diff --git a/clang/test/CodeGenSYCL/intel-max-global-work-dim.cpp b/clang/test/CodeGenSYCL/intel-max-global-work-dim.cpp index 35f0e4d19cf11..e9e380455fe84 100644 --- a/clang/test/CodeGenSYCL/intel-max-global-work-dim.cpp +++ b/clang/test/CodeGenSYCL/intel-max-global-work-dim.cpp @@ -16,6 +16,9 @@ class Functor { [[intel::max_global_work_dim(SIZE)]] void operator()() const {} }; +template +[[intel::max_global_work_dim(N)]] void func() {} + int main() { q.submit([&](handler &h) { Foo boo; @@ -26,6 +29,10 @@ int main() { Functor<2> f; h.single_task(f); + + h.single_task([]() { + func<2>(); + }); }); return 0; } @@ -33,5 +40,6 @@ int main() { // CHECK: define {{.*}}spir_kernel void @{{.*}}kernel_name1"() #0 {{.*}} !max_global_work_dim ![[NUM1:[0-9]+]] // CHECK: define {{.*}}spir_kernel void @{{.*}}kernel_name2"() #0 {{.*}} !max_global_work_dim ![[NUM2:[0-9]+]] // CHECK: define {{.*}}spir_kernel void @{{.*}}kernel_name3"() #0 {{.*}} !max_global_work_dim ![[NUM2]] +// CHECK: define {{.*}}spir_kernel void @{{.*}}kernel_name4"() #0 {{.*}} !max_global_work_dim ![[NUM2]] // CHECK: ![[NUM1]] = !{i32 1} // CHECK: ![[NUM2]] = !{i32 2} diff --git a/clang/test/CodeGenSYCL/num-simd-work-items.cpp b/clang/test/CodeGenSYCL/num-simd-work-items.cpp index 4620ead8b7896..7a5f3892171fd 100644 --- a/clang/test/CodeGenSYCL/num-simd-work-items.cpp +++ b/clang/test/CodeGenSYCL/num-simd-work-items.cpp @@ -16,6 +16,9 @@ class Functor { [[intel::num_simd_work_items(SIZE)]] void operator()() const {} }; +template +[[intel::num_simd_work_items(N)]] void func() {} + int main() { q.submit([&](handler &h) { Foo boo; @@ -26,6 +29,10 @@ int main() { Functor<2> f; h.single_task(f); + + h.single_task([]() { + func<4>(); + }); }); return 0; } @@ -33,6 +40,8 @@ int main() { // CHECK: define {{.*}}spir_kernel void @{{.*}}kernel_name1"() #0 {{.*}} !num_simd_work_items ![[NUM1:[0-9]+]] // CHECK: define {{.*}}spir_kernel void @{{.*}}kernel_name2"() #0 {{.*}} !num_simd_work_items ![[NUM42:[0-9]+]] // CHECK: define {{.*}}spir_kernel void @{{.*}}kernel_name3"() #0 {{.*}} !num_simd_work_items ![[NUM2:[0-9]+]] +// CHECK: define {{.*}}spir_kernel void @{{.*}}kernel_name4"() #0 {{.*}} !num_simd_work_items ![[NUM4:[0-9]+]] // CHECK: ![[NUM1]] = !{i32 1} // CHECK: ![[NUM42]] = !{i32 42} // CHECK: ![[NUM2]] = !{i32 2} +// CHECK: ![[NUM4]] = !{i32 4} diff --git a/clang/test/CodeGenSYCL/reqd-sub-group-size.cpp b/clang/test/CodeGenSYCL/reqd-sub-group-size.cpp index 2bd724421a84e..8325beb99e8f3 100644 --- a/clang/test/CodeGenSYCL/reqd-sub-group-size.cpp +++ b/clang/test/CodeGenSYCL/reqd-sub-group-size.cpp @@ -25,6 +25,9 @@ class Functor2 { [[intel::reqd_sub_group_size(SIZE)]] void operator()() const {} }; +template +[[intel::reqd_sub_group_size(N)]] void func() {} + int main() { q.submit([&](handler &h) { Functor16 f16; @@ -38,6 +41,10 @@ int main() { Functor2<2> f2; h.single_task(f2); + + h.single_task([]() { + func<2>(); + }); }); return 0; } @@ -46,6 +53,7 @@ int main() { // CHECK: define {{.*}}spir_kernel void @{{.*}}kernel_name2"() #0 {{.*}} !intel_reqd_sub_group_size ![[SGSIZE8:[0-9]+]] // CHECK: define {{.*}}spir_kernel void @{{.*}}kernel_name3"() #0 {{.*}} !intel_reqd_sub_group_size ![[SGSIZE4:[0-9]+]] // CHECK: define {{.*}}spir_kernel void @{{.*}}kernel_name4"() #0 {{.*}} !intel_reqd_sub_group_size ![[SGSIZE2:[0-9]+]] +// CHECK: define {{.*}}spir_kernel void @{{.*}}kernel_name5"() #0 {{.*}} !intel_reqd_sub_group_size ![[SGSIZE2]] // CHECK: ![[SGSIZE16]] = !{i32 16} // CHECK: ![[SGSIZE8]] = !{i32 8} // CHECK: ![[SGSIZE4]] = !{i32 4} diff --git a/clang/test/SemaSYCL/sycl-device-intel-max-global-work-dim-template.cpp b/clang/test/SemaSYCL/sycl-device-intel-max-global-work-dim-template.cpp index 9b8600f99a76d..ce49d6344897c 100644 --- a/clang/test/SemaSYCL/sycl-device-intel-max-global-work-dim-template.cpp +++ b/clang/test/SemaSYCL/sycl-device-intel-max-global-work-dim-template.cpp @@ -2,6 +2,32 @@ // Test that checkes template parameter support for 'max_global_work_dim' attribute on sycl device. +// Test that checks wrong function template instantiation and ensures that the type +// is checked properly when instantiating from the template definition. +template +// expected-error@+1 2{{'max_global_work_dim' attribute requires an integer constant}} +[[intel::max_global_work_dim(Ty{})]] void func() {} + +struct S {}; +void test() { + //expected-note@+1{{in instantiation of function template specialization 'func' requested here}} + func(); + //expected-note@+1{{in instantiation of function template specialization 'func' requested here}} + func(); + // no error expected + func(); // OK +} + +// Test that checks expression is not a constant expression. +int foo(); +// expected-error@+1{{'max_global_work_dim' attribute requires an integer constant}} +[[intel::max_global_work_dim(foo() + 1)]] void func1(); + +// Test that checks expression is a constant expression. +constexpr int bar() { return 0; } +[[intel::max_global_work_dim(bar() + 2)]] void func2(); // OK + +// Test that checks template parameter support on member function of class template. template class KernelFunctor { public: @@ -23,3 +49,24 @@ int main() { // CHECK: SubstNonTypeTemplateParmExpr {{.*}} // CHECK-NEXT: NonTypeTemplateParmDecl {{.*}} // CHECK-NEXT: IntegerLiteral{{.*}}2{{$}} + +// Test that checks template parameter support on function. +template +// expected-error@+1{{'max_global_work_dim' attribute requires a non-negative integral compile time constant expression}} +[[intel::max_global_work_dim(N)]] void func3() {} + +int check() { + // no error expected + func3<2>(); + //expected-note@+1{{in instantiation of function template specialization 'func3<-1>' requested here}} + func3<-1>(); + return 0; +} + +// CHECK: FunctionTemplateDecl {{.*}} {{.*}} func3 +// CHECK: NonTypeTemplateParmDecl {{.*}} {{.*}} referenced 'int' depth 0 index 0 N +// CHECK: FunctionDecl {{.*}} {{.*}} func3 'void ()' +// CHECK: SYCLIntelMaxGlobalWorkDimAttr {{.*}} +// CHECK: SubstNonTypeTemplateParmExpr {{.*}} +// CHECK-NEXT: NonTypeTemplateParmDecl {{.*}} +// CHECK-NEXT: IntegerLiteral{{.*}}2{{$}} diff --git a/clang/test/SemaSYCL/sycl-device-intel-max-work-group-size-template.cpp b/clang/test/SemaSYCL/sycl-device-intel-max-work-group-size-template.cpp index c5dac7f8ec637..262f04041492e 100644 --- a/clang/test/SemaSYCL/sycl-device-intel-max-work-group-size-template.cpp +++ b/clang/test/SemaSYCL/sycl-device-intel-max-work-group-size-template.cpp @@ -24,7 +24,7 @@ int foo(); constexpr int bar() { return 0; } [[intel::max_work_group_size(bar() + 12, bar() + 12, bar() + 12)]] void func2(); // OK -// Test that checks template parameter suppport on member function of class template. +// Test that checks template parameter support on member function of class template. template class KernelFunctor { public: diff --git a/clang/test/SemaSYCL/sycl-device-intel-reqd-work-group-size-template.cpp b/clang/test/SemaSYCL/sycl-device-intel-reqd-work-group-size-template.cpp index 32e07f7a2b3ee..a964dc1860ac5 100644 --- a/clang/test/SemaSYCL/sycl-device-intel-reqd-work-group-size-template.cpp +++ b/clang/test/SemaSYCL/sycl-device-intel-reqd-work-group-size-template.cpp @@ -24,7 +24,7 @@ int foo(); constexpr int bar() { return 0; } [[intel::reqd_work_group_size(bar() + 12, bar() + 12, bar() + 12)]] void func2(); // OK -// Test that checks template parameter suppport on member function of class template. +// Test that checks template parameter support on member function of class template. template class KernelFunctor { public: diff --git a/clang/test/SemaSYCL/sycl-device-num_simd_work_items-template.cpp b/clang/test/SemaSYCL/sycl-device-num_simd_work_items-template.cpp index 4f4f9286b5d72..f29d050d4b49e 100644 --- a/clang/test/SemaSYCL/sycl-device-num_simd_work_items-template.cpp +++ b/clang/test/SemaSYCL/sycl-device-num_simd_work_items-template.cpp @@ -2,6 +2,33 @@ // Test that checkes template parameter support for 'num_simd_work_items' attribute on sycl device. +// Test that checks wrong function template instantiation and ensures that the type +// is checked properly when instantiating from the template definition. +template +// expected-error@+2{{'num_simd_work_items' attribute requires a positive integral compile time constant expression}} +// expected-error@+1 2{{'num_simd_work_items' attribute requires an integer constant}} +[[intel::num_simd_work_items(Ty{})]] void func() {} + +struct S {}; +void test() { + //expected-note@+1{{in instantiation of function template specialization 'func' requested here}} + func(); + //expected-note@+1{{in instantiation of function template specialization 'func' requested here}} + func(); + //expected-note@+1{{in instantiation of function template specialization 'func' requested here}} + func(); +} + +// Test that checks expression is not a constant expression. +int foo(); +// expected-error@+1{{'num_simd_work_items' attribute requires an integer constant}} +[[intel::num_simd_work_items(foo() + 12)]] void func1(); + +// Test that checks expression is a constant expression. +constexpr int bar() { return 0; } +[[intel::num_simd_work_items(bar() + 12)]] void func2(); // OK + +// Test that checks template parameter support on member function of class template. template class KernelFunctor { public: @@ -14,6 +41,7 @@ int main() { KernelFunctor<-1>(); // no error expected KernelFunctor<10>(); + return 0; } // CHECK: ClassTemplateDecl {{.*}} {{.*}} KernelFunctor @@ -23,3 +51,24 @@ int main() { // CHECK: SubstNonTypeTemplateParmExpr {{.*}} // CHECK-NEXT: NonTypeTemplateParmDecl {{.*}} // CHECK-NEXT: IntegerLiteral{{.*}}10{{$}} + +// Test that checks template parameter support on function. +template +// expected-error@+1{{'num_simd_work_items' attribute requires a positive integral compile time constant expression}} +[[intel::num_simd_work_items(N)]] void func3() {} + +int check() { + // no error expected + func3<8>(); + //expected-note@+1{{in instantiation of function template specialization 'func3<-1>' requested here}} + func3<-1>(); + return 0; +} + +// CHECK: FunctionTemplateDecl {{.*}} {{.*}} func3 +// CHECK: NonTypeTemplateParmDecl {{.*}} {{.*}} referenced 'int' depth 0 index 0 N +// CHECK: FunctionDecl {{.*}} {{.*}} func3 'void ()' +// CHECK: SYCLIntelNumSimdWorkItemsAttr {{.*}} +// CHECK: SubstNonTypeTemplateParmExpr {{.*}} +// CHECK-NEXT: NonTypeTemplateParmDecl {{.*}} +// CHECK-NEXT: IntegerLiteral{{.*}}8{{$}} diff --git a/clang/test/SemaSYCL/sycl-device-reqd-sub-group-size-template.cpp b/clang/test/SemaSYCL/sycl-device-reqd-sub-group-size-template.cpp index 4c4a376cf4591..ae41e6bead1dc 100644 --- a/clang/test/SemaSYCL/sycl-device-reqd-sub-group-size-template.cpp +++ b/clang/test/SemaSYCL/sycl-device-reqd-sub-group-size-template.cpp @@ -2,6 +2,33 @@ // Test that checkes template parameter support for 'reqd_sub_group_size' attribute on sycl device. +// Test that checks wrong function template instantiation and ensures that the type +// is checked properly when instantiating from the template definition. +template +// expected-error@+2{{'reqd_sub_group_size' attribute requires a positive integral compile time constant expression}} +// expected-error@+1 2{{'reqd_sub_group_size' attribute requires an integer constant}} +[[intel::reqd_sub_group_size(Ty{})]] void func() {} + +struct S {}; +void test() { + //expected-note@+1{{in instantiation of function template specialization 'func' requested here}} + func(); + //expected-note@+1{{in instantiation of function template specialization 'func' requested here}} + func(); + //expected-note@+1{{in instantiation of function template specialization 'func' requested here}} + func(); +} + +// Test that checks expression is not a constant expression. +int foo(); +// expected-error@+1{{'reqd_sub_group_size' attribute requires an integer constant}} +[[intel::reqd_sub_group_size(foo() + 12)]] void func1(); + +// Test that checks expression is a constant expression. +constexpr int bar() { return 0; } +[[intel::reqd_sub_group_size(bar() + 12)]] void func2(); // OK + +// Test that checks template parameter support on member function of class template. template class KernelFunctor { public: @@ -14,6 +41,7 @@ int main() { KernelFunctor<-1>(); // no error expected KernelFunctor<10>(); + return 0; } // CHECK: ClassTemplateDecl {{.*}} {{.*}} KernelFunctor @@ -23,3 +51,24 @@ int main() { // CHECK: SubstNonTypeTemplateParmExpr {{.*}} // CHECK-NEXT: NonTypeTemplateParmDecl {{.*}} // CHECK-NEXT: IntegerLiteral{{.*}}10{{$}} + +// Test that checks template parameter support on function. +template +// expected-error@+1{{'reqd_sub_group_size' attribute requires a positive integral compile time constant expression}} +[[intel::reqd_sub_group_size(N)]] void func3() {} + +int check() { + // no error expected + func3<12>(); + //expected-note@+1{{in instantiation of function template specialization 'func3<-1>' requested here}} + func3<-1>(); + return 0; +} + +// CHECK: FunctionTemplateDecl {{.*}} {{.*}} func3 +// CHECK: NonTypeTemplateParmDecl {{.*}} {{.*}} referenced 'int' depth 0 index 0 N +// CHECK: FunctionDecl {{.*}} {{.*}} func3 'void ()' +// CHECK: IntelReqdSubGroupSizeAttr {{.*}} +// CHECK: SubstNonTypeTemplateParmExpr {{.*}} +// CHECK-NEXT: NonTypeTemplateParmDecl {{.*}} +// CHECK-NEXT: IntegerLiteral{{.*}}12{{$}} diff --git a/clang/test/SemaSYCL/sycl-device-reqd-work-group-size-template.cpp b/clang/test/SemaSYCL/sycl-device-reqd-work-group-size-template.cpp index 364dc7a8d9e40..0cfe7e4efc8bc 100644 --- a/clang/test/SemaSYCL/sycl-device-reqd-work-group-size-template.cpp +++ b/clang/test/SemaSYCL/sycl-device-reqd-work-group-size-template.cpp @@ -24,7 +24,7 @@ int foo(); constexpr int bar() { return 0; } [[cl::reqd_work_group_size(bar() + 12, bar() + 12, bar() + 12)]] void func2(); // OK -// Test that checks template parameter suppport on member function of class template. +// Test that checks template parameter support on member function of class template. template class KernelFunctor { public: