From 2fc939ba6b59c95f4f5022845ff58232acf2c004 Mon Sep 17 00:00:00 2001 From: Aleksander Fadeev Date: Fri, 28 Feb 2020 14:57:00 +0300 Subject: [PATCH 01/16] [SYCL] reqd_work_group_size attribute is reversed Signed-off-by: Aleksander Fadeev --- clang/lib/Sema/SemaDeclAttr.cpp | 38 ++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index c6d8acadb8a64..ecb5dda8f6f7c 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -10,6 +10,7 @@ // //===----------------------------------------------------------------------===// +//#include "clang/Basic/Attributes.h" #include "clang/AST/ASTConsumer.h" #include "clang/AST/ASTContext.h" #include "clang/AST/ASTMutationListener.h" @@ -2943,11 +2944,46 @@ static void handleWorkGroupSize(Sema &S, Decl *D, const ParsedAttr &AL) { Existing->getYDim() == WGSize[1] && Existing->getZDim() == WGSize[2])) S.Diag(AL.getLoc(), diag::warn_duplicate_attribute) << AL; - D->addAttr(::new (S.Context) WorkGroupAttr(S.Context, AL, WGSize[0], WGSize[1], WGSize[2])); } +template <> +void handleWorkGroupSize(Sema &S, Decl *D, const ParsedAttr &AL) { + if (D->isInvalidDecl()) + return; + + uint32_t WGSize[3]; + for (unsigned i = 0; i < 3; ++i) { + const Expr *E = AL.getArgAsExpr(i); + if (!checkUInt32Argument(S, AL, E, WGSize[i], i, + /*StrictlyUnsigned=*/true)) + return; + if (WGSize[i] == 0) { + S.Diag(AL.getLoc(), diag::err_attribute_argument_is_zero) + << AL << E->getSourceRange(); + return; + } + } + + if (!checkWorkGroupSizeValues(S, D, AL, WGSize)) + return; + + ReqdWorkGroupSizeAttr *Existing = D->getAttr(); + if (Existing && !(Existing->getXDim() == WGSize[0] && + Existing->getYDim() == WGSize[1] && + Existing->getZDim() == WGSize[2])) + S.Diag(AL.getLoc(), diag::warn_duplicate_attribute) << AL; + if (S.getLangOpts().SYCLIsDevice){ + D->addAttr(::new (S.Context) + ReqdWorkGroupSizeAttr(S.Context, AL, WGSize[2], WGSize[1], WGSize[0])); + } + else{ + D->addAttr(::new (S.Context) + ReqdWorkGroupSizeAttr(S.Context, AL, WGSize[0], WGSize[1], WGSize[2])); + } +} + // Handles intel_reqd_sub_group_size. static void handleSubGroupSize(Sema &S, Decl *D, const ParsedAttr &AL) { uint32_t SGSize; From 3582e970048730a4f6dadb40396af407c1d32a86 Mon Sep 17 00:00:00 2001 From: Aleksander Fadeev Date: Fri, 28 Feb 2020 15:11:36 +0300 Subject: [PATCH 02/16] [SYCL] reqd_work_group_size attribute is reversed (fix #2) Signed-off-by: Aleksander Fadeev --- clang/lib/Sema/SemaDeclAttr.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index ecb5dda8f6f7c..d0c268b8e85e3 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -10,7 +10,6 @@ // //===----------------------------------------------------------------------===// -//#include "clang/Basic/Attributes.h" #include "clang/AST/ASTConsumer.h" #include "clang/AST/ASTContext.h" #include "clang/AST/ASTMutationListener.h" From 3c6ea835307967c503d2398e6197908b4b26928f Mon Sep 17 00:00:00 2001 From: Aleksander Fadeev Date: Fri, 28 Feb 2020 16:11:32 +0300 Subject: [PATCH 03/16] [SYCL] reqd_work_group_size attribute is reversed (fixed #3) Signed-off-by: Aleksander Fadeev --- clang/lib/Sema/SemaDeclAttr.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index d0c268b8e85e3..f359036218262 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -2948,7 +2948,8 @@ static void handleWorkGroupSize(Sema &S, Decl *D, const ParsedAttr &AL) { } template <> -void handleWorkGroupSize(Sema &S, Decl *D, const ParsedAttr &AL) { +void handleWorkGroupSize(Sema &S, Decl *D, + const ParsedAttr &AL) { if (D->isInvalidDecl()) return; @@ -2969,17 +2970,16 @@ void handleWorkGroupSize(Sema &S, Decl *D, const ParsedAt return; ReqdWorkGroupSizeAttr *Existing = D->getAttr(); - if (Existing && !(Existing->getXDim() == WGSize[0] && - Existing->getYDim() == WGSize[1] && - Existing->getZDim() == WGSize[2])) + if (Existing && + !(Existing->getXDim() == WGSize[0] && Existing->getYDim() == WGSize[1] && + Existing->getZDim() == WGSize[2])) S.Diag(AL.getLoc(), diag::warn_duplicate_attribute) << AL; - if (S.getLangOpts().SYCLIsDevice){ - D->addAttr(::new (S.Context) - ReqdWorkGroupSizeAttr(S.Context, AL, WGSize[2], WGSize[1], WGSize[0])); - } - else{ - D->addAttr(::new (S.Context) - ReqdWorkGroupSizeAttr(S.Context, AL, WGSize[0], WGSize[1], WGSize[2])); + if (S.getLangOpts().SYCLIsDevice) { + D->addAttr(::new (S.Context) ReqdWorkGroupSizeAttr(S.Context, AL, WGSize[2], + WGSize[1], WGSize[0])); + } else { + D->addAttr(::new (S.Context) ReqdWorkGroupSizeAttr(S.Context, AL, WGSize[0], + WGSize[1], WGSize[2])); } } From b14013def07f55d7befec47630d8f7f54d82a015 Mon Sep 17 00:00:00 2001 From: Aleksander Fadeev Date: Fri, 28 Feb 2020 18:18:26 +0300 Subject: [PATCH 04/16] [SYCL] reqd_work_group_size attribute is reversed (fix #4) Signed-off-by: Aleksander Fadeev --- clang/test/SemaSYCL/reqd-work-group-size.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/test/SemaSYCL/reqd-work-group-size.cpp b/clang/test/SemaSYCL/reqd-work-group-size.cpp index d2336fa4ffcce..af838c862070a 100644 --- a/clang/test/SemaSYCL/reqd-work-group-size.cpp +++ b/clang/test/SemaSYCL/reqd-work-group-size.cpp @@ -110,9 +110,9 @@ void bar() { } // CHECK: FunctionDecl {{.*}} {{.*}}kernel_name1 -// CHECK: ReqdWorkGroupSizeAttr {{.*}} 16 1 1 +// CHECK: ReqdWorkGroupSizeAttr {{.*}} 1 1 16 // CHECK: FunctionDecl {{.*}} {{.*}}kernel_name2 -// CHECK: ReqdWorkGroupSizeAttr {{.*}} 4 1 1 +// CHECK: ReqdWorkGroupSizeAttr {{.*}} 1 1 4 // CHECK: FunctionDecl {{.*}} {{.*}}kernel_name3 // CHECK: ReqdWorkGroupSizeAttr {{.*}} 16 16 16 // CHECK: FunctionDecl {{.*}} {{.*}}kernel_name4 From 1d0d7512bbaaa7bf896574b4d2b479b79aef689f Mon Sep 17 00:00:00 2001 From: Aleksander Fadeev Date: Mon, 2 Mar 2020 18:52:35 +0300 Subject: [PATCH 05/16] [SYCL] reqd_work_group_size attribute is reversed (fix #5) Signed-off-by: Aleksander Fadeev --- clang/lib/Sema/SemaDeclAttr.cpp | 40 +++++---------------------------- 1 file changed, 5 insertions(+), 35 deletions(-) diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index f359036218262..77c3faf22b774 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -2943,46 +2943,16 @@ static void handleWorkGroupSize(Sema &S, Decl *D, const ParsedAttr &AL) { Existing->getYDim() == WGSize[1] && Existing->getZDim() == WGSize[2])) S.Diag(AL.getLoc(), diag::warn_duplicate_attribute) << AL; + if (S.getLangOpts().SYCLIsDevice) + D->addAttr(::new (S.Context) + WorkGroupAttr(S.Context, AL, WGSize[2], WGSize[1], WGSize[0])); + else D->addAttr(::new (S.Context) WorkGroupAttr(S.Context, AL, WGSize[0], WGSize[1], WGSize[2])); -} - -template <> -void handleWorkGroupSize(Sema &S, Decl *D, - const ParsedAttr &AL) { - if (D->isInvalidDecl()) - return; - - uint32_t WGSize[3]; - for (unsigned i = 0; i < 3; ++i) { - const Expr *E = AL.getArgAsExpr(i); - if (!checkUInt32Argument(S, AL, E, WGSize[i], i, - /*StrictlyUnsigned=*/true)) - return; - if (WGSize[i] == 0) { - S.Diag(AL.getLoc(), diag::err_attribute_argument_is_zero) - << AL << E->getSourceRange(); - return; - } - } - if (!checkWorkGroupSizeValues(S, D, AL, WGSize)) - return; - - ReqdWorkGroupSizeAttr *Existing = D->getAttr(); - if (Existing && - !(Existing->getXDim() == WGSize[0] && Existing->getYDim() == WGSize[1] && - Existing->getZDim() == WGSize[2])) - S.Diag(AL.getLoc(), diag::warn_duplicate_attribute) << AL; - if (S.getLangOpts().SYCLIsDevice) { - D->addAttr(::new (S.Context) ReqdWorkGroupSizeAttr(S.Context, AL, WGSize[2], - WGSize[1], WGSize[0])); - } else { - D->addAttr(::new (S.Context) ReqdWorkGroupSizeAttr(S.Context, AL, WGSize[0], - WGSize[1], WGSize[2])); - } } + // Handles intel_reqd_sub_group_size. static void handleSubGroupSize(Sema &S, Decl *D, const ParsedAttr &AL) { uint32_t SGSize; From ff6746a28b7d85fe332ed3c44bf1295b83d59f30 Mon Sep 17 00:00:00 2001 From: Aleksander Fadeev Date: Tue, 3 Mar 2020 13:59:42 +0300 Subject: [PATCH 06/16] [SYCL] reqd_work_group_size attribute is reversed (fix #6) Signed-off-by: Aleksander Fadeev --- clang/test/CodeGenSYCL/reqd-work-group-size.cpp | 4 ++-- clang/test/CodeGenSYCL/sycl-multi-kernel-attr.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/clang/test/CodeGenSYCL/reqd-work-group-size.cpp b/clang/test/CodeGenSYCL/reqd-work-group-size.cpp index 5fd4f6a84358e..f2d91453661ee 100644 --- a/clang/test/CodeGenSYCL/reqd-work-group-size.cpp +++ b/clang/test/CodeGenSYCL/reqd-work-group-size.cpp @@ -33,7 +33,7 @@ void bar() { // CHECK: define spir_kernel void @{{.*}}kernel_name1() {{.*}} !reqd_work_group_size ![[WGSIZE32:[0-9]+]] // CHECK: define spir_kernel void @{{.*}}kernel_name2() {{.*}} !reqd_work_group_size ![[WGSIZE8:[0-9]+]] // CHECK: define spir_kernel void @{{.*}}kernel_name3() {{.*}} !reqd_work_group_size ![[WGSIZE88:[0-9]+]] -// CHECK: ![[WGSIZE32]] = !{i32 32, i32 16, i32 16} -// CHECK: ![[WGSIZE8]] = !{i32 8, i32 1, i32 1} +// CHECK: ![[WGSIZE32]] = !{i32 16, i32 16, i32 32} +// CHECK: ![[WGSIZE8]] = !{i32 1, i32 1, i32 8} // CHECK: ![[WGSIZE88]] = !{i32 8, i32 8, i32 8} diff --git a/clang/test/CodeGenSYCL/sycl-multi-kernel-attr.cpp b/clang/test/CodeGenSYCL/sycl-multi-kernel-attr.cpp index 7b1ce6921e105..f0072c196ea53 100644 --- a/clang/test/CodeGenSYCL/sycl-multi-kernel-attr.cpp +++ b/clang/test/CodeGenSYCL/sycl-multi-kernel-attr.cpp @@ -17,5 +17,5 @@ void bar() { } // CHECK: define spir_kernel void @{{.*}}kernel_name() {{.*}} !reqd_work_group_size ![[WGSIZE:[0-9]+]] !intel_reqd_sub_group_size ![[SGSIZE:[0-9]+]] -// CHECK: ![[WGSIZE]] = !{i32 32, i32 16, i32 16} +// CHECK: ![[WGSIZE]] = !{i32 16, i32 16, i32 32} // CHECK: ![[SGSIZE]] = !{i32 4} From 245f323743e615047f4a625a32a1442b7e423c73 Mon Sep 17 00:00:00 2001 From: Aleksander Fadeev Date: Tue, 3 Mar 2020 14:43:49 +0300 Subject: [PATCH 07/16] [SYCL] reqd_work_group_size attribute is reversed (fix #6) Signed-off-by: Aleksander Fadeev --- clang/lib/Sema/SemaDeclAttr.cpp | 8 ++++---- clang/test/SemaSYCL/intel-max-global-work-dim.cpp | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 77c3faf22b774..f5a036a764d66 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -2898,16 +2898,16 @@ static bool checkWorkGroupSizeValues(Sema &S, Decl *D, const ParsedAttr &Attr, /*ReverseAttrs=*/ true); if (const auto *A = D->getAttr()) { - if (!(WGSize[0] <= A->getXDim() && WGSize[1] <= A->getYDim() && - WGSize[2] <= A->getZDim())) { + if (!(WGSize[2] <= A->getXDim() && WGSize[1] <= A->getYDim() && + WGSize[0] <= A->getZDim())) { S.Diag(Attr.getLoc(), diag::err_conflicting_sycl_function_attributes) << Attr << A->getSpelling(); Result &= false; } } if (const auto *A = D->getAttr()) { - if (!(WGSize[0] >= A->getXDim() && WGSize[1] >= A->getYDim() && - WGSize[2] >= A->getZDim())) { + if (!(WGSize[2] >= A->getXDim() && WGSize[1] >= A->getYDim() && + WGSize[0] >= A->getZDim())) { S.Diag(Attr.getLoc(), diag::err_conflicting_sycl_function_attributes) << Attr << A->getSpelling(); Result &= false; diff --git a/clang/test/SemaSYCL/intel-max-global-work-dim.cpp b/clang/test/SemaSYCL/intel-max-global-work-dim.cpp index 26f43ef1a5f92..6b196c75331aa 100644 --- a/clang/test/SemaSYCL/intel-max-global-work-dim.cpp +++ b/clang/test/SemaSYCL/intel-max-global-work-dim.cpp @@ -82,8 +82,8 @@ int main() { kernel( TRIFuncObjGood2()); // CHECK-LABEL: FunctionDecl {{.*}} _ZTSZ4mainE12test_kernel5 - // CHECK: ReqdWorkGroupSizeAttr {{.*}} 4 1 1 - // CHECK: SYCLIntelMaxWorkGroupSizeAttr {{.*}} 8 1 1 + // CHECK: ReqdWorkGroupSizeAttr {{.*}} 1 1 4 + // CHECK: SYCLIntelMaxWorkGroupSizeAttr {{.*}} 1 1 8 // CHECK: SYCLIntelMaxGlobalWorkDimAttr {{.*}} 3 #ifdef TRIGGER_ERROR From 9125bc17b0f813b9b567f081a155e44d41d9c0d0 Mon Sep 17 00:00:00 2001 From: Aleksander Fadeev Date: Tue, 3 Mar 2020 15:14:20 +0300 Subject: [PATCH 08/16] [SYCL] reqd_work_group_size attribute is reversed (fix #8) Signed-off-by: Aleksander Fadeev --- clang/lib/Sema/SemaDeclAttr.cpp | 18 ++++++++---------- .../test/CodeGenSYCL/reqd-work-group-size.cpp | 3 +-- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index f5a036a764d66..3e6daa0a92d87 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -2939,20 +2939,18 @@ static void handleWorkGroupSize(Sema &S, Decl *D, const ParsedAttr &AL) { return; WorkGroupAttr *Existing = D->getAttr(); - if (Existing && !(Existing->getXDim() == WGSize[0] && - Existing->getYDim() == WGSize[1] && - Existing->getZDim() == WGSize[2])) + if (Existing && + !(Existing->getXDim() == WGSize[0] && Existing->getYDim() == WGSize[1] && + Existing->getZDim() == WGSize[2])) S.Diag(AL.getLoc(), diag::warn_duplicate_attribute) << AL; if (S.getLangOpts().SYCLIsDevice) - D->addAttr(::new (S.Context) - WorkGroupAttr(S.Context, AL, WGSize[2], WGSize[1], WGSize[0])); - else - D->addAttr(::new (S.Context) - WorkGroupAttr(S.Context, AL, WGSize[0], WGSize[1], WGSize[2])); - + D->addAttr(::new (S.Context) WorkGroupAttr(S.Context, AL, WGSize[2], + WGSize[1], WGSize[0])); + else + D->addAttr(::new (S.Context) WorkGroupAttr(S.Context, AL, WGSize[0], + WGSize[1], WGSize[2])); } - // Handles intel_reqd_sub_group_size. static void handleSubGroupSize(Sema &S, Decl *D, const ParsedAttr &AL) { uint32_t SGSize; diff --git a/clang/test/CodeGenSYCL/reqd-work-group-size.cpp b/clang/test/CodeGenSYCL/reqd-work-group-size.cpp index f2d91453661ee..896cb2d997784 100644 --- a/clang/test/CodeGenSYCL/reqd-work-group-size.cpp +++ b/clang/test/CodeGenSYCL/reqd-work-group-size.cpp @@ -27,7 +27,7 @@ void bar() { kernel(f); kernel( - []() [[cl::reqd_work_group_size(8, 8, 8)]] {}); + []() [[cl::reqd_work_group_size(8, 8, 8)]]{}); } // CHECK: define spir_kernel void @{{.*}}kernel_name1() {{.*}} !reqd_work_group_size ![[WGSIZE32:[0-9]+]] @@ -36,4 +36,3 @@ void bar() { // CHECK: ![[WGSIZE32]] = !{i32 16, i32 16, i32 32} // CHECK: ![[WGSIZE8]] = !{i32 1, i32 1, i32 8} // CHECK: ![[WGSIZE88]] = !{i32 8, i32 8, i32 8} - From a7eef4be3876cc914377180cd5c4b41b9f7c5576 Mon Sep 17 00:00:00 2001 From: Aleksander Fadeev Date: Wed, 4 Mar 2020 17:02:55 +0300 Subject: [PATCH 09/16] [SYCL] reqd_work_group_size attribute is reversed (fix #9) Signed-off-by: Aleksander Fadeev --- clang/lib/Sema/SemaDeclAttr.cpp | 33 +++++++++++++++----- clang/test/SemaSYCL/reqd-work-group-size.cpp | 4 +-- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 3e6daa0a92d87..4cf219f286eee 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -2898,21 +2898,33 @@ static bool checkWorkGroupSizeValues(Sema &S, Decl *D, const ParsedAttr &Attr, /*ReverseAttrs=*/ true); if (const auto *A = D->getAttr()) { - if (!(WGSize[2] <= A->getXDim() && WGSize[1] <= A->getYDim() && + if (S.getLangOpts().SYCLIsDevice && !(WGSize[2] <= A->getXDim() && WGSize[1] <= A->getYDim() && WGSize[0] <= A->getZDim())) { S.Diag(Attr.getLoc(), diag::err_conflicting_sycl_function_attributes) << Attr << A->getSpelling(); Result &= false; } - } - if (const auto *A = D->getAttr()) { - if (!(WGSize[2] >= A->getXDim() && WGSize[1] >= A->getYDim() && - WGSize[0] >= A->getZDim())) { + if (!S.getLangOpts().SYCLIsDevice && !(WGSize[0] <= A->getXDim() && WGSize[1] <= A->getYDim() && + WGSize[2] <= A->getZDim())) { S.Diag(Attr.getLoc(), diag::err_conflicting_sycl_function_attributes) << Attr << A->getSpelling(); Result &= false; } } + if (const auto *A = D->getAttr()) { + if (S.getLangOpts().SYCLIsDevice && !(WGSize[2] >= A->getXDim() && WGSize[1] >= A->getYDim() && + WGSize[0] >= A->getZDim())) { + S.Diag(Attr.getLoc(), diag::err_conflicting_sycl_function_attributes) + << Attr << A->getSpelling(); + Result &= false; + } + if (!S.getLangOpts().SYCLIsDevice && !(WGSize[0] >= A->getXDim() && WGSize[1] >= A->getYDim() && + WGSize[2] >= A->getZDim())) { + S.Diag(Attr.getLoc(), diag::err_conflicting_sycl_function_attributes) + << Attr << A->getSpelling(); + Result &= false; + } + } return Result; } @@ -2939,10 +2951,15 @@ static void handleWorkGroupSize(Sema &S, Decl *D, const ParsedAttr &AL) { return; WorkGroupAttr *Existing = D->getAttr(); - if (Existing && - !(Existing->getXDim() == WGSize[0] && Existing->getYDim() == WGSize[1] && - Existing->getZDim() == WGSize[2])) + if (S.getLangOpts().SYCLIsDevice && Existing && !(Existing->getXDim() == WGSize[2] && + Existing->getYDim() == WGSize[1] && + Existing->getZDim() == WGSize[0])) S.Diag(AL.getLoc(), diag::warn_duplicate_attribute) << AL; + if (!S.getLangOpts().SYCLIsDevice && Existing && !(Existing->getXDim() == WGSize[0] && + Existing->getYDim() == WGSize[1] && + Existing->getZDim() == WGSize[2])) + S.Diag(AL.getLoc(), diag::warn_duplicate_attribute) << AL; + if (S.getLangOpts().SYCLIsDevice) D->addAttr(::new (S.Context) WorkGroupAttr(S.Context, AL, WGSize[2], WGSize[1], WGSize[0])); diff --git a/clang/test/SemaSYCL/reqd-work-group-size.cpp b/clang/test/SemaSYCL/reqd-work-group-size.cpp index af838c862070a..a3a7d9d648f74 100644 --- a/clang/test/SemaSYCL/reqd-work-group-size.cpp +++ b/clang/test/SemaSYCL/reqd-work-group-size.cpp @@ -42,7 +42,7 @@ class Functor16x16x16 { class Functor8 { // expected-error {{conflicting attributes applied to a SYCL kernel}} public: - [[cl::reqd_work_group_size(8, 1, 1)]] void operator()() { // expected-note {{conflicting attribute is here}} + [[cl::reqd_work_group_size(1, 1, 8)]] [[cl::reqd_work_group_size(1, 1, 8)]] void operator()() { // expected-note {{conflicting attribute is here}} f4x1x1(); } }; @@ -77,7 +77,7 @@ void bar() { FunctorAttr fattr; kernel(fattr); - kernel([]() [[cl::reqd_work_group_size(32, 32, 32)]] { + kernel([]() [[cl::reqd_work_group_size(32, 32, 32), cl::reqd_work_group_size(32, 32, 32)]] { f32x32x32(); }); From 2b6df0107976163e2c2e1f2b50b5228395ed22a5 Mon Sep 17 00:00:00 2001 From: Aleksander Fadeev Date: Wed, 4 Mar 2020 18:30:30 +0300 Subject: [PATCH 10/16] [SYCL] reqd_work_group_size attribute is reversed (fix #10) Signed-off-by: Aleksander Fadeev --- clang/test/SemaSYCL/reqd-work-group-size.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/test/SemaSYCL/reqd-work-group-size.cpp b/clang/test/SemaSYCL/reqd-work-group-size.cpp index a3a7d9d648f74..722f4c20f6f8b 100644 --- a/clang/test/SemaSYCL/reqd-work-group-size.cpp +++ b/clang/test/SemaSYCL/reqd-work-group-size.cpp @@ -32,7 +32,7 @@ void bar() { class Functor16 { public: - [[cl::reqd_work_group_size(16, 1, 1)]] void operator()() {} + [[cl::reqd_work_group_size(16, 1, 1)]] [[cl::reqd_work_group_size(16, 1, 1)]] void operator()() {} }; class Functor16x16x16 { @@ -42,7 +42,7 @@ class Functor16x16x16 { class Functor8 { // expected-error {{conflicting attributes applied to a SYCL kernel}} public: - [[cl::reqd_work_group_size(1, 1, 8)]] [[cl::reqd_work_group_size(1, 1, 8)]] void operator()() { // expected-note {{conflicting attribute is here}} + [[cl::reqd_work_group_size(1, 1, 8)]] void operator()() { // expected-note {{conflicting attribute is here}} f4x1x1(); } }; From 5c3501f165ef7b7424124a2185510cd19f302665 Mon Sep 17 00:00:00 2001 From: Aleksander Fadeev Date: Wed, 4 Mar 2020 18:37:37 +0300 Subject: [PATCH 11/16] [SYCL] reqd_work_group_size attribute is reversed (fix #11) Signed-off-by: Aleksander Fadeev --- clang/lib/Sema/SemaDeclAttr.cpp | 46 +++++++++++--------- clang/test/SemaSYCL/reqd-work-group-size.cpp | 10 ++--- 2 files changed, 29 insertions(+), 27 deletions(-) diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 4cf219f286eee..d6957b2057f98 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -2895,16 +2895,18 @@ static bool checkWorkGroupSizeValues(Sema &S, Decl *D, const ParsedAttr &Attr, if (const auto *A = D->getAttr()) if (A->getNumber() == 0) Result &= checkZeroDim(A, WGSize[0], WGSize[1], WGSize[2], - /*ReverseAttrs=*/ true); + /*ReverseAttrs=*/true); if (const auto *A = D->getAttr()) { - if (S.getLangOpts().SYCLIsDevice && !(WGSize[2] <= A->getXDim() && WGSize[1] <= A->getYDim() && + if (S.getLangOpts().SYCLIsDevice && + !(WGSize[2] <= A->getXDim() && WGSize[1] <= A->getYDim() && WGSize[0] <= A->getZDim())) { S.Diag(Attr.getLoc(), diag::err_conflicting_sycl_function_attributes) << Attr << A->getSpelling(); Result &= false; } - if (!S.getLangOpts().SYCLIsDevice && !(WGSize[0] <= A->getXDim() && WGSize[1] <= A->getYDim() && + if (!S.getLangOpts().SYCLIsDevice && + !(WGSize[0] <= A->getXDim() && WGSize[1] <= A->getYDim() && WGSize[2] <= A->getZDim())) { S.Diag(Attr.getLoc(), diag::err_conflicting_sycl_function_attributes) << Attr << A->getSpelling(); @@ -2912,18 +2914,20 @@ static bool checkWorkGroupSizeValues(Sema &S, Decl *D, const ParsedAttr &Attr, } } if (const auto *A = D->getAttr()) { - if (S.getLangOpts().SYCLIsDevice && !(WGSize[2] >= A->getXDim() && WGSize[1] >= A->getYDim() && - WGSize[0] >= A->getZDim())) { - S.Diag(Attr.getLoc(), diag::err_conflicting_sycl_function_attributes) - << Attr << A->getSpelling(); - Result &= false; - } - if (!S.getLangOpts().SYCLIsDevice && !(WGSize[0] >= A->getXDim() && WGSize[1] >= A->getYDim() && - WGSize[2] >= A->getZDim())) { - S.Diag(Attr.getLoc(), diag::err_conflicting_sycl_function_attributes) - << Attr << A->getSpelling(); - Result &= false; - } + if (S.getLangOpts().SYCLIsDevice && + !(WGSize[2] >= A->getXDim() && WGSize[1] >= A->getYDim() && + WGSize[0] >= A->getZDim())) { + S.Diag(Attr.getLoc(), diag::err_conflicting_sycl_function_attributes) + << Attr << A->getSpelling(); + Result &= false; + } + if (!S.getLangOpts().SYCLIsDevice && + !(WGSize[0] >= A->getXDim() && WGSize[1] >= A->getYDim() && + WGSize[2] >= A->getZDim())) { + S.Diag(Attr.getLoc(), diag::err_conflicting_sycl_function_attributes) + << Attr << A->getSpelling(); + Result &= false; + } } return Result; } @@ -2951,13 +2955,13 @@ static void handleWorkGroupSize(Sema &S, Decl *D, const ParsedAttr &AL) { return; WorkGroupAttr *Existing = D->getAttr(); - if (S.getLangOpts().SYCLIsDevice && Existing && !(Existing->getXDim() == WGSize[2] && - Existing->getYDim() == WGSize[1] && - Existing->getZDim() == WGSize[0])) + if (S.getLangOpts().SYCLIsDevice && Existing && + !(Existing->getXDim() == WGSize[2] && Existing->getYDim() == WGSize[1] && + Existing->getZDim() == WGSize[0])) S.Diag(AL.getLoc(), diag::warn_duplicate_attribute) << AL; - if (!S.getLangOpts().SYCLIsDevice && Existing && !(Existing->getXDim() == WGSize[0] && - Existing->getYDim() == WGSize[1] && - Existing->getZDim() == WGSize[2])) + if (!S.getLangOpts().SYCLIsDevice && Existing && + !(Existing->getXDim() == WGSize[0] && Existing->getYDim() == WGSize[1] && + Existing->getZDim() == WGSize[2])) S.Diag(AL.getLoc(), diag::warn_duplicate_attribute) << AL; if (S.getLangOpts().SYCLIsDevice) diff --git a/clang/test/SemaSYCL/reqd-work-group-size.cpp b/clang/test/SemaSYCL/reqd-work-group-size.cpp index 722f4c20f6f8b..0d01c081e06c5 100644 --- a/clang/test/SemaSYCL/reqd-work-group-size.cpp +++ b/clang/test/SemaSYCL/reqd-work-group-size.cpp @@ -7,7 +7,6 @@ class Functor { public: [[cl::reqd_work_group_size(4, 1, 1)]] void operator()() {} - }; template @@ -24,10 +23,10 @@ void bar() { // expected-note@-1 {{conflicting attribute is here}} [[cl::reqd_work_group_size(32, 1, 1)]] void f32x1x1() {} // expected-note {{conflicting attribute is here}} -[[cl::reqd_work_group_size(16, 1, 1)]] void f16x1x1() {} // expected-note {{conflicting attribute is here}} +[[cl::reqd_work_group_size(16, 1, 1)]] void f16x1x1() {} // expected-note {{conflicting attribute is here}} [[cl::reqd_work_group_size(16, 16, 1)]] void f16x16x1() {} // expected-note {{conflicting attribute is here}} -[[cl::reqd_work_group_size(32, 32, 1)]] void f32x32x1() {} // expected-note {{conflicting attribute is here}} +[[cl::reqd_work_group_size(32, 32, 1)]] void f32x32x1() {} // expected-note {{conflicting attribute is here}} [[cl::reqd_work_group_size(32, 32, 32)]] void f32x32x32() {} // expected-note {{conflicting attribute is here}} class Functor16 { @@ -78,10 +77,9 @@ void bar() { kernel(fattr); kernel([]() [[cl::reqd_work_group_size(32, 32, 32), cl::reqd_work_group_size(32, 32, 32)]] { - f32x32x32(); + f32x32x32(); }); - #ifdef TRIGGER_ERROR Functor8 f8; kernel(f8); @@ -102,7 +100,7 @@ void bar() { }); // expected-error@+1 {{expected variable name or 'this' in lambda capture list}} - kernel([[cl::reqd_work_group_size(32, 32, 32)]] []() { + kernel([[cl::reqd_work_group_size(32, 32, 32)]][]() { f32x32x32(); }); From 43f265fba6e597ca259fccfb119a12775c38aaac Mon Sep 17 00:00:00 2001 From: Aleksander Fadeev Date: Wed, 4 Mar 2020 20:24:13 +0300 Subject: [PATCH 12/16] [SYCL] reqd_work_group_size attribute is reversed (fix #12) Signed-off-by: Aleksander Fadeev --- clang/lib/Sema/SemaDeclAttr.cpp | 7 ++++--- clang/test/SemaSYCL/reqd-work-group-size.cpp | 14 +++++++++++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index d6957b2057f98..ba9186af44599 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -2914,6 +2914,7 @@ static bool checkWorkGroupSizeValues(Sema &S, Decl *D, const ParsedAttr &Attr, } } if (const auto *A = D->getAttr()) { + if (S.getLangOpts().SYCLIsDevice && !(WGSize[2] >= A->getXDim() && WGSize[1] >= A->getYDim() && WGSize[0] >= A->getZDim())) { @@ -2951,9 +2952,6 @@ static void handleWorkGroupSize(Sema &S, Decl *D, const ParsedAttr &AL) { } } - if (!checkWorkGroupSizeValues(S, D, AL, WGSize)) - return; - WorkGroupAttr *Existing = D->getAttr(); if (S.getLangOpts().SYCLIsDevice && Existing && !(Existing->getXDim() == WGSize[2] && Existing->getYDim() == WGSize[1] && @@ -2964,6 +2962,9 @@ static void handleWorkGroupSize(Sema &S, Decl *D, const ParsedAttr &AL) { Existing->getZDim() == WGSize[2])) S.Diag(AL.getLoc(), diag::warn_duplicate_attribute) << AL; + if (!checkWorkGroupSizeValues(S, D, AL, WGSize)) + return; + if (S.getLangOpts().SYCLIsDevice) D->addAttr(::new (S.Context) WorkGroupAttr(S.Context, AL, WGSize[2], WGSize[1], WGSize[0])); diff --git a/clang/test/SemaSYCL/reqd-work-group-size.cpp b/clang/test/SemaSYCL/reqd-work-group-size.cpp index 0d01c081e06c5..08c68801da462 100644 --- a/clang/test/SemaSYCL/reqd-work-group-size.cpp +++ b/clang/test/SemaSYCL/reqd-work-group-size.cpp @@ -34,6 +34,14 @@ class Functor16 { [[cl::reqd_work_group_size(16, 1, 1)]] [[cl::reqd_work_group_size(16, 1, 1)]] void operator()() {} }; +#ifdef TRIGGER_ERROR +class Functor32 { +public: + //expected-warning@+2{{attribute 'reqd_work_group_size' is already applied with different parameters}} + // expected-error@+1{{'reqd_work_group_size' attribute conflicts with 'reqd_work_group_size' attribute}} + [[cl::reqd_work_group_size(32, 1, 1)]] [[cl::reqd_work_group_size(1, 1, 32)]] void operator()() {} +}; +#endif class Functor16x16x16 { public: [[cl::reqd_work_group_size(16, 16, 16)]] void operator()() {} @@ -66,7 +74,7 @@ __attribute__((sycl_kernel)) void kernel(Func kernelFunc) { void bar() { Functor16 f16; kernel(f16); - + Functor f; kernel(f); @@ -84,7 +92,11 @@ void bar() { Functor8 f8; kernel(f8); + Functor32 f32; + kernel(f32); + kernel([]() { // expected-error {{conflicting attributes applied to a SYCL kernel}} + f4x1x1(); f32x1x1(); }); From 5831eb4bf984441731e161bd9d15f5195b2a5327 Mon Sep 17 00:00:00 2001 From: Aleksander Fadeev Date: Thu, 5 Mar 2020 14:28:20 +0300 Subject: [PATCH 13/16] [SYCL] reqd_work_group_size attribute is reversed (fix #13) Signed-off-by: Aleksander Fadeev --- clang/lib/Sema/SemaDeclAttr.cpp | 2 +- clang/test/SemaSYCL/reqd-work-group-size.cpp | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index ba9186af44599..6c377c77d6255 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -2914,7 +2914,7 @@ static bool checkWorkGroupSizeValues(Sema &S, Decl *D, const ParsedAttr &Attr, } } if (const auto *A = D->getAttr()) { - + if (S.getLangOpts().SYCLIsDevice && !(WGSize[2] >= A->getXDim() && WGSize[1] >= A->getYDim() && WGSize[0] >= A->getZDim())) { diff --git a/clang/test/SemaSYCL/reqd-work-group-size.cpp b/clang/test/SemaSYCL/reqd-work-group-size.cpp index 08c68801da462..4daa3c08227a6 100644 --- a/clang/test/SemaSYCL/reqd-work-group-size.cpp +++ b/clang/test/SemaSYCL/reqd-work-group-size.cpp @@ -40,7 +40,7 @@ class Functor32 { //expected-warning@+2{{attribute 'reqd_work_group_size' is already applied with different parameters}} // expected-error@+1{{'reqd_work_group_size' attribute conflicts with 'reqd_work_group_size' attribute}} [[cl::reqd_work_group_size(32, 1, 1)]] [[cl::reqd_work_group_size(1, 1, 32)]] void operator()() {} -}; +}; #endif class Functor16x16x16 { public: @@ -74,7 +74,7 @@ __attribute__((sycl_kernel)) void kernel(Func kernelFunc) { void bar() { Functor16 f16; kernel(f16); - + Functor f; kernel(f); @@ -96,7 +96,6 @@ void bar() { kernel(f32); kernel([]() { // expected-error {{conflicting attributes applied to a SYCL kernel}} - f4x1x1(); f32x1x1(); }); From 8696f6e3be84d7d34d6a9798f97b27fca339d570 Mon Sep 17 00:00:00 2001 From: Aleksander Fadeev Date: Thu, 5 Mar 2020 14:28:20 +0300 Subject: [PATCH 14/16] [SYCL] reqd_work_group_size attribute is reversed (fix #13) Signed-off-by: Aleksander Fadeev --- clang/include/clang/Basic/Attr.td | 10 +++++++++- clang/lib/Sema/SemaDeclAttr.cpp | 8 ++++++-- clang/test/SemaSYCL/reqd-work-group-size.cpp | 5 ++--- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index fc8d392e3937a..df97ab51252b7 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -1147,7 +1147,7 @@ def SYCLIntelKernelArgsRestrict : InheritableAttr { def SYCLIntelNumSimdWorkItems : InheritableAttr { let Spellings = [CXX11<"intelfpga","num_simd_work_items">]; - let Args = [UnsignedArgument<"Number">]; + let Args = [IntArgument<"Number">]; let LangOpts = [SYCLIsDevice, SYCLIsHost]; let Subjects = SubjectList<[Function], ErrorDiag>; let Documentation = [SYCLIntelNumSimdWorkItemsAttrDocs]; @@ -2420,6 +2420,14 @@ def ReqdWorkGroupSize : InheritableAttr { let Documentation = [Undocumented]; } +def SYCLIntelReqdWorkGroupSize : InheritableAttr { + let Spellings = [CXX11<"intel","reqd_work_group_size">]; + let Args = [IntArgument<"XDim">, DefaultIntArgument<"YDim", 1>, + DefaultIntArgument<"ZDim", 1>]; + let Subjects = SubjectList<[Function], ErrorDiag>; + let Documentation = [Undocumented]; +} + def WorkGroupSizeHint : InheritableAttr { // Does not have a [[]] spelling because it is an OpenCL-related attribute. let Spellings = [GNU<"work_group_size_hint">]; diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index ba9186af44599..56b9df2789ae5 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -2914,7 +2914,7 @@ static bool checkWorkGroupSizeValues(Sema &S, Decl *D, const ParsedAttr &Attr, } } if (const auto *A = D->getAttr()) { - + if (S.getLangOpts().SYCLIsDevice && !(WGSize[2] >= A->getXDim() && WGSize[1] >= A->getYDim() && WGSize[0] >= A->getZDim())) { @@ -2940,9 +2940,13 @@ static void handleWorkGroupSize(Sema &S, Decl *D, const ParsedAttr &AL) { return; uint32_t WGSize[3]; + if (const auto *A = D->getAttr()){ + WGSize[1] = SYCLIntelReqdWorkGroupSizeAttr::DefaultYDim; + WGSize[2] = SYCLIntelReqdWorkGroupSizeAttr::DefaultZDim; + } for (unsigned i = 0; i < 3; ++i) { const Expr *E = AL.getArgAsExpr(i); - if (!checkUInt32Argument(S, AL, E, WGSize[i], i, + if (i < AL.getNumArgs() && !checkUInt32Argument(S, AL, E, WGSize[i], i, /*StrictlyUnsigned=*/true)) return; if (WGSize[i] == 0) { diff --git a/clang/test/SemaSYCL/reqd-work-group-size.cpp b/clang/test/SemaSYCL/reqd-work-group-size.cpp index 08c68801da462..4daa3c08227a6 100644 --- a/clang/test/SemaSYCL/reqd-work-group-size.cpp +++ b/clang/test/SemaSYCL/reqd-work-group-size.cpp @@ -40,7 +40,7 @@ class Functor32 { //expected-warning@+2{{attribute 'reqd_work_group_size' is already applied with different parameters}} // expected-error@+1{{'reqd_work_group_size' attribute conflicts with 'reqd_work_group_size' attribute}} [[cl::reqd_work_group_size(32, 1, 1)]] [[cl::reqd_work_group_size(1, 1, 32)]] void operator()() {} -}; +}; #endif class Functor16x16x16 { public: @@ -74,7 +74,7 @@ __attribute__((sycl_kernel)) void kernel(Func kernelFunc) { void bar() { Functor16 f16; kernel(f16); - + Functor f; kernel(f); @@ -96,7 +96,6 @@ void bar() { kernel(f32); kernel([]() { // expected-error {{conflicting attributes applied to a SYCL kernel}} - f4x1x1(); f32x1x1(); }); From dc704bfd4f71739b637851d7d2727bf18092ac58 Mon Sep 17 00:00:00 2001 From: Aleksander Fadeev Date: Fri, 6 Mar 2020 17:18:32 +0300 Subject: [PATCH 15/16] [SYCL] reqd_work_group_size attribute is reversed (fix #14) Signed-off-by: Aleksander Fadeev --- clang/include/clang/Basic/Attr.td | 8 ------ clang/lib/Sema/SemaDeclAttr.cpp | 46 +++++++------------------------ 2 files changed, 10 insertions(+), 44 deletions(-) diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index df97ab51252b7..4beb2f44159e3 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -2420,14 +2420,6 @@ def ReqdWorkGroupSize : InheritableAttr { let Documentation = [Undocumented]; } -def SYCLIntelReqdWorkGroupSize : InheritableAttr { - let Spellings = [CXX11<"intel","reqd_work_group_size">]; - let Args = [IntArgument<"XDim">, DefaultIntArgument<"YDim", 1>, - DefaultIntArgument<"ZDim", 1>]; - let Subjects = SubjectList<[Function], ErrorDiag>; - let Documentation = [Undocumented]; -} - def WorkGroupSizeHint : InheritableAttr { // Does not have a [[]] spelling because it is an OpenCL-related attribute. let Spellings = [GNU<"work_group_size_hint">]; diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 56b9df2789ae5..20cdcd394c8f0 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -2898,15 +2898,7 @@ static bool checkWorkGroupSizeValues(Sema &S, Decl *D, const ParsedAttr &Attr, /*ReverseAttrs=*/true); if (const auto *A = D->getAttr()) { - if (S.getLangOpts().SYCLIsDevice && - !(WGSize[2] <= A->getXDim() && WGSize[1] <= A->getYDim() && - WGSize[0] <= A->getZDim())) { - S.Diag(Attr.getLoc(), diag::err_conflicting_sycl_function_attributes) - << Attr << A->getSpelling(); - Result &= false; - } - if (!S.getLangOpts().SYCLIsDevice && - !(WGSize[0] <= A->getXDim() && WGSize[1] <= A->getYDim() && + if (!(WGSize[0] <= A->getXDim() && WGSize[1] <= A->getYDim() && WGSize[2] <= A->getZDim())) { S.Diag(Attr.getLoc(), diag::err_conflicting_sycl_function_attributes) << Attr << A->getSpelling(); @@ -2914,16 +2906,7 @@ static bool checkWorkGroupSizeValues(Sema &S, Decl *D, const ParsedAttr &Attr, } } if (const auto *A = D->getAttr()) { - - if (S.getLangOpts().SYCLIsDevice && - !(WGSize[2] >= A->getXDim() && WGSize[1] >= A->getYDim() && - WGSize[0] >= A->getZDim())) { - S.Diag(Attr.getLoc(), diag::err_conflicting_sycl_function_attributes) - << Attr << A->getSpelling(); - Result &= false; - } - if (!S.getLangOpts().SYCLIsDevice && - !(WGSize[0] >= A->getXDim() && WGSize[1] >= A->getYDim() && + if (!(WGSize[0] >= A->getXDim() && WGSize[1] >= A->getYDim() && WGSize[2] >= A->getZDim())) { S.Diag(Attr.getLoc(), diag::err_conflicting_sycl_function_attributes) << Attr << A->getSpelling(); @@ -2940,13 +2923,9 @@ static void handleWorkGroupSize(Sema &S, Decl *D, const ParsedAttr &AL) { return; uint32_t WGSize[3]; - if (const auto *A = D->getAttr()){ - WGSize[1] = SYCLIntelReqdWorkGroupSizeAttr::DefaultYDim; - WGSize[2] = SYCLIntelReqdWorkGroupSizeAttr::DefaultZDim; - } for (unsigned i = 0; i < 3; ++i) { const Expr *E = AL.getArgAsExpr(i); - if (i < AL.getNumArgs() && !checkUInt32Argument(S, AL, E, WGSize[i], i, + if (!checkUInt32Argument(S, AL, E, WGSize[i], i, /*StrictlyUnsigned=*/true)) return; if (WGSize[i] == 0) { @@ -2956,25 +2935,20 @@ static void handleWorkGroupSize(Sema &S, Decl *D, const ParsedAttr &AL) { } } + // For a SYCLDevice WorkGroupAttr arguments are reversed + if (S.getLangOpts().SYCLIsDevice) { + std::swap(WGSize[0], WGSize[2]); + } WorkGroupAttr *Existing = D->getAttr(); - if (S.getLangOpts().SYCLIsDevice && Existing && - !(Existing->getXDim() == WGSize[2] && Existing->getYDim() == WGSize[1] && - Existing->getZDim() == WGSize[0])) - S.Diag(AL.getLoc(), diag::warn_duplicate_attribute) << AL; - if (!S.getLangOpts().SYCLIsDevice && Existing && + if (Existing && !(Existing->getXDim() == WGSize[0] && Existing->getYDim() == WGSize[1] && Existing->getZDim() == WGSize[2])) S.Diag(AL.getLoc(), diag::warn_duplicate_attribute) << AL; - if (!checkWorkGroupSizeValues(S, D, AL, WGSize)) return; - if (S.getLangOpts().SYCLIsDevice) - D->addAttr(::new (S.Context) WorkGroupAttr(S.Context, AL, WGSize[2], - WGSize[1], WGSize[0])); - else - D->addAttr(::new (S.Context) WorkGroupAttr(S.Context, AL, WGSize[0], - WGSize[1], WGSize[2])); + D->addAttr(::new (S.Context) + WorkGroupAttr(S.Context, AL, WGSize[0], WGSize[1], WGSize[2])); } // Handles intel_reqd_sub_group_size. From abe6d2d3213eaa173c6fde03aceb44b769c35dd9 Mon Sep 17 00:00:00 2001 From: Aleksander Fadeev Date: Tue, 10 Mar 2020 13:21:39 +0300 Subject: [PATCH 16/16] [SYCL] reqd_work_group_size attribute is reversed (fix #15) Signed-off-by: Aleksander Fadeev --- clang/include/clang/Basic/Attr.td | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index 4beb2f44159e3..fc8d392e3937a 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -1147,7 +1147,7 @@ def SYCLIntelKernelArgsRestrict : InheritableAttr { def SYCLIntelNumSimdWorkItems : InheritableAttr { let Spellings = [CXX11<"intelfpga","num_simd_work_items">]; - let Args = [IntArgument<"Number">]; + let Args = [UnsignedArgument<"Number">]; let LangOpts = [SYCLIsDevice, SYCLIsHost]; let Subjects = SubjectList<[Function], ErrorDiag>; let Documentation = [SYCLIntelNumSimdWorkItemsAttrDocs];