1
- // XFAIL: cuda || level_zero
2
- // CUDA exposes broken hierarchical parallelism.
1
+ // XFAIL: level_zero
2
+ // UNSUPPORTED: windows
3
+ // Level0 testing times out on Windows.
3
4
4
5
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
5
6
// RUN: %CPU_RUN_PLACEHOLDER %t.out
@@ -29,106 +30,111 @@ int main() {
29
30
string_class DeviceVendorName = D.get_info <info::device::vendor>();
30
31
auto DeviceType = D.get_info <info::device::device_type>();
31
32
32
- // parallel_for, (16, 16, 16) global, (8, 8, 8) local, reqd_wg_size(4, 4, 4)
33
- // -> fail
34
- try {
35
- Q.submit ([&](handler &CGH) {
36
- CGH.parallel_for <class ReqdWGSizeNegativeA >(
37
- nd_range<3 >(range<3 >(16 , 16 , 16 ), range<3 >(8 , 8 , 8 )),
38
- [=](nd_item<3 >) { reqd_wg_size_helper (); });
39
- });
40
- Q.wait_and_throw ();
41
- std::cerr << " Test case ReqdWGSizeNegativeA failed: no exception has been "
42
- " thrown\n " ;
43
- return 1 ; // We shouldn't be here, exception is expected
44
- } catch (nd_range_error &E) {
45
- if (string_class (E.what ()).find (
46
- " Specified local size doesn't match the required work-group size "
47
- " specified in the program source" ) == string_class::npos) {
48
- std::cerr
49
- << " Test case ReqdWGSizeNegativeA failed: unexpected exception: "
50
- << E.what () << std::endl;
51
- return 1 ;
52
- }
53
- } catch (runtime_error &E) {
54
- std::cerr << " Test case ReqdWGSizeNegativeA failed: unexpected exception: "
55
- << E.what () << std::endl;
56
- return 1 ;
57
- } catch (...) {
58
- std::cerr << " Test case ReqdWGSizeNegativeA failed: something unexpected "
59
- " has been caught"
60
- << std::endl;
61
- return 1 ;
62
- }
63
-
64
33
string_class OCLVersionStr = D.get_info <info::device::version>();
65
- assert (OCLVersionStr.size () >= 10 &&
34
+ const bool OCLBackend = (OCLVersionStr.find (" OpenCL" ) != string_class::npos);
35
+ assert ((!OCLBackend || (OCLVersionStr.size () >= 10 )) &&
66
36
" Unexpected device version string" ); // strlen("OpenCL X.Y")
67
37
const char *OCLVersion = &OCLVersionStr[7 ]; // strlen("OpenCL ")
68
- if (OCLVersion[0 ] == ' 1' || (OCLVersion[0 ] == ' 2' && OCLVersion[2 ] == ' 0' )) {
69
- // parallel_for, (16, 16, 16) global, null local, reqd_wg_size(4, 4, 4) //
38
+
39
+ // reqd_work_group_size is OpenCL specific.
40
+ if (OCLBackend) {
41
+ if (OCLVersion[0 ] == ' 1' || (OCLVersion[0 ] == ' 2' && OCLVersion[2 ] == ' 0' )) {
42
+ // parallel_for, (16, 16, 16) global, (8, 8, 8) local, reqd_wg_size(4, 4, 4)
70
43
// -> fail
71
44
try {
72
45
Q.submit ([&](handler &CGH) {
73
- CGH.parallel_for <class ReqdWGSizeNegativeB >(
74
- range<3 >(16 , 16 , 16 ), [=](item<3 >) { reqd_wg_size_helper (); });
46
+ CGH.parallel_for <class ReqdWGSizeNegativeA >(
47
+ nd_range<3 >(range<3 >(16 , 16 , 16 ), range<3 >(8 , 8 , 8 )),
48
+ [=](nd_item<3 >) { reqd_wg_size_helper (); });
75
49
});
76
50
Q.wait_and_throw ();
77
- std::cerr
78
- << " Test case ReqdWGSizeNegativeB failed: no exception has been "
79
- " thrown\n " ;
51
+ std::cerr << " Test case ReqdWGSizeNegativeA failed: no exception has been "
52
+ " thrown\n " ;
80
53
return 1 ; // We shouldn't be here, exception is expected
81
54
} catch (nd_range_error &E) {
82
55
if (string_class (E.what ()).find (
83
- " OpenCL 1.x and 2.0 requires to pass local size argument even if "
84
- " required work-group size was specified in the program source" ) ==
85
- string_class::npos) {
56
+ " Specified local size doesn't match the required work-group size "
57
+ " specified in the program source" ) == string_class::npos) {
86
58
std::cerr
87
- << " Test case ReqdWGSizeNegativeB failed: unexpected exception: "
59
+ << " Test case ReqdWGSizeNegativeA failed: unexpected exception: "
88
60
<< E.what () << std::endl;
89
61
return 1 ;
90
62
}
91
63
} catch (runtime_error &E) {
92
- std::cerr
93
- << " Test case ReqdWGSizeNegativeB failed: unexpected exception: "
94
- << E.what () << std::endl;
64
+ std::cerr << " Test case ReqdWGSizeNegativeA failed: unexpected exception: "
65
+ << E.what () << std::endl;
95
66
return 1 ;
96
67
} catch (...) {
97
- std::cerr << " Test case ReqdWGSizeNegativeB failed: something unexpected "
68
+ std::cerr << " Test case ReqdWGSizeNegativeA failed: something unexpected "
98
69
" has been caught"
99
70
<< std::endl;
100
71
return 1 ;
101
72
}
102
- }
103
73
104
- // Positive test-cases that should pass on any underlying OpenCL runtime
105
-
106
- // parallel_for, (8, 8, 8) global, (4, 4, 4) local, reqd_wg_size(4, 4, 4) ->
107
- // pass
108
- try {
109
- Q.submit ([&](handler &CGH) {
110
- CGH.parallel_for <class ReqdWGSizePositiveA >(
111
- nd_range<3 >(range<3 >(8 , 8 , 8 ), range<3 >(4 , 4 , 4 )),
112
- [=](nd_item<3 >) { reqd_wg_size_helper (); });
113
- });
114
- Q.wait_and_throw ();
115
- } catch (nd_range_error &E) {
116
- std::cerr << " Test case ReqdWGSizePositiveA failed: unexpected exception: "
117
- << E.what () << std::endl;
118
- return 1 ;
119
- } catch (runtime_error &E) {
120
- std::cerr << " Test case ReqdWGSizePositiveA failed: unexpected exception: "
74
+ // parallel_for, (16, 16, 16) global, null local, reqd_wg_size(4, 4, 4) //
75
+ // -> fail
76
+ try {
77
+ Q.submit ([&](handler &CGH) {
78
+ CGH.parallel_for <class ReqdWGSizeNegativeB >(
79
+ range<3 >(16 , 16 , 16 ), [=](item<3 >) { reqd_wg_size_helper (); });
80
+ });
81
+ Q.wait_and_throw ();
82
+ std::cerr
83
+ << " Test case ReqdWGSizeNegativeB failed: no exception has been "
84
+ " thrown\n " ;
85
+ return 1 ; // We shouldn't be here, exception is expected
86
+ } catch (nd_range_error &E) {
87
+ if (string_class (E.what ()).find (
88
+ " OpenCL 1.x and 2.0 requires to pass local size argument even if "
89
+ " required work-group size was specified in the program source" ) ==
90
+ string_class::npos) {
91
+ std::cerr
92
+ << " Test case ReqdWGSizeNegativeB failed: unexpected exception: "
121
93
<< E.what () << std::endl;
122
- return 1 ;
123
- } catch (...) {
124
- std::cerr << " Test case ReqdWGSizePositiveA failed: something unexpected "
125
- " has been caught"
126
- << std::endl;
127
- return 1 ;
128
- }
94
+ return 1 ;
95
+ }
96
+ } catch (runtime_error &E) {
97
+ std::cerr
98
+ << " Test case ReqdWGSizeNegativeB failed: unexpected exception: "
99
+ << E.what () << std::endl;
100
+ return 1 ;
101
+ } catch (...) {
102
+ std::cerr << " Test case ReqdWGSizeNegativeB failed: something unexpected "
103
+ " has been caught"
104
+ << std::endl;
105
+ return 1 ;
106
+ }
107
+ }
129
108
130
- if (OCLVersion[0 ] == ' 1' ) {
131
- // OpenCL 1.x
109
+ // Positive test-cases that should pass on any underlying OpenCL runtime
110
+
111
+ // parallel_for, (8, 8, 8) global, (4, 4, 4) local, reqd_wg_size(4, 4, 4) ->
112
+ // pass
113
+ try {
114
+ Q.submit ([&](handler &CGH) {
115
+ CGH.parallel_for <class ReqdWGSizePositiveA >(
116
+ nd_range<3 >(range<3 >(8 , 8 , 8 ), range<3 >(4 , 4 , 4 )),
117
+ [=](nd_item<3 >) { reqd_wg_size_helper (); });
118
+ });
119
+ Q.wait_and_throw ();
120
+ } catch (nd_range_error &E) {
121
+ std::cerr << " Test case ReqdWGSizePositiveA failed: unexpected exception: "
122
+ << E.what () << std::endl;
123
+ return 1 ;
124
+ } catch (runtime_error &E) {
125
+ std::cerr << " Test case ReqdWGSizePositiveA failed: unexpected exception: "
126
+ << E.what () << std::endl;
127
+ return 1 ;
128
+ } catch (...) {
129
+ std::cerr << " Test case ReqdWGSizePositiveA failed: something unexpected "
130
+ " has been caught"
131
+ << std::endl;
132
+ return 1 ;
133
+ }
134
+ } // if (OCLBackend)
135
+
136
+ if (!OCLBackend || (OCLVersion[0 ] == ' 1' )) {
137
+ // OpenCL 1.x or non-OpenCL backends which behave like OpenCl 1.2 in SYCL.
132
138
133
139
// CL_INVALID_WORK_GROUP_SIZE if local_work_size is specified and
134
140
// number of workitems specified by global_work_size is not evenly
@@ -227,7 +233,8 @@ int main() {
227
233
return 1 ; // We shouldn't be here, exception is expected
228
234
}
229
235
} catch (nd_range_error &E) {
230
- if (string_class (E.what ()).find (" Local workgroup size cannot be greater than global range in any dimension" ) == string_class::npos) {
236
+ if ((string_class (E.what ()).find (" Local workgroup size cannot be greater than global range in any dimension" ) == string_class::npos) &&
237
+ (string_class (E.what ()).find (" Non-uniform work-groups are not supported by the target device" ) == string_class::npos)) {
231
238
std::cerr
232
239
<< " Test case OpenCL1XNegativeA2 failed: unexpected exception: "
233
240
<< E.what () << std::endl;
@@ -264,7 +271,8 @@ int main() {
264
271
return 1 ; // We shouldn't be here, exception is expected
265
272
}
266
273
} catch (nd_range_error &E) {
267
- if (string_class (E.what ()).find (" Local workgroup size cannot be greater than global range in any dimension" ) == string_class::npos) {
274
+ if ((string_class (E.what ()).find (" Local workgroup size cannot be greater than global range in any dimension" ) == string_class::npos) &&
275
+ (string_class (E.what ()).find (" Non-uniform work-groups are not supported by the target device" ) == string_class::npos)) {
268
276
std::cerr
269
277
<< " Test case OpenCL1XNegativeB2 failed: unexpected exception: "
270
278
<< E.what () << std::endl;
@@ -299,9 +307,10 @@ int main() {
299
307
" thrown\n " ;
300
308
return 1 ; // We shouldn't be here, exception is expected
301
309
} catch (nd_range_error &E) {
302
- if (string_class (E.what ()).find (
310
+ if (( string_class (E.what ()).find (
303
311
" Total number of work-items in a work-group cannot exceed " +
304
- std::to_string (MaxDeviceWGSize)) == string_class::npos) {
312
+ std::to_string (MaxDeviceWGSize)) == string_class::npos) &&
313
+ (string_class (E.what ()).find (" Non-uniform work-groups are not supported by the target device" ) == string_class::npos)) {
305
314
std::cerr
306
315
<< " Test case OpenCL1XNegativeC failed: unexpected exception: "
307
316
<< E.what () << std::endl;
@@ -317,7 +326,7 @@ int main() {
317
326
<< std::endl;
318
327
return 1 ;
319
328
}
320
- } else if (OCLVersion[0 ] == ' 2' ) {
329
+ } else if (OCLBackend && ( OCLVersion[0 ] == ' 2' ) ) {
321
330
// OpenCL 2.x
322
331
323
332
// OpenCL 2.x:
0 commit comments