-
Notifications
You must be signed in to change notification settings - Fork 769
[SYCL] Adjust kernel parameters requirements #1014
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[SYCL] Adjust kernel parameters requirements #1014
Conversation
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.
LGTM with a few suggestions.
@@ -2199,8 +2199,9 @@ static bool mustSkipTailPadding(TargetCXXABI ABI, const CXXRecordDecl *RD) { | |||
llvm_unreachable("bad tail-padding use kind"); | |||
} | |||
|
|||
static bool isMsLayout(const ASTContext &Context) { | |||
return Context.getTargetInfo().getCXXABI().isMicrosoft(); | |||
static bool isMsLayout(const ASTContext &Context, bool CheckAuxABI = false) { |
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.
What if we change parameter type to TargetInfo
?
static bool isMsLayout(const ASTContext &Context, bool CheckAuxABI = false) { | |
static bool isMsLayout(const TargeInfo *TI) { |
usage
if (isMsLayout(*this.getTargetInfo())) ...
...
if (isMsLayout(*this.getAuxTargetInfo())) ...
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.
Then we will need to change usage of this function for 3 additional times not including the one which I changed. And these 3 additional places of isMsLayout
usage aren't connected with my current patch. Are you sure?
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.
I don't see any problems with this refactoring.
The benefit I see from this change is that we move if
statement higher in the call stack as exactly the same logic is already implemented higher in the calls stack. On the other hand, I hope all isMsLayout
calls are inlined and this might not be a problem.
I'll leave final decision to 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.
I'd like to keep unrelated parts of code unchanged.
Is that now the default to accept trivially copyable instead of standard layout? The current SYCL 1.2.1 specification still mentions standard layout. I think maybe this should be an option when you pass "-std=sycl-1.2.1-intel" so that "-std=sycl-1.2.1" is conformant to the current spec. |
Make sense to me. |
Note that the standard currently requires standard layout and trivially copyable. Thus if we make the check for std-layout a compiler option than the more strict option should check for both and not just standard layout (as before this change). BTW: the standard doesn't require a diagnostic from the compiler. It just says it is a requirement without saying whether it is UB/implementation-defined/diagnostic-required/.... Thus I don't think removing the check makes it non-spec compliant. Having said that I'm not apposed to add a compiler switch. |
I am not entirely disagreeing with you, but the spec document only requires standard layout for kernel parameter passing. SYCL 1.2.1, 3.10:
SYCL 1.2.1, 4.8.9.1:
SYCL 1.2.1, 4.8.11: (Rules for kernel parameters)
Trivially copyable is a condition only for the
The only mention of both trivially copyable and standard layout is on Table 4.78 for the |
1003bcc
to
7bf61f1
Compare
Okay, for me the SPEC seems a bit unclear about trivially-copyable requirement, when it's clear about standard layout requirement, so I've added a front-end option, which is not enabled when |
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.
LGTM.
The way this is written this refers to both kernel arguments and buffers AFAICS. The sentence before even explicitly lists both lambda capture and accessors. Of course I suggest we remove the whole (IMO useless) std-layout requirement from the spec.
You are right. But this is a clear omission and needs to be fixed. There is no way to implement argument passing without breaking the C++ memory model (http://eel.is/c++draft/basic.types#3). |
@@ -233,6 +233,7 @@ LANGOPT(GPUMaxThreadsPerBlock, 32, 256, "default max threads per block for kerne | |||
LANGOPT(SYCLIsDevice , 1, 0, "Generate code for SYCL device") | |||
LANGOPT(SYCLIsHost , 1, 0, "SYCL host compilation") | |||
LANGOPT(SYCLAllowFuncPtr , 1, 0, "Allow function pointers in SYCL device code") | |||
LANGOPT(SYCLNewKernelParamReq, 1, 0, "Enable trivially copyable requirement instead of standard layout requirement for SYCL kernel parameters") |
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.
I disagree with this choice. Trvially copyable should always be required. Even before we fix the SYCL spec it is required by the C++ spec. This option should only enable/disable whether std-layout is also checked. And the same way as our other usability improvements the default should be that the std-layout check is off.
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.
So, we will always require trivially copyable and enable/disable standard layout using option.
@Ruyk , What do you think about it?
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.
Yeah that makes some sense. The SYCL standard requires standard layout, which is why i would expect -sycl-std=sycl-1.2.1 to ask for standard layout.
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.
requirement Standard layout is too restrictive (prevents things like tuple). To make using of non-standard layout structs safe compiler builds structs layout in accordance with host ABI. Signed-off-by: Mariya Podchishchaeva <mariya.podchishchaeva@intel.com>
Signed-off-by: Mariya Podchishchaeva <mariya.podchishchaeva@intel.com>
Signed-off-by: Mariya Podchishchaeva <mariya.podchishchaeva@intel.com>
Signed-off-by: Mariya Podchishchaeva <mariya.podchishchaeva@intel.com>
37fb682
to
d6830e2
Compare
Enable standard layout requirement passing front-end option which `-sycl-std=1.2.1.` driver option turnes on. Signed-off-by: Mariya Podchishchaeva <mariya.podchishchaeva@intel.com>
Signed-off-by: Mariya Podchishchaeva <mariya.podchishchaeva@intel.com>
Okay, I implemented checking of trivially copyable requirement by default and option to enable standard layout requirement checking. We check standard layout requirement only if |
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.
Thanks! LGTM.
That is why I said at the start that I am not entirely disagreeing with your comments. However, the fact is the published 1.2.1 spec is what it is, and if a change is needed, the place is the SYCL WG in Khronos IP zone, or at least the public SYCL-DOC spec, so everyone can track and follow this discussion. In the meantime, I suggest we should try to keep all implementations aligned as to what is a valid SYCL program conformant to the spec. Whatever defaults you guys want to have is your choice, but to me at least when using -sycl-std=1.2.1, it should match what the text says. |
@rolandschulz ping. |
Standard layout is too restrictive (prevents things like tuple). Enable standard layout requirement only if
-sycl-std=1.2.1
is set.To make using of non-standard layout structs safe compiler builds structs layout in accordance with host ABI.
Add trivially copyable requirement for all parameters.
Signed-off-by: Mariya Podchishchaeva mariya.podchishchaeva@intel.com