-
Notifications
You must be signed in to change notification settings - Fork 768
[SYCL] Enable OpenCL diagnostics for sampler in SYCL mode #167
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
I think if we are going to remove OpTypeSampler usages, we should also remove it from clang tests. |
Thanks for reminding about this. |
This PR is superseded by #171. |
Note: in #171 diagnostics aren't enabled. |
Okay. I'll re-open this PR. |
@@ -6347,6 +6347,26 @@ NamedDecl *Sema::ActOnVariableDeclarator( | |||
return nullptr; | |||
} | |||
|
|||
if (R->isSamplerT()) { |
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.
Shouldn't we guard this code under if (getLangOpts().SYCLIsDevice || getLangOpts().OpenCL)
?
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.
Sampler type is enabled only for OpenCL and SYCL modes, so if R->isSamplerT()
returns true
, we know that getLangOpts().SYCLIsDevice || getLangOpts().OpenCL
is also true
.
There might be some other environments which might be interested in enabling this data type, so if they what to disable this diagnostics they will have to extend the condition.
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.
But this code already was under if (getLangOpts().OpenCL)
, maybe this if could help to understand this code in the future.
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.
@AnastasiaStulova asked for applying changes like this as removing redundant checks should speed-up compilation.
@@ -6347,6 +6347,26 @@ NamedDecl *Sema::ActOnVariableDeclarator( | |||
return nullptr; | |||
} | |||
|
|||
if (R->isSamplerT()) { | |||
// OpenCL v1.2 s6.9.b p4: |
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 comment looks stange. We implement some OpenCL restrictions but not only for OpenCL.
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.
Yes. Any suggestions?
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.
Actually I can't find any restrictions for sampler in SYCL spec. I think we can leave comment describes that SYCL re-uses OpenCL types so these restrictions applied for SYCL too but it's not necessary.
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.
NOTE: the restriction is enabled for all languages, which allows sampler type. I don't think explicitly mentioning SYCL here is good idea.
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. So, why we are explicitly mentioning OpenCL here?
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 the place where the behavior of this type is defined.
@@ -5634,6 +5634,9 @@ void InitializationSequence::InitializeFrom(Sema &S, | |||
bool allowObjCWritebackConversion = S.getLangOpts().ObjCAutoRefCount && | |||
Entity.isParameterKind(); | |||
|
|||
if (TryOCLSamplerInitialization(S, *this, DestType, Initializer)) |
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.
Sorry, could you please clarify: why do you need this change?
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.
To enable sampler initialization diagnostics in SYCL 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.
Okay, I didn't see why it can't work on old place. I will expand hidden code next time.
Looks like we need also move TryOCLZeroOpaqueTypeInitialization
if we want enable diagnostics for event in the future.
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.
Event type diagnostics should be enabled separately.
@@ -2322,7 +2322,7 @@ QualType Sema::BuildArrayType(QualType T, ArrayType::ArraySizeModifier ASM, | |||
// OpenCL v2.0 s6.12.5 - Arrays of blocks are not supported. | |||
// OpenCL v2.0 s6.16.13.1 - Arrays of pipe type are not supported. | |||
// OpenCL v2.0 s6.9.b - Arrays of image/sampler type are not supported. | |||
if (getLangOpts().OpenCL) { | |||
if (getLangOpts().OpenCL || getLangOpts().SYCLIsDevice) { |
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.
Following the logic:
Sampler type is enabled only for OpenCL and SYCL modes, so if R->isSamplerT() returns true, we know that getLangOpts().SYCLIsDevice || getLangOpts().OpenCL is also true.
Can't we remove getLangOpts checks?
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 think so.
Blocks are not OpenCL specific types.
Removed comments are redundant and complicate maintenance. Signed-off-by: Alexey Bader <alexey.bader@intel.com>
Signed-off-by: Alexey Bader <alexey.bader@intel.com>
Selectively enabled a few OpenCL diagnostics for sampler type as some diagnostics trigger on SYCL use cases. For instance, OpenCL kernel in SYCL mode initializes lambda captures with the kernel argument values. This initialization code for sampler emits errors because OpenCL disallows sampler on the right hand side of the binary operators - these are supposed to be used only by built-in functions. Another potential issue is the lambda object itself - captured sampler is a member of the lambda object and OpenCL doesn't allow composite types with samplers. SPIR-V produced from SYCL should be okay as lambda object can be removed by standard LLVM transformation passes. Signed-off-by: Alexey Bader <alexey.bader@intel.com>
Selectively enabled a few OpenCL diagnostics for sampler type as some
diagnostics trigger on SYCL use cases.
For instance, OpenCL kernel in SYCL mode initializes lambda captures with
the kernel argument values. This initialization code for sampler emits
errors because OpenCL disallows sampler on the right hand side of the
binary operators - these are supposed to be used only by built-in
functions.
Another potential issue is the lambda object itself -
captured sampler is a member of the lambda object and OpenCL doesn't
allow composite types with samplers. SPIR-V produced from SYCL should be
okay as lambda object can be removed by standard LLVM transformation
passes.