Skip to content

[SYCL] Immutable kernel functions redo. #2259

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

cperkinsintel
Copy link
Contributor

@cperkinsintel cperkinsintel commented Aug 4, 2020

This is the same immutable kernel functions PR that was merged (and reverted) last week. The SYCL conformance tests have been updated, so hopefully this should be mergeable. I've added the __SYCL_NONCONST_FUNCTOR__ as requested.

I have also hooked up the -sycl-std= compiler driver flag so that it will pass DCL_SYCL_LANGUAGE_VERSION=121 if SYCL 1.2.1 is chosen or DCL_SYCL_LANGUAGE_VERSION=2020 if SYCL 2020 is chosen.

In SYCL 2020 kernel functions are now const and passed by reference. In this PR the existing API constant CL_SYCL_LANGUAGE_VERSION now determine another constant ( SYCL_NONCONST_FUNCTOR ) that makes the kernel functions be constant references (or not).

In the Clang Front end, both by-reference and by-value passing of the kernel functions is supported, and a diagnostic emitted if that is mismatched. The sycl-std flag now supports 2020 as a valid option. And the sycl-std flag will pass -DCL_SYCL_LANGUAGE_VERSION= to match its election. Tests have been added to confirm that both kernel passings are supported and that the sycl-std flag is working correctly. Additionally, there are a lot of FE tests that employ mock kernels, these have been updated to the SYCL 2020 convention avoiding the deferred maintenance.

Signed-off-by: Chris Perkins chris.perkins@intel.com

@cperkinsintel cperkinsintel changed the title [WIP] - Do Not Merge -- immutable kernel functions redo. [SYCL] - Ready for Review -- immutable kernel functions redo. Aug 5, 2020
@cperkinsintel cperkinsintel force-pushed the cperkins-immutable-kernel-functions-redo branch from c2f532c to 2b005ed Compare August 5, 2020 20:06
@cperkinsintel
Copy link
Contributor Author

There is a warning that is being emitted by ExternalASTSource.h when building the ASTImporterTest.cpp unit test. I wasn't seeing this until I rebased. However, it seems to be in the sycl branch of intel/llvm.

Fznamznon
Fznamznon previously approved these changes Aug 10, 2020
Copy link
Contributor

@Fznamznon Fznamznon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FE changes LGTM.

// SYCL 2020 - kernel functions are passed by reference.
template <typename name, typename Func>
#if defined(SYCL2017)
// expected-warning@+2 {{Passing of kernel functions by reference is a SYCL 2020 extension}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably should be emitted as a note or only in pedantic mode. This API can be back-ported to SYCL-1.2.1 mode (as it's done in our implementation if I understand the patch), but it might be supported by other implementations. IIRC, DPC++ compiler sets -Wsycl-strict if -sycl-std= option is set. Am I right?

I'd like to hear @erichkeane opinion on this.

Suggested change
// expected-warning@+2 {{Passing of kernel functions by reference is a SYCL 2020 extension}}
// expected-warning@+2 {{Passing of kernel functions by reference is a SYCL 2020 extension}}

"extension"? I think this is standard SYCL-2020 API.

@@ -707,7 +707,39 @@ getKernelInvocationKind(FunctionDecl *KernelCallerFunc) {

static const CXXRecordDecl *getKernelObjectType(FunctionDecl *Caller) {
assert(Caller->getNumParams() > 0 && "Insufficient kernel parameters");
return Caller->getParamDecl(0)->getType()->getAsCXXRecordDecl();

QualType KernelParamTy = (*Caller->param_begin())->getType();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if you've done the re-merge yet, but this line changes a bit to Caller->getParamDecl(0)->getType().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

erichkeane
erichkeane previously approved these changes Aug 13, 2020
Copy link
Contributor

@erichkeane erichkeane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just scrolled through the test changes, but the CFE parts look ok to me. Properly rebased as well it appears.

if (KernelParamTy->isReferenceType()) {
// passing by reference, so emit warning if not using SYCL 2020
if (LangOpts.SYCLVersion < 2020)
Diag(KernelFunc->getLocation(), diag::warn_sycl_pass_by_reference_future);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note for other reviewers: since these are just warnings, we don't want them invalidating the kernelFunc.

Comment on lines 468 to 469
else if (LangOpts.SYCLVersion == 2020)
Builder.defineMacro("CL_SYCL_LANGUAGE_VERSION", "2020");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From SYCL-2020 provisional specification.

"SYCL_LANGUAGE_VERSION substitutes an integer reflecting the version number and revision of the SYCL
language being supported by the implementation. The version of SYCL defined in this document will
have SYCL_LANGUAGE_VERSION substitute the integer 202001, composed with the general SYCL version
followed by 2 digits representing the revision number;"

As SYCL targets non-OpenCL API now, I suggest defining SYCL_LANGUAGE_VERSION for any SYCL version using "YEARREVISION" format and define CL_SYCL_LANGUAGE_VERSION=121 only for SYCL-1.2.1.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks. Done.

@bader bader requested a review from romanovvlad August 13, 2020 12:11
@cperkinsintel cperkinsintel force-pushed the cperkins-immutable-kernel-functions-redo branch from 7ccef1e to 07fab10 Compare August 13, 2020 17:52
@cperkinsintel
Copy link
Contributor Author

/summary:run

Signed-off-by: Chris Perkins <chris.perkins@intel.com>
Signed-off-by: Chris Perkins <chris.perkins@intel.com>
Signed-off-by: Chris Perkins <chris.perkins@intel.com>
Signed-off-by: Chris Perkins <chris.perkins@intel.com>
Signed-off-by: Chris Perkins <chris.perkins@intel.com>
Signed-off-by: Chris Perkins <chris.perkins@intel.com>
Signed-off-by: Chris Perkins <chris.perkins@intel.com>
Signed-off-by: Chris Perkins <chris.perkins@intel.com>
Signed-off-by: Chris Perkins <chris.perkins@intel.com>
Signed-off-by: Chris Perkins <chris.perkins@intel.com>
Signed-off-by: Chris Perkins <chris.perkins@intel.com>
Signed-off-by: Chris Perkins <chris.perkins@intel.com>
Signed-off-by: Chris Perkins <chris.perkins@intel.com>
Signed-off-by: Chris Perkins <chris.perkins@intel.com>
Signed-off-by: Chris Perkins <chris.perkins@intel.com>
Signed-off-by: Chris Perkins <chris.perkins@intel.com>
@cperkinsintel cperkinsintel force-pushed the cperkins-immutable-kernel-functions-redo branch from 8073b8e to 391ba54 Compare August 17, 2020 21:23
@cperkinsintel
Copy link
Contributor Author

rebased (again) -

@cperkinsintel cperkinsintel requested a review from bader August 17, 2020 21:32
@bader
Copy link
Contributor

bader commented Aug 18, 2020

/summary:run

@cperkinsintel
Copy link
Contributor Author

I have no idea what is going on with the Jenkins Summary - the error doesn't even look like it's pulling the same PR. But as that is not required, is it possible to get this merged anyway?

This PR touches a lot of files, has been reviewed several times, but lately each time we go to merge there is a conflict with some other change, so I have to rebase, re-run the tests, re-request reviews, and by the time it all finishes, another conflict will be introduced.

@bader bader merged commit 1dbc358 into intel:sycl Aug 19, 2020
bader pushed a commit that referenced this pull request Sep 3, 2020
Support _for_  `sycl-std=2020` was added in an earlier PR( #2259 ) but the default SYCL version was left alone.  Now we are changing the FE so that if not otherwise specified `sycl-std=2020` is elected as the default.

Signed-off-by: Chris Perkins <chris.perkins@intel.com>
@cperkinsintel cperkinsintel deleted the cperkins-immutable-kernel-functions-redo branch September 13, 2023 17:08
jsji pushed a commit that referenced this pull request Dec 21, 2023
SPIRVEntry created in function getEntry isn't deleted when
it is ExtOp and isn't SourceContinued.

Original commit:
KhronosGroup/SPIRV-LLVM-Translator@b891a51
Chenyang-L pushed a commit that referenced this pull request Feb 18, 2025
[L0] Enable Immediate Command Lists by default given Intel GPU DG2 or newer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants