@@ -18,6 +18,10 @@ class MyUInt32Const;
18
18
class MyFloatConst ;
19
19
class MyDoubleConst ;
20
20
21
+ namespace test {
22
+ class MySpecConstantWithinANamespace ;
23
+ };
24
+
21
25
int main () {
22
26
// Create specialization constants.
23
27
cl::sycl::ONEAPI::experimental::spec_constant<bool , MyBoolConst> i1 (false );
@@ -32,13 +36,31 @@ int main() {
32
36
cl::sycl::ONEAPI::experimental::spec_constant<unsigned int , MyUInt32Const> ui32 (0 );
33
37
cl::sycl::ONEAPI::experimental::spec_constant<float , MyFloatConst> f32 (0 );
34
38
cl::sycl::ONEAPI::experimental::spec_constant<double , MyDoubleConst> f64 (0 );
39
+ // Kernel name can be used as a spec constant name
40
+ cl::sycl::ONEAPI::experimental::spec_constant<int , SpecializedKernel> spec1 (0 );
41
+ // Spec constant name can be declared within a namespace
42
+ cl::sycl::ONEAPI::experimental::spec_constant<int , test::MySpecConstantWithinANamespace> spec2 (0 );
35
43
36
44
double val;
37
45
double *ptr = &val; // to avoid "unused" warnings
38
46
47
+ // CHECK: // Forward declarations of templated spec constant types:
48
+ // CHECK: class MyInt8Const;
49
+ // CHECK: class MyUInt8Const;
50
+ // CHECK: class MyInt16Const;
51
+ // CHECK: class MyUInt16Const;
52
+ // CHECK: class MyInt32Const;
53
+ // CHECK: class MyUInt32Const;
54
+ // CHECK: class MyFloatConst;
55
+ // CHECK: class MyDoubleConst;
56
+ // CHECK: class SpecializedKernel;
57
+ // CHECK: namespace test {
58
+ // CHECK: class MySpecConstantWithinANamespace;
59
+ // CHECK: }
60
+
39
61
cl::sycl::kernel_single_task<SpecializedKernel>([=]() {
40
62
*ptr = i1.get () +
41
- // CHECK-DAG: template <> struct sycl::detail::SpecConstantInfo<class MyBoolConst> {
63
+ // CHECK-DAG: template <> struct sycl::detail::SpecConstantInfo<:: MyBoolConst> {
42
64
// CHECK-DAG-NEXT: static constexpr const char* getName() {
43
65
// CHECK-DAG-NEXT: return "_ZTS11MyBoolConst";
44
66
// CHECK-DAG-NEXT: }
@@ -58,7 +80,11 @@ int main() {
58
80
// CHECK-DAG: return "_ZTS13MyUInt32Const";
59
81
f32 .get () +
60
82
// CHECK-DAG: return "_ZTS12MyFloatConst";
61
- f64 .get ();
62
- // CHECK-DAG: return "_ZTS13MyDoubleConst";
83
+ f64 .get () +
84
+ // CHECK-DAG: return "_ZTS13MyDoubleConst";
85
+ spec1.get () +
86
+ // CHECK-DAG: return "_ZTS17SpecializedKernel"
87
+ spec2.get ();
88
+ // CHECK-DAG: return "_ZTSN4test30MySpecConstantWithinANamespaceE"
63
89
});
64
90
}
0 commit comments