-
Notifications
You must be signed in to change notification settings - Fork 790
fix merge after readding syclkernel attr #20363
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
Conversation
Signed-off-by: Sarnie, Nick <[email protected]>
FYI @tahonermann |
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 started looking at this, but it is going to take more time than I have available tonight. I'll resume tomorrow.
static KernelReferenceKind getDefaultKernelReference(const FunctionDecl *D) { | ||
return (D->hasAttr<DeviceKernelAttr>() || D->getLangOpts().CUDAIsDevice) | ||
return (D->hasAttr<DeviceKernelAttr>() || D->getLangOpts().CUDAIsDevice || | ||
D->hasAttr<SYCLKernelAttr>()) |
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'm not sure that checking for SYCLKernelAttr
is correct here. We didn't check for it prior to llvm/llvm-project#137882 landing.
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.
Right, upstream didnt, but we did in syclos
before we pulled down that commit, see here https://github.com/intel/llvm/blob/nightly-2025-07-18/clang/include/clang/AST/GlobalDecl.h#L168
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.
Please prioritize the review, we will need to merge this later today to unblock pulldown. Thanks. |
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've done what I can to review. I find git archeology in the presence of pull down merges really difficult, so I wouldn't be surprised if I've missed things. There is one bit of code that I think is incorrect and at least one other one that I'm unsure of. Otherwise, it looks like @sarnex has done his homework on this quite well.
static KernelReferenceKind getDefaultKernelReference(const FunctionDecl *D) { | ||
return (D->hasAttr<DeviceKernelAttr>() || D->getLangOpts().CUDAIsDevice) | ||
return (D->hasAttr<DeviceKernelAttr>() || D->getLangOpts().CUDAIsDevice || | ||
D->hasAttr<SYCLKernelAttr>()) |
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.
if (S.getASTContext().getTargetInfo().getTriple().isNVPTX()) { | ||
>>>>>>> 1db148cc946eb95fefd5399766e379fc030eef78 | ||
handleGlobalAttr(S, D, AL); |
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'm not sure this is right. Prior to llvm/llvm-project#137882, processing of NVPTXKernelAttr
and CUDAGlobalAttr
were not dependent on an NVPTX target. I'm not sure if this has ramifications for the SYCL-CUDA compat mode.
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.
For NVPTXKernelAttr
, it looks like it is target dependent in the attr definition:
def NVPTXKernel : InheritableAttr, **TargetSpecificAttr<TargetNVPTX>** {
so if the target doesn't match the the attr is never added, the check for the target agains the attr is in ParsedAttr
, before we create that NVPTXKernel
object
and this function can't be hit for CUDAGlobalAttr
because it's guarded by a check for DeviceKernelAttr
.
so I think the cases handleGlobalAttr
sees NVPTXKernelAttr
or CUDAGlobalAttr
are the exact same before and after
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 think I agree with that, but shouldn't there also be a check for isNVPTXSpelling()
? If the spelling is "__kernel" or "kernel", I would expect the else branch to be the desired control flow.
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.
upstream Joseph was really against target-specific behavior, and even if seems confusing he would prefer for all the remaining spellings of DeviceKernelAttr
to be aliases, expect for OpenCL because it's very particular, and if we do make a change like that i would expect it to be upstream
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 understand that he would like to have one attribute for kernels that are strongly tied to a particular target (though I don't necessarily agree with him). With this code as is though, wouldn't use of the OpenCL spellings end up going down the wrong branch when targeting NVPTX?
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 I think you're right, but it doesn't seem to be causing any problems either upstream or here.
Is it okay if we move forward with this PR in syclos and I make a PR upstream to add a check so we don't go down this branch for OpenCL spellings?
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.
Sure, I think that is reasonable.
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.
Co-authored-by: Tom Honermann <[email protected]>
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'm going to go ahead and improve with the understanding that one outstanding issue will be addressed by a separate PR that targets upstream. All of my other concerns have been addressed.
Thanks, will work on the upstream PR immedately. @jsji @premanandrao Please merge this when you are ready |
Thank you @tahonermann and @sarnex |
bool FunctionDecl::isReferenceableKernel() const { | ||
return hasAttr<CUDAGlobalAttr>() || | ||
DeviceKernelAttr::isOpenCLSpelling(getAttr<DeviceKernelAttr>()) || hasAttr<DeviceKernelAttr>(); | ||
return hasAttr<CUDAGlobalAttr>() || |
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.
Duplicate lines:
return hasAttr() ||
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 is OK, I will remove it in the amend commit.
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.
ah my bad, github suggestion UI 👎
fix merge after llvm/llvm-project#162868
check-clang
passes with only 3 unrelated failures that were failing before the breaking change