-
Notifications
You must be signed in to change notification settings - Fork 769
[SYCL] Add template parameter support for intel_reqd_sub_group_size a… #1807
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
158622c
to
d5481a6
Compare
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 few nits:
Please also add a test in CodeGenSYCL.
clang/lib/Sema/SemaDeclAttr.cpp
Outdated
return; | ||
} | ||
int32_t ArgInt = ArgVal.getSExtValue(); | ||
if (ArgInt < 0) { |
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 (ArgInt < 0) { | |
if (ArgInt <= 0) { |
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.
Done
clang/lib/Sema/SemaDeclAttr.cpp
Outdated
int32_t ArgInt = ArgVal.getSExtValue(); | ||
if (ArgInt < 0) { | ||
Diag(E->getExprLoc(), diag::err_attribute_requires_positive_integer) | ||
<< Attr.getAttrName() << /*non-negative*/ 1; |
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.
<< Attr.getAttrName() << /*non-negative*/ 1; | |
<< Attr.getAttrName() << /*positive*/ 0; |
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.
Done
clang/lib/Sema/SemaDeclAttr.cpp
Outdated
<< Attr.getAttrName() << /*non-negative*/ 1; | ||
return; | ||
} | ||
if (ArgInt == 0) { |
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 (ArgInt == 0) { |
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.
Done
static void instantiateIntelReqdSubGroupSizeAttr( | ||
Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, | ||
const IntelReqdSubGroupSizeAttr *Attr, Decl *New) { | ||
// The SubGroupSize expression is a constant expressions. | ||
EnterExpressionEvaluationContext Unevaluated( | ||
S, Sema::ExpressionEvaluationContext::ConstantEvaluated); | ||
ExprResult Result = S.SubstExpr(Attr->getSubGroupSize(), TemplateArgs); | ||
if (!Result.isInvalid()) | ||
S.addIntelReqdSubGroupSizeAttr(New, *Attr, Result.getAs<Expr>()); | ||
} |
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 shouldn't block this particular patch since is a general problem, but I want to highlight it.
If you take a look at the code above, you will feel deja vu, because there are a ton of same copy-pasted functions for other SYCL attributes (most of them for FPGA). I think we have to get rid of this copy-paste and unify same code across different attribute handling.
static void instantiateIntelReqdSubGroupSizeAttr( | ||
Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, | ||
const IntelReqdSubGroupSizeAttr *Attr, Decl *New) { | ||
// The SubGroupSize expression is a constant expressions. |
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.
// The SubGroupSize expression is a constant expressions. | |
// The SubGroupSize expression is a constant expression. |
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.
Done
a6ec392
to
61a072f
Compare
Please don't force push unless absolutely necessary, it removes the conversations. That said, it seems the latest force-push doesn't do all the comments above. |
Sorry about this. I did not know that this removes the conversation. |
…ttribute Signed-off-by: Soumi Manna <soumi.manna@intel.com>
61a072f
to
d96007d
Compare
You seem to have force-pushed again. Please don't. |
Sorry for the force-pushed again. Does " git push origin " command work.? It is not allowing me to push the patch. |
I am not sure why clang-format check is failing with invalid-kernel-attr.cl file. |
Looks like it wants you to align comment indentation for kernel15 with the comment on next string. |
Do you store new changes into the same commit via amend option? git push doesn't work in this case. You should add new changes into separate commit. |
@@ -35,7 +35,7 @@ kernel __attribute__((reqd_work_group_size(1,0,2))) void kernel12(){} // expecte | |||
kernel __attribute__((reqd_work_group_size(0,1,2))) void kernel13(){} // expected-error {{'reqd_work_group_size' attribute must be greater than 0}} | |||
|
|||
__attribute__((intel_reqd_sub_group_size(8))) void kernel14(){} // expected-error {{attribute 'intel_reqd_sub_group_size' can only be applied to an OpenCL kernel}} | |||
kernel __attribute__((intel_reqd_sub_group_size(0))) void kernel15(){} // expected-error {{'intel_reqd_sub_group_size' attribute must be greater than 0}} | |||
kernel __attribute__((intel_reqd_sub_group_size(0))) void kernel15(){} // expected-error {{'intel_reqd_sub_group_size' attribute requires a positive integral compile time constant expression}} |
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 has changed because you're now treating this as a signed value, whereas the previous code treated it as unsigned, and thus a different error message makes sense.
Please add a test with a negative value as well to make sure that doesn't change again. I realize you have one in the template version, but I'd like one right next to this one to show intent.
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 have added a test with a negative value. But it seems like changing again. I will try to add inserting of empty line to fix the clang-format check error.
…ttribute Signed-off-by: Soumi Manna <soumi.manna@intel.com>
…ttribute Signed-off-by: Soumi Manna <soumi.manna@intel.com>
Sorry about the multiple submission. I am still trying to figure out why clang-format is failing even with inserting of empty line. |
https://clang.llvm.org/docs/ClangFormat.html#script-for-patch-reformatting - this should help you to fix the formatting. |
@bader Thanks. I will try this. |
…ttribute Signed-off-by: Soumi Manna <soumi.manna@intel.com>
Thanks @mlychkov. Yes, empty line was needed here. |
Thanks @mlychkov , yes i used git amend command that's why git push did not work. |
clang/include/clang/Sema/Sema.h
Outdated
@@ -9917,6 +9917,11 @@ class Sema final { | |||
|
|||
bool checkNSReturnsRetainedReturnType(SourceLocation loc, QualType type); | |||
|
|||
// addIntelReqdSubGroupSizeAttr - Adds an intel_reqd_sub_group_size attribute |
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.
// addIntelReqdSubGroupSizeAttr - Adds an intel_reqd_sub_group_size attribute | |
// Adds an intel_reqd_sub_group_size attribute |
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.
Done
// RUN: %clang_cc1 -fsycl -fsycl-is-device -fsyntax-only -verify -pedantic %s | ||
// RUN: %clang_cc1 -fsycl -fsycl-is-device -fsyntax-only -ast-dump -verify -pedantic %s | FileCheck %s |
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.
Doesn't the second command cover both diagnostics and AST 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.
Thanks @bader. Yes, the second command covers both diagnostics and AST checks.
First RUN command is not needed and this is removed now.
…ttribute Signed-off-by: Soumi Manna <soumi.manna@intel.com>
A little refactoring, addressed to a comment: intel#1807 (comment) Signed-off-by: Dmitry Sidorov <dmitry.sidorov@intel.com>
A little refactoring, addressed to a comment: #1807 (comment) Signed-off-by: Dmitry Sidorov <dmitry.sidorov@intel.com>
Fixed an issue with comparing pointers to Attr objects rather than values passed to the attribute in source code. Refactored IntelReqdSubGroupSizeAttr class to store evaluated value of attribute value for further uses to avoid evaluating it each time we need that value to check something. The bug were uncovered after intel#1778 landed, but it had been introduced in intel#1807
Template parameter support was added for 1. [[intel::max_global_work_dim)]] attribute on intel#2816 2. [[intel::num_simd_work_items()]] attribute on intel#2510 3. [[intel::reqd_sub_group_size()]] attribute on intel#1807 This patch adds the following new test cases that were not there before to improve the support: 1. Test that checks wrong function template instantiation and ensures that the type is checked properly when instantiating from the template definition. 2. Test that checks expression is not a constant expression. 3. Test that checks expression is a constant expression. 4. Test that checks template parameter support on function. NOTE: No change in compiler. All new test cases have already been supported. Signed-off-by: Soumi Manna <soumi.manna@intel.com>
…3089) Template parameter support was added for 1. [[intel::max_global_work_dim)]] attribute on #2816 2. [[intel::num_simd_work_items()]] attribute on #2510 3. [[intel::reqd_sub_group_size()]] attribute on #1807 This patch adds the following new test cases that were not there before to improve the support: 1. Test that checks wrong function template instantiation and ensures that the type is checked properly when instantiating from the template definition. 2. Test that checks expression is not a constant expression. 3. Test that checks expression is a constant expression. 4. Test that checks template parameter support on function. NOTE: No change in compiler. All new test cases have already been supported. Signed-off-by: Soumi Manna <soumi.manna@intel.com>
Update FileCheck patterns for llvm-project commit eae26b6 ("[IRBuilder] Use canonical i64 type for insertelement index used by vector splats.", 2023-01-11). Original commit: KhronosGroup/SPIRV-LLVM-Translator@ced105f
…ttribute
Signed-off-by: Soumi Manna soumi.manna@intel.com