Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit f61938f

Browse files
[SYCL] Change online compiler test to build IL based on queue (#1028)
Level-zero expects a single device when creating a module. This means that the online compiler test for level-zero has an assertion on the supplied context assuring only a single device. However, on multi-GPU systems this assertion will fail, in turn causing the test to report a failure. Rather than skipping the test on multi-GPU systems, these changes makes the test use the device in the queue rather than the first device in the associated context. Signed-off-by: Larsen, Steffen <[email protected]>
1 parent 46354b5 commit f61938f

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

SYCL/OnlineCompiler/online_compiler_L0.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
using byte = unsigned char;
2424

2525
#ifdef RUN_KERNELS
26-
sycl::kernel getSYCLKernelWithIL(sycl::context &Context,
26+
sycl::kernel getSYCLKernelWithIL(sycl::queue &Queue,
2727
const std::vector<byte> &IL) {
2828

2929
ze_module_desc_t ZeModuleDesc = {};
@@ -33,8 +33,8 @@ sycl::kernel getSYCLKernelWithIL(sycl::context &Context,
3333
ZeModuleDesc.pBuildFlags = "";
3434
ZeModuleDesc.pConstants = nullptr;
3535

36-
assert(Context.get_devices().size() == 1 && "Expected to have only 1 device");
37-
sycl::device Device = Context.get_devices()[0];
36+
sycl::context Context = Queue.get_context();
37+
sycl::device Device = Queue.get_device();
3838
auto ZeDevice = Device.get_native<sycl::backend::ext_oneapi_level_zero>();
3939
auto ZeContext = Context.get_native<sycl::backend::ext_oneapi_level_zero>();
4040

SYCL/OnlineCompiler/online_compiler_OpenCL.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@
1919
using byte = unsigned char;
2020

2121
#ifdef RUN_KERNELS
22-
sycl::kernel getSYCLKernelWithIL(sycl::context &Context,
22+
sycl::kernel getSYCLKernelWithIL(sycl::queue &Queue,
2323
const std::vector<byte> &IL) {
24+
sycl::context Context = Queue.get_context();
25+
2426
cl_int Err;
2527
cl_program ClProgram =
2628
clCreateProgramWithIL(sycl::get_native<sycl::backend::opencl>(Context),

SYCL/OnlineCompiler/online_compiler_common.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ void testSyclKernel(sycl::queue &Q, sycl::kernel Kernel) {
5151

5252
int main(int argc, char **argv) {
5353
cl::sycl::queue Q;
54-
cl::sycl::context Context = Q.get_context();
5554
cl::sycl::device Device = Q.get_device();
5655

5756
{ // Compile and run a trivial OpenCL kernel.
@@ -73,7 +72,7 @@ int main(int argc, char **argv) {
7372
return 1;
7473
}
7574
#ifdef RUN_KERNELS
76-
testSyclKernel(Q, getSYCLKernelWithIL(Context, IL));
75+
testSyclKernel(Q, getSYCLKernelWithIL(Q, IL));
7776
#endif // RUN_KERNELS
7877
}
7978

@@ -93,7 +92,7 @@ int main(int argc, char **argv) {
9392
return 1;
9493
}
9594
#ifdef RUN_KERNELS
96-
testSyclKernel(Q, getSYCLKernelWithIL(Context, IL));
95+
testSyclKernel(Q, getSYCLKernelWithIL(Q, IL));
9796
#endif // RUN_KERNELS
9897
}
9998

0 commit comments

Comments
 (0)