Skip to content

Commit f8b72c7

Browse files
committed
[SYCL][LIT] Apply clang-format to test
Signed-off-by: Bjoern Knafla <[email protected]>
1 parent 7089b6a commit f8b72c7

File tree

1 file changed

+112
-74
lines changed

1 file changed

+112
-74
lines changed

sycl/test/basic_tests/parallel_for_range.cpp

Lines changed: 112 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -38,38 +38,44 @@ int main() {
3838

3939
// reqd_work_group_size is OpenCL specific.
4040
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)
43-
// -> fail
44-
try {
45-
Q.submit([&](handler &CGH) {
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(); });
49-
});
50-
Q.wait_and_throw();
51-
std::cerr << "Test case ReqdWGSizeNegativeA failed: no exception has been "
52-
"thrown\n";
53-
return 1; // We shouldn't be here, exception is expected
54-
} catch (nd_range_error &E) {
55-
if (string_class(E.what()).find(
56-
"Specified local size doesn't match the required work-group size "
57-
"specified in the program source") == string_class::npos) {
41+
if (OCLVersion[0] == '1' ||
42+
(OCLVersion[0] == '2' && OCLVersion[2] == '0')) {
43+
// parallel_for, (16, 16, 16) global, (8, 8, 8) local, reqd_wg_size(4, 4,
44+
// 4)
45+
// -> fail
46+
try {
47+
Q.submit([&](handler &CGH) {
48+
CGH.parallel_for<class ReqdWGSizeNegativeA>(
49+
nd_range<3>(range<3>(16, 16, 16), range<3>(8, 8, 8)),
50+
[=](nd_item<3>) { reqd_wg_size_helper(); });
51+
});
52+
Q.wait_and_throw();
53+
std::cerr
54+
<< "Test case ReqdWGSizeNegativeA failed: no exception has been "
55+
"thrown\n";
56+
return 1; // We shouldn't be here, exception is expected
57+
} catch (nd_range_error &E) {
58+
if (string_class(E.what()).find("Specified local size doesn't match "
59+
"the required work-group size "
60+
"specified in the program source") ==
61+
string_class::npos) {
62+
std::cerr
63+
<< "Test case ReqdWGSizeNegativeA failed: unexpected exception: "
64+
<< E.what() << std::endl;
65+
return 1;
66+
}
67+
} catch (runtime_error &E) {
5868
std::cerr
5969
<< "Test case ReqdWGSizeNegativeA failed: unexpected exception: "
6070
<< E.what() << std::endl;
6171
return 1;
72+
} catch (...) {
73+
std::cerr
74+
<< "Test case ReqdWGSizeNegativeA failed: something unexpected "
75+
"has been caught"
76+
<< std::endl;
77+
return 1;
6278
}
63-
} catch (runtime_error &E) {
64-
std::cerr << "Test case ReqdWGSizeNegativeA failed: unexpected exception: "
65-
<< E.what() << std::endl;
66-
return 1;
67-
} catch (...) {
68-
std::cerr << "Test case ReqdWGSizeNegativeA failed: something unexpected "
69-
"has been caught"
70-
<< std::endl;
71-
return 1;
72-
}
7379

7480
// parallel_for, (16, 16, 16) global, null local, reqd_wg_size(4, 4, 4) //
7581
// -> fail
@@ -84,9 +90,10 @@ int main() {
8490
"thrown\n";
8591
return 1; // We shouldn't be here, exception is expected
8692
} 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") ==
93+
if (string_class(E.what()).find("OpenCL 1.x and 2.0 requires to pass "
94+
"local size argument even if "
95+
"required work-group size was "
96+
"specified in the program source") ==
9097
string_class::npos) {
9198
std::cerr
9299
<< "Test case ReqdWGSizeNegativeB failed: unexpected exception: "
@@ -99,9 +106,10 @@ int main() {
99106
<< E.what() << std::endl;
100107
return 1;
101108
} catch (...) {
102-
std::cerr << "Test case ReqdWGSizeNegativeB failed: something unexpected "
103-
"has been caught"
104-
<< std::endl;
109+
std::cerr
110+
<< "Test case ReqdWGSizeNegativeB failed: something unexpected "
111+
"has been caught"
112+
<< std::endl;
105113
return 1;
106114
}
107115
}
@@ -118,12 +126,14 @@ int main() {
118126
});
119127
Q.wait_and_throw();
120128
} catch (nd_range_error &E) {
121-
std::cerr << "Test case ReqdWGSizePositiveA failed: unexpected exception: "
122-
<< E.what() << std::endl;
129+
std::cerr
130+
<< "Test case ReqdWGSizePositiveA failed: unexpected exception: "
131+
<< E.what() << std::endl;
123132
return 1;
124133
} catch (runtime_error &E) {
125-
std::cerr << "Test case ReqdWGSizePositiveA failed: unexpected exception: "
126-
<< E.what() << std::endl;
134+
std::cerr
135+
<< "Test case ReqdWGSizePositiveA failed: unexpected exception: "
136+
<< E.what() << std::endl;
127137
return 1;
128138
} catch (...) {
129139
std::cerr << "Test case ReqdWGSizePositiveA failed: something unexpected "
@@ -233,8 +243,12 @@ int main() {
233243
return 1; // We shouldn't be here, exception is expected
234244
}
235245
} catch (nd_range_error &E) {
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)) {
246+
if ((string_class(E.what()).find("Local workgroup size cannot be greater "
247+
"than global range in any dimension") ==
248+
string_class::npos) &&
249+
(string_class(E.what()).find("Non-uniform work-groups are not "
250+
"supported by the target device") ==
251+
string_class::npos)) {
238252
std::cerr
239253
<< "Test case OpenCL1XNegativeA2 failed: unexpected exception: "
240254
<< E.what() << std::endl;
@@ -271,8 +285,12 @@ int main() {
271285
return 1; // We shouldn't be here, exception is expected
272286
}
273287
} catch (nd_range_error &E) {
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)) {
288+
if ((string_class(E.what()).find("Local workgroup size cannot be greater "
289+
"than global range in any dimension") ==
290+
string_class::npos) &&
291+
(string_class(E.what()).find("Non-uniform work-groups are not "
292+
"supported by the target device") ==
293+
string_class::npos)) {
276294
std::cerr
277295
<< "Test case OpenCL1XNegativeB2 failed: unexpected exception: "
278296
<< E.what() << std::endl;
@@ -308,9 +326,11 @@ int main() {
308326
return 1; // We shouldn't be here, exception is expected
309327
} catch (nd_range_error &E) {
310328
if ((string_class(E.what()).find(
311-
"Total number of work-items in a work-group cannot exceed " +
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)) {
329+
"Total number of work-items in a work-group cannot exceed " +
330+
std::to_string(MaxDeviceWGSize)) == string_class::npos) &&
331+
(string_class(E.what()).find("Non-uniform work-groups are not "
332+
"supported by the target device") ==
333+
string_class::npos)) {
314334
std::cerr
315335
<< "Test case OpenCL1XNegativeC failed: unexpected exception: "
316336
<< E.what() << std::endl;
@@ -488,9 +508,11 @@ int main() {
488508
} catch (nd_range_error &E) {
489509
if (string_class(E.what()).find(
490510
"Local workgroup size greater than global range size. "
491-
"Non-uniform work-groups are not allowed by default. Underlying "
511+
"Non-uniform work-groups are not allowed by default. "
512+
"Underlying "
492513
"OpenCL 2.x implementation supports this feature and to enable "
493-
"it, build device program with -cl-std=CL2.0") == string_class::npos) {
514+
"it, build device program with -cl-std=CL2.0") ==
515+
string_class::npos) {
494516
std::cerr
495517
<< "Test case OpenCL2XNegativeB2 failed: unexpected exception: "
496518
<< E.what() << std::endl;
@@ -502,9 +524,10 @@ int main() {
502524
<< E.what() << std::endl;
503525
return 1;
504526
} catch (...) {
505-
std::cerr << "Test case OpenCL2XNegativeB2 failed: something unexpected "
506-
"has been caught"
507-
<< std::endl;
527+
std::cerr
528+
<< "Test case OpenCL2XNegativeB2 failed: something unexpected "
529+
"has been caught"
530+
<< std::endl;
508531
return 1;
509532
}
510533

@@ -545,9 +568,10 @@ int main() {
545568
<< E.what() << std::endl;
546569
return 1;
547570
} catch (...) {
548-
std::cerr << "Test case OpenCL2XNegativeC2 failed: something unexpected "
549-
"has been caught"
550-
<< std::endl;
571+
std::cerr
572+
<< "Test case OpenCL2XNegativeC2 failed: something unexpected "
573+
"has been caught"
574+
<< std::endl;
551575
return 1;
552576
}
553577
}
@@ -645,9 +669,12 @@ int main() {
645669
} catch (nd_range_error &E) {
646670
if (string_class(E.what()).find(
647671
"Global_work_size not evenly divisible by local_work_size. "
648-
"Non-uniform work-groups are not allowed by when -cl-uniform-work-group-size flag is used. Underlying "
649-
"OpenCL 2.x implementation supports this feature, but it is being "
650-
"disabled by -cl-uniform-work-group-size build flag") == string_class::npos) {
672+
"Non-uniform work-groups are not allowed by when "
673+
"-cl-uniform-work-group-size flag is used. Underlying "
674+
"OpenCL 2.x implementation supports this feature, but it is "
675+
"being "
676+
"disabled by -cl-uniform-work-group-size build flag") ==
677+
string_class::npos) {
651678
std::cerr
652679
<< "Test case OpenCL2XNegativeD failed: unexpected exception: "
653680
<< E.what() << std::endl;
@@ -692,9 +719,12 @@ int main() {
692719
} catch (nd_range_error &E) {
693720
if (string_class(E.what()).find(
694721
"Global_work_size not evenly divisible by local_work_size. "
695-
"Non-uniform work-groups are not allowed by when -cl-uniform-work-group-size flag is used. Underlying "
696-
"OpenCL 2.x implementation supports this feature, but it is being "
697-
"disabled by -cl-uniform-work-group-size build flag") == string_class::npos) {
722+
"Non-uniform work-groups are not allowed by when "
723+
"-cl-uniform-work-group-size flag is used. Underlying "
724+
"OpenCL 2.x implementation supports this feature, but it is "
725+
"being "
726+
"disabled by -cl-uniform-work-group-size build flag") ==
727+
string_class::npos) {
698728
std::cerr
699729
<< "Test case OpenCL2XNegativeE failed: unexpected exception: "
700730
<< E.what() << std::endl;
@@ -713,10 +743,10 @@ int main() {
713743
}
714744
}
715745

716-
// Local Size larger than Global, -cl-std=CL2.0 -cl-uniform-work-group-size flag used
717-
// CL_INVALID_WORK_GROUP_SIZE if local_work_size is specified as larger
718-
// than the global size, then a different error string is used.
719-
// This is a sub-case of the more general 'non-uniform work group'
746+
// Local Size larger than Global, -cl-std=CL2.0 -cl-uniform-work-group-size
747+
// flag used CL_INVALID_WORK_GROUP_SIZE if local_work_size is specified as
748+
// larger than the global size, then a different error string is used. This
749+
// is a sub-case of the more general 'non-uniform work group'
720750
{
721751
program P(Q.get_context());
722752
P.build_with_kernel_type<class OpenCL2XNegativeD2>(
@@ -742,9 +772,12 @@ int main() {
742772
} catch (nd_range_error &E) {
743773
if (string_class(E.what()).find(
744774
"Local workgroup size greater than global range size. "
745-
"Non-uniform work-groups are not allowed by when -cl-uniform-work-group-size flag is used. Underlying "
746-
"OpenCL 2.x implementation supports this feature, but it is being "
747-
"disabled by -cl-uniform-work-group-size build flag") == string_class::npos) {
775+
"Non-uniform work-groups are not allowed by when "
776+
"-cl-uniform-work-group-size flag is used. Underlying "
777+
"OpenCL 2.x implementation supports this feature, but it is "
778+
"being "
779+
"disabled by -cl-uniform-work-group-size build flag") ==
780+
string_class::npos) {
748781
std::cerr
749782
<< "Test case OpenCL2XNegativeD2 failed: unexpected exception: "
750783
<< E.what() << std::endl;
@@ -756,9 +789,10 @@ int main() {
756789
<< E.what() << std::endl;
757790
return 1;
758791
} catch (...) {
759-
std::cerr << "Test case OpenCL2XNegativeD2 failed: something unexpected "
760-
"has been caught"
761-
<< std::endl;
792+
std::cerr
793+
<< "Test case OpenCL2XNegativeD2 failed: something unexpected "
794+
"has been caught"
795+
<< std::endl;
762796
return 1;
763797
}
764798
}
@@ -789,9 +823,12 @@ int main() {
789823
} catch (nd_range_error &E) {
790824
if (string_class(E.what()).find(
791825
"Local workgroup size greater than global range size. "
792-
"Non-uniform work-groups are not allowed by when -cl-uniform-work-group-size flag is used. Underlying "
793-
"OpenCL 2.x implementation supports this feature, but it is being "
794-
"disabled by -cl-uniform-work-group-size build flag") == string_class::npos) {
826+
"Non-uniform work-groups are not allowed by when "
827+
"-cl-uniform-work-group-size flag is used. Underlying "
828+
"OpenCL 2.x implementation supports this feature, but it is "
829+
"being "
830+
"disabled by -cl-uniform-work-group-size build flag") ==
831+
string_class::npos) {
795832
std::cerr
796833
<< "Test case OpenCL2XNegativeE2 failed: unexpected exception: "
797834
<< E.what() << std::endl;
@@ -803,9 +840,10 @@ int main() {
803840
<< E.what() << std::endl;
804841
return 1;
805842
} catch (...) {
806-
std::cerr << "Test case OpenCL2XNegativeE2 failed: something unexpected "
807-
"has been caught"
808-
<< std::endl;
843+
std::cerr
844+
<< "Test case OpenCL2XNegativeE2 failed: something unexpected "
845+
"has been caught"
846+
<< std::endl;
809847
return 1;
810848
}
811849
}

0 commit comments

Comments
 (0)