Skip to content

Commit 9d5b4b8

Browse files
[SYCL][clang] Add attr/props warning case for multiple attributes (#20652)
This commit adds new cases to the existing tests for checking the warning issued when there may be potential conflicts between SYCL attributes and compile-time properties. These tests check that multiple warning diagnostics are issued if there are multiple attributes on the same kernel, each specifying the potentially conflicting attribute. --------- Signed-off-by: Larsen, Steffen <[email protected]>
1 parent 74ffed8 commit 9d5b4b8

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

clang/test/SemaSYCL/attr-add-ir-attributes-function-conflict.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ int main() {
112112
NonemptyWrapper.kernel_single_task<class NEK9>([]() [[sycl::device_has(sycl::aspect::cpu)]] {});
113113
// expected-warning@+1 {{kernel has both attribute 'sycl::device_has' and kernel properties; conflicting properties are ignored}}
114114
NonemptyWrapper.kernel_single_task<class NEK10>([]() [[sycl::device_has(sycl::aspect::cpu, sycl::aspect::gpu)]] {});
115+
// expected-warning@+4 {{kernel has both attribute 'sycl::reqd_work_group_size' and kernel properties; conflicting properties are ignored}}
116+
// expected-warning@+3 {{kernel has both attribute 'sycl::work_group_size_hint' and kernel properties; conflicting properties are ignored}}
117+
// expected-warning@+2 {{kernel has both attribute 'sycl::reqd_sub_group_size' and kernel properties; conflicting properties are ignored}}
118+
// expected-warning@+1 {{kernel has both attribute 'sycl::device_has' and kernel properties; conflicting properties are ignored}}
119+
NonemptyWrapper.kernel_single_task<class NEK11>([]() [[sycl::reqd_work_group_size(1)]] [[sycl::work_group_size_hint(1)]] [[sycl::reqd_sub_group_size(1)]] [[sycl::device_has(sycl::aspect::cpu, sycl::aspect::gpu)]] {});
115120

116121
// expected-warning@+1 {{kernel has both attribute 'sycl::reqd_work_group_size' and kernel properties; conflicting properties are ignored}}
117122
NonemptyWrapperWithImplicit.kernel_single_task<class NEKWI1>([]() [[sycl::reqd_work_group_size(1)]] {});
@@ -133,6 +138,11 @@ int main() {
133138
NonemptyWrapperWithImplicit.kernel_single_task<class NEKWI9>([]() [[sycl::device_has(sycl::aspect::cpu)]] {});
134139
// expected-warning@+1 {{kernel has both attribute 'sycl::device_has' and kernel properties; conflicting properties are ignored}}
135140
NonemptyWrapperWithImplicit.kernel_single_task<class NEKWI10>([]() [[sycl::device_has(sycl::aspect::cpu, sycl::aspect::gpu)]] {});
141+
// expected-warning@+4 {{kernel has both attribute 'sycl::reqd_work_group_size' and kernel properties; conflicting properties are ignored}}
142+
// expected-warning@+3 {{kernel has both attribute 'sycl::work_group_size_hint' and kernel properties; conflicting properties are ignored}}
143+
// expected-warning@+2 {{kernel has both attribute 'sycl::reqd_sub_group_size' and kernel properties; conflicting properties are ignored}}
144+
// expected-warning@+1 {{kernel has both attribute 'sycl::device_has' and kernel properties; conflicting properties are ignored}}
145+
NonemptyWrapperWithImplicit.kernel_single_task<class NEKWI11>([]() [[sycl::reqd_work_group_size(1)]] [[sycl::work_group_size_hint(1)]] [[sycl::reqd_sub_group_size(1)]] [[sycl::device_has(sycl::aspect::cpu, sycl::aspect::gpu)]] {});
136146

137147
// expected-warning@+1 {{kernel has both attribute 'sycl::reqd_work_group_size' and kernel properties; conflicting properties are ignored}}
138148
NonemptyWrapperWithFilter.kernel_single_task<class NEKWF1>([]() [[sycl::reqd_work_group_size(1)]] {});
@@ -154,6 +164,11 @@ int main() {
154164
NonemptyWrapperWithFilter.kernel_single_task<class NEKWF9>([]() [[sycl::device_has(sycl::aspect::cpu)]] {});
155165
// expected-warning@+1 {{kernel has both attribute 'sycl::device_has' and kernel properties; conflicting properties are ignored}}
156166
NonemptyWrapperWithFilter.kernel_single_task<class NEKWF10>([]() [[sycl::device_has(sycl::aspect::cpu, sycl::aspect::gpu)]] {});
167+
// expected-warning@+4 {{kernel has both attribute 'sycl::reqd_work_group_size' and kernel properties; conflicting properties are ignored}}
168+
// expected-warning@+3 {{kernel has both attribute 'sycl::work_group_size_hint' and kernel properties; conflicting properties are ignored}}
169+
// expected-warning@+2 {{kernel has both attribute 'sycl::reqd_sub_group_size' and kernel properties; conflicting properties are ignored}}
170+
// expected-warning@+1 {{kernel has both attribute 'sycl::device_has' and kernel properties; conflicting properties are ignored}}
171+
NonemptyWrapperWithFilter.kernel_single_task<class NEKWF11>([]() [[sycl::reqd_work_group_size(1)]] [[sycl::work_group_size_hint(1)]] [[sycl::reqd_sub_group_size(1)]] [[sycl::device_has(sycl::aspect::cpu, sycl::aspect::gpu)]] {});
157172

158173
// expected-warning@+1 {{kernel has both attribute 'sycl::reqd_work_group_size' and kernel properties; conflicting properties are ignored}}
159174
NonemptyWrapperWithImplicitAndFilter.kernel_single_task<class NEKWIF1>([]() [[sycl::reqd_work_group_size(1)]] {});
@@ -175,4 +190,9 @@ int main() {
175190
NonemptyWrapperWithImplicitAndFilter.kernel_single_task<class NEKWIF9>([]() [[sycl::device_has(sycl::aspect::cpu)]] {});
176191
// expected-warning@+1 {{kernel has both attribute 'sycl::device_has' and kernel properties; conflicting properties are ignored}}
177192
NonemptyWrapperWithImplicitAndFilter.kernel_single_task<class NEKWIF10>([]() [[sycl::device_has(sycl::aspect::cpu, sycl::aspect::gpu)]] {});
193+
// expected-warning@+4 {{kernel has both attribute 'sycl::reqd_work_group_size' and kernel properties; conflicting properties are ignored}}
194+
// expected-warning@+3 {{kernel has both attribute 'sycl::work_group_size_hint' and kernel properties; conflicting properties are ignored}}
195+
// expected-warning@+2 {{kernel has both attribute 'sycl::reqd_sub_group_size' and kernel properties; conflicting properties are ignored}}
196+
// expected-warning@+1 {{kernel has both attribute 'sycl::device_has' and kernel properties; conflicting properties are ignored}}
197+
NonemptyWrapperWithImplicitAndFilter.kernel_single_task<class NEKWIF11>([]() [[sycl::reqd_work_group_size(1)]] [[sycl::work_group_size_hint(1)]] [[sycl::reqd_sub_group_size(1)]] [[sycl::device_has(sycl::aspect::cpu, sycl::aspect::gpu)]] {});
178198
}

sycl/test/extensions/properties/properties_kernel_negative_device.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,21 @@ template <sycl::aspect Aspect> struct KernelFunctorWithDeviceHasWithAttr {
3838
}
3939
};
4040

41+
template <sycl::aspect Aspect> struct KernelFunctorWithAllAttrs {
42+
// expected-warning@+4 {{kernel has both attribute 'sycl::reqd_work_group_size' and kernel properties; conflicting properties are ignored}}
43+
// expected-warning@+4 {{kernel has both attribute 'sycl::work_group_size_hint' and kernel properties; conflicting properties are ignored}}
44+
// expected-warning@+4 {{kernel has both attribute 'sycl::reqd_sub_group_size' and kernel properties; conflicting properties are ignored}}
45+
// expected-warning@+4 {{kernel has both attribute 'sycl::device_has' and kernel properties; conflicting properties are ignored}}
46+
void operator() [[sycl::reqd_work_group_size(
47+
32)]] [[sycl::
48+
work_group_size_hint(32)]] [[sycl::reqd_sub_group_size(
49+
32)]] [[sycl::device_has(sycl::aspect::cpu)]] () const {}
50+
auto get(sycl::ext::oneapi::experimental::properties_tag) const {
51+
return sycl::ext::oneapi::experimental::properties{
52+
sycl::ext::oneapi::experimental::device_has<Aspect>};
53+
}
54+
};
55+
4156
void check_work_group_size() {
4257
sycl::queue Q;
4358

@@ -62,10 +77,17 @@ void check_device_has() {
6277
Q.single_task(KernelFunctorWithDeviceHasWithAttr<sycl::aspect::cpu>{});
6378
}
6479

80+
void check_all() {
81+
sycl::queue Q;
82+
83+
Q.single_task(KernelFunctorWithAllAttrs<sycl::aspect::cpu>{});
84+
}
85+
6586
int main() {
6687
check_work_group_size();
6788
check_work_group_size_hint();
6889
check_sub_group_size();
6990
check_device_has();
91+
check_all();
7092
return 0;
7193
}

0 commit comments

Comments
 (0)