|
| 1 | +// RUN: %clang_cc1 -fsycl -fsycl-is-device -fsyntax-only -verify -DTRIGGER_ERROR %s |
| 2 | +// RUN: %clang_cc1 -fsycl -fsycl-is-device -ast-dump %s | FileCheck %s |
| 3 | +// RUN: %clang_cc1 -fsycl -fsycl-is-host -fsyntax-only -verify %s |
| 4 | + |
| 5 | +#ifndef __SYCL_DEVICE_ONLY__ |
| 6 | +// expected-no-diagnostics |
| 7 | +class Functor { |
| 8 | +public: |
| 9 | + [[intel::reqd_work_group_size(4)]] void operator()() {} |
| 10 | +}; |
| 11 | + |
| 12 | +template <typename name, typename Func> |
| 13 | +void kernel(Func kernelFunc) { |
| 14 | + kernelFunc(); |
| 15 | +} |
| 16 | + |
| 17 | +void bar() { |
| 18 | + Functor f; |
| 19 | + kernel<class kernel_name>(f); |
| 20 | +} |
| 21 | +#else |
| 22 | +[[intel::reqd_work_group_size(4)]] void f4x1x1() {} // expected-note {{conflicting attribute is here}} |
| 23 | +// expected-note@-1 {{conflicting attribute is here}} |
| 24 | +[[intel::reqd_work_group_size(32)]] void f32x1x1() {} // expected-note {{conflicting attribute is here}} |
| 25 | + |
| 26 | +[[intel::reqd_work_group_size(16)]] void f16x1x1() {} // expected-note {{conflicting attribute is here}} |
| 27 | +[[intel::reqd_work_group_size(16, 16)]] void f16x16x1() {} // expected-note {{conflicting attribute is here}} |
| 28 | + |
| 29 | +[[intel::reqd_work_group_size(32, 32)]] void f32x32x1() {} // expected-note {{conflicting attribute is here}} |
| 30 | +[[intel::reqd_work_group_size(32, 32, 32)]] void f32x32x32() {} // expected-note {{conflicting attribute is here}} |
| 31 | + |
| 32 | +#ifdef TRIGGER_ERROR |
| 33 | +class Functor32 { |
| 34 | +public: |
| 35 | + [[cl::reqd_work_group_size(32)]] void operator()() {} // expected-error {{'reqd_work_group_size' attribute requires exactly 3 arguments}} |
| 36 | +}; |
| 37 | +class Functor33 { |
| 38 | +public: |
| 39 | + [[intel::reqd_work_group_size(32, -4)]] void operator()() {} // expected-error {{'reqd_work_group_size' attribute requires a non-negative integral compile time constant expression}} |
| 40 | +}; |
| 41 | +#endif // TRIGGER_ERROR |
| 42 | + |
| 43 | +class Functor16 { |
| 44 | +public: |
| 45 | + [[intel::reqd_work_group_size(16)]] void operator()() {} |
| 46 | +}; |
| 47 | + |
| 48 | +class Functor64 { |
| 49 | +public: |
| 50 | + [[intel::reqd_work_group_size(64, 64)]] void operator()() {} |
| 51 | +}; |
| 52 | + |
| 53 | +class Functor16x16x16 { |
| 54 | +public: |
| 55 | + [[intel::reqd_work_group_size(16, 16, 16)]] void operator()() {} |
| 56 | +}; |
| 57 | + |
| 58 | +class Functor8 { // expected-error {{conflicting attributes applied to a SYCL kernel}} |
| 59 | +public: |
| 60 | + [[intel::reqd_work_group_size(8)]] void operator()() { // expected-note {{conflicting attribute is here}} |
| 61 | + f4x1x1(); |
| 62 | + } |
| 63 | +}; |
| 64 | + |
| 65 | +class Functor { |
| 66 | +public: |
| 67 | + void operator()() { |
| 68 | + f4x1x1(); |
| 69 | + } |
| 70 | +}; |
| 71 | + |
| 72 | +class FunctorAttr { |
| 73 | +public: |
| 74 | + __attribute__((reqd_work_group_size(128, 128, 128))) void operator()() {} |
| 75 | +}; |
| 76 | + |
| 77 | +template <typename name, typename Func> |
| 78 | +__attribute__((sycl_kernel)) void kernel(Func kernelFunc) { |
| 79 | + kernelFunc(); |
| 80 | +} |
| 81 | + |
| 82 | +void bar() { |
| 83 | + Functor16 f16; |
| 84 | + kernel<class kernel_name1>(f16); |
| 85 | + |
| 86 | + Functor f; |
| 87 | + kernel<class kernel_name2>(f); |
| 88 | + |
| 89 | + Functor16x16x16 f16x16x16; |
| 90 | + kernel<class kernel_name3>(f16x16x16); |
| 91 | + |
| 92 | + FunctorAttr fattr; |
| 93 | + kernel<class kernel_name4>(fattr); |
| 94 | + |
| 95 | + kernel<class kernel_name5>([]() [[intel::reqd_work_group_size(32, 32, 32)]] { |
| 96 | + f32x32x32(); |
| 97 | + }); |
| 98 | + |
| 99 | +#ifdef TRIGGER_ERROR |
| 100 | + Functor8 f8; |
| 101 | + kernel<class kernel_name6>(f8); |
| 102 | + |
| 103 | + kernel<class kernel_name7>([]() { // expected-error {{conflicting attributes applied to a SYCL kernel}} |
| 104 | + f4x1x1(); |
| 105 | + f32x1x1(); |
| 106 | + }); |
| 107 | + |
| 108 | + kernel<class kernel_name8>([]() { // expected-error {{conflicting attributes applied to a SYCL kernel}} |
| 109 | + f16x1x1(); |
| 110 | + f16x16x1(); |
| 111 | + }); |
| 112 | + |
| 113 | + kernel<class kernel_name9>([]() { // expected-error {{conflicting attributes applied to a SYCL kernel}} |
| 114 | + f32x32x32(); |
| 115 | + f32x32x1(); |
| 116 | + }); |
| 117 | + |
| 118 | + // expected-error@+1 {{expected variable name or 'this' in lambda capture list}} |
| 119 | + kernel<class kernel_name10>([[intel::reqd_work_group_size(32, 32, 32)]][]() { |
| 120 | + f32x32x32(); |
| 121 | + }); |
| 122 | + |
| 123 | +#endif // TRIGGER_ERROR |
| 124 | +} |
| 125 | + |
| 126 | +// CHECK: FunctionDecl {{.*}} {{.*}}kernel_name1 |
| 127 | +// CHECK: ReqdWorkGroupSizeAttr {{.*}} 1 1 16 |
| 128 | +// CHECK: FunctionDecl {{.*}} {{.*}}kernel_name2 |
| 129 | +// CHECK: ReqdWorkGroupSizeAttr {{.*}} 1 1 4 |
| 130 | +// CHECK: FunctionDecl {{.*}} {{.*}}kernel_name3 |
| 131 | +// CHECK: ReqdWorkGroupSizeAttr {{.*}} 16 16 16 |
| 132 | +// CHECK: FunctionDecl {{.*}} {{.*}}kernel_name4 |
| 133 | +// CHECK: ReqdWorkGroupSizeAttr {{.*}} 128 128 128 |
| 134 | +// CHECK: FunctionDecl {{.*}} {{.*}}kernel_name5 |
| 135 | +// CHECK: ReqdWorkGroupSizeAttr {{.*}} 32 32 32 |
| 136 | +#endif // __SYCL_DEVICE_ONLY__ |
0 commit comments