Skip to content

Commit 5b9f0f6

Browse files
authored
[SYCL] Fix launch config in the max_num_work_groups e2e test (#15359)
The previous global work size was exceeding the limits of INT_MAX on the intel opencl fpga emulator device and thus failing the test. This commit also cleans up the test checks validation by leaving the `assert`ions and removing the `if` conditions.
1 parent 40271ed commit 5b9f0f6

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

sycl/test-e2e/Basic/launch_queries/max_num_work_groups.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ int test_max_num_work_groups(sycl::queue &q, const sycl::device &dev) {
7171

7272
const size_t maxWorkGroupSize =
7373
kernel.template get_info<work_group_size>(dev);
74-
const size_t NumWorkItems = maxWorkGroupSize * maxWorkGroupSize;
74+
// Will try to launch 2 work groups.
75+
const size_t NumWorkItems = maxWorkGroupSize * 2;
7576

7677
size_t workGroupSize = 32;
7778
size_t localMemorySizeInBytes{0};
@@ -100,8 +101,6 @@ int test_max_num_work_groups(sycl::queue &q, const sycl::device &dev) {
100101
// ===================== //
101102
// We must have at least one active group if we are below resource limits.
102103
assert(maxWGs > 0 && "max_num_work_groups query failed");
103-
if (maxWGs == 0)
104-
return 1;
105104

106105
// Run the kernel
107106
auto launch_range = sycl::nd_range<1>{sycl::range<1>{NumWorkItems},
@@ -121,7 +120,6 @@ int test_max_num_work_groups(sycl::queue &q, const sycl::device &dev) {
121120
// ========================== //
122121
// Test 3 - use max resources //
123122
// ========================== //
124-
// A little over the maximum work-group size for the purpose of exceeding.
125123
workGroupSize = maxWorkGroupSize;
126124
workGroupRange[0] = workGroupSize;
127125
size_t localSize =
@@ -133,9 +131,8 @@ int test_max_num_work_groups(sycl::queue &q, const sycl::device &dev) {
133131
syclex::info::kernel_queue_specific::max_num_work_groups>(
134132
q, workGroupRange, localMemorySizeInBytes);
135133

134+
// We must have at least one active group if we are at resource limits.
136135
assert(maxWGs > 0 && "max_num_work_groups query failed");
137-
if (maxWGs == 0)
138-
return 1;
139136

140137
launch_range = sycl::nd_range<1>{sycl::range<1>{NumWorkItems},
141138
sycl::range<1>{workGroupSize}};
@@ -155,6 +152,7 @@ int test_max_num_work_groups(sycl::queue &q, const sycl::device &dev) {
155152
// =============================== //
156153
// Test 4 - exceed resource limits //
157154
// =============================== //
155+
// A little over the maximum work-group size for the purpose of exceeding.
158156
workGroupSize = maxWorkGroupSize + 32;
159157
workGroupRange[0] = workGroupSize;
160158
maxWGs = kernel.template ext_oneapi_get_info<
@@ -163,10 +161,10 @@ int test_max_num_work_groups(sycl::queue &q, const sycl::device &dev) {
163161
// It cannot be possible to launch a kernel successfully with a configuration
164162
// that exceeds the available resources as in the above defined workGroupSize.
165163
// workGroupSize is larger than maxWorkGroupSize, hence maxWGs must equal 0.
164+
// Note: Level-Zero currently always returns a non-zero value. While other
165+
// backends (i.e., OpenCL, HIP) always return 1 in their implementations.
166166
if (dev.get_backend() == sycl::backend::ext_oneapi_cuda) {
167167
assert(maxWGs == 0 && "max_num_work_groups query failed");
168-
if (maxWGs > 0)
169-
return 1;
170168
}
171169

172170
// As we ensured that the 'max_num_work_groups' query correctly

0 commit comments

Comments
 (0)