-
Notifications
You must be signed in to change notification settings - Fork 744
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
[SYCL] Add support for kernel name types templated using enums. #1675
Conversation
Signed-off-by: Elizabeth Andrews <[email protected]>
Signed-off-by: Elizabeth Andrews <[email protected]>
Signed-off-by: Elizabeth Andrews <[email protected]>
@premanandrao I've added a test for anonymous namespaces. I'm waiting on your response about enums in SYCL headers, before removing the 'in cl namespace' check. Thanks! |
I took another look at the integration header and the includes here are defines.hpp and kernel_desc.hpp. As far as I can tell the only namespaces visible in integration header are therefore 'cl' and anything declared in cstddef (which is included in kernel_desc.hpp). Given that information do you still think we should remove the 'enum defined in cl namespace' check? Removing this check would result in a lot of unnecessary forward declarations in the integration header - since most sycl programs use the enums defined in SYCL headers. |
I don't think this is right. <kernel_desc.hpp> includes many other header files and a lot of other symbols including enums are visible. Perhaps you were looking at the minimal version in the test directories?
But the forward declarations are only for the cases where they are used as kernel name types. |
Oh right. Yes that's true. Got confused for a second. I'll remove the check. |
I'm having some trouble with emitting the global scope specifiers. I can emit it for template arguments by getting Argument type for each argument and creating fullyQualifiedType
But I'm not sure what to do about template name. Currently I'm emitting it using printQualifiedName but this does not emit global scope specifier. Would someone know how I can go about this? |
What do you mean by "global scope specifier". Do you mean the scope resolution operator? (::)? |
Yes. That is what I meant. After my patch,
has become
5d22a8e was done a while ago to start the search for namespaces from global namespace |
I have no idea how that worked (or why 'suppress typedefs' did it...). I haven't looked closely into the printer, but I think @premanandrao has. Prem, can you take a look? |
Yes, I will take a look. |
Removed check for CL namespace. Emit scope resolution operator for global namespace. Added test when underlying type is not fixed. Signed-off-by: Elizabeth Andrews <[email protected]>
…o fixed underlying type Signed-off-by: Elizabeth Andrews <[email protected]>
clang/lib/Sema/SemaSYCL.cpp
Outdated
|
||
for (unsigned I = 0; I < Args.size(); I++) { | ||
const TemplateArgument &Arg = Args[I]; | ||
if (Arg.getKind() == TemplateArgument::ArgKind::Pack) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems a lot like a few of the other places we emit arguments based on their kind. Is there a way to dispatch the body of much of this instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maaaaybe. But I think the function body is not similar enough to make this efficient. Both functions are looping over arguments to emit 'something' but what is being emitted is different.
Minor refactoring when emitting scope resolution operator. Added tests got unscoped enum. Added comment syntax for bool argument. Signed-off-by: Elizabeth Andrews <[email protected]>
Signed-off-by: Elizabeth Andrews <[email protected]>
Signed-off-by: Elizabeth Andrews <[email protected]>
Signed-off-by: Elizabeth Andrews <[email protected]>
Signed-off-by: Elizabeth Andrews <[email protected]>
Thanks for the review everyone! |
http://ci.llvm.intel.com:8010/#/builders/37/builds/859/steps/15/logs/FAIL__SYCL-Unit__CudaInteropGetNativeTests_interop - this failure seems to be unrelated to the patch. |
Also fixed handling of template argument type - enum type. The prior patch handled only enum values, not the type itself. Signed-off-by: Elizabeth Andrews <[email protected]>
52add49
Signed-off-by: Elizabeth Andrews <[email protected]>
Changed 'check' function to return true on error. Changed diagnostic message. Signed-off-by: Elizabeth Andrews <[email protected]>
// expected-error@+2 {{kernel name is invalid. Unscoped enum requires fixed underlying type}} | ||
template <unscoped_enum_no_type_set EnumType> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be great if this diagnostic will also point to concrete single_task
/parallel_for
kernel invocation call which caused this error. See
// expected-error@+4 {{kernel needs to have a globally-visible name}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is because kernel location is set differently when kernel is defined using a lambda vs a functor. I just tested kernelname-enum.cpp using lambdas instead of functors and the diagnostic is generated at the point of kernel invocation like this example above. Since this is an existing issue with all diagnostics emitted when kernel is defined using functors, I'd like to work on this as a separate issue if that is alright with you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay. We need to capture this problem somehow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. I'll file a bug and assign it to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Signed-off-by: Elizabeth Andrews <[email protected]>
* sycl: (65 commits) [SYCL] Host task implementation (intel#1471) [SYCL] Update getting dependencies documentation (intel#1699) [SYCL] Fix types and transparent functors recognition in reduction (intel#1709) [SYCL][Doc] Get started guide clean-up (intel#1697) Add --spirv-fp-contract={on|off|fast} option (intel#509) [SYCL][Doc] Fix tbb target path in Get Started Guide. (intel#1695) [SYCL] Add support for kernel name types templated using enums. (intel#1675) [Driver][SYCL] Make -std=c++17 the default for DPC++ (intel#1662) AllocaInst should store Align instead of MaybeAlign. [X86] Replace selectScalarSSELoad ComplexPattern with PatFrags to handle the 3 types of loads we currently match. Harden IR and bitcode parsers against infinite size types. Revert "[nfc] test commit" [nfc] test commit Expose IRGen API to add the default IR attributes to a function definition. The release notes for ObjCBreakBeforeNestedBlockParam was placed between the release note for IndentCaseBlocks and its example code [VectorCombine] forward walk through instructions to improve chaining of transforms [PhaseOrdering] add vector reduction tests; NFC [InstCombine] Clean up alignment handling (NFC) [ARM] Patterns for VQSHRN [VectorCombine] add reduction-like patterns; NFC ...
Forward declaration of enum used as template parameter for kernel name type is now emitted in integration header.
Enumerators in name type is also replaced with their underlying integer value since the enum definition is not visible in integration header..
E.g. For following application/user code:
The following is generated in integration header:
Signed-off-by: Elizabeth Andrews [email protected]