Skip to content

Commit e582654

Browse files
[SYCL] kernel_compiler and device lists. (#11988)
piProgramBuild must be called with a device list, not individually. BUT no backend presently supports kernel compilation across multiple devices, so the test ensures that any queue/context instantiated is limited to just one device.
1 parent 7868596 commit e582654

File tree

3 files changed

+28
-21
lines changed

3 files changed

+28
-21
lines changed

sycl/source/detail/kernel_bundle_impl.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,11 +372,15 @@ class kernel_bundle_impl {
372372

373373
Plugin->call<PiApiKind::piProgramRetain>(PiProgram);
374374

375+
std::vector<pi::PiDevice> DeviceVec;
376+
DeviceVec.reserve(Devices.size());
375377
for (const auto &SyclDev : Devices) {
376378
pi::PiDevice Dev = getSyclObjImpl(SyclDev)->getHandleRef();
377-
Plugin->call<errc::build, PiApiKind::piProgramBuild>(
378-
PiProgram, 1, &Dev, nullptr, nullptr, nullptr);
379+
DeviceVec.push_back(Dev);
379380
}
381+
Plugin->call<errc::build, PiApiKind::piProgramBuild>(
382+
PiProgram, DeviceVec.size(), DeviceVec.data(), nullptr, nullptr,
383+
nullptr);
380384

381385
// Get the number of kernels in the program.
382386
size_t NumKernels;

sycl/test-e2e/KernelCompiler/kernel_compiler.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@
88

99
// REQUIRES: ocloc
1010

11-
// UNSUPPORTED: (gpu-intel-dg2 && level_zero) || (gpu-intel-pvc && level_zero)
12-
// Seems to be an incompatibility with the KernelCompiler on L0 with DG2 and
13-
// PVC.
14-
1511
// RUN: %{build} -o %t.out
1612
// RUN: %{run} %t.out
1713

@@ -82,8 +78,11 @@ void test_build_and_run() {
8278
using source_kb = sycl::kernel_bundle<sycl::bundle_state::ext_oneapi_source>;
8379
using exe_kb = sycl::kernel_bundle<sycl::bundle_state::executable>;
8480

85-
sycl::queue q;
86-
sycl::context ctx = q.get_context();
81+
// only one device is supported at this time, so we limit the queue and
82+
// context to that
83+
sycl::device d{sycl::default_selector_v};
84+
sycl::context ctx{d};
85+
sycl::queue q{ctx, d};
8786

8887
bool ok = syclex::is_source_kernel_bundle_supported(
8988
ctx.get_backend(), syclex::source_language::opencl);
@@ -135,8 +134,11 @@ void test_error() {
135134
using source_kb = sycl::kernel_bundle<sycl::bundle_state::ext_oneapi_source>;
136135
using exe_kb = sycl::kernel_bundle<sycl::bundle_state::executable>;
137136

138-
sycl::queue q;
139-
sycl::context ctx = q.get_context();
137+
// only one device is supported at this time, so we limit the queue and
138+
// context to that
139+
sycl::device d{sycl::default_selector_v};
140+
sycl::context ctx{d};
141+
sycl::queue q{ctx, d};
140142

141143
bool ok = syclex::is_source_kernel_bundle_supported(
142144
ctx.get_backend(), syclex::source_language::opencl);

sycl/test-e2e/KernelCompiler/opencl_capabilities.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,15 @@
88

99
// REQUIRES: ocloc
1010

11-
// UNSUPPORTED: (gpu-intel-dg2 && level_zero) || (gpu-intel-pvc && level_zero)
12-
// Seems to be an incompatibility with the KernelCompiler on L0 with DG2 and
13-
// PVC.
14-
1511
// RUN: %{build} -o %t.out
1612
// RUN: %{run} %t.out
1713

1814
// Here we are testing some of the various args that SYCL can and cannot
1915
// pass to an OpenCL kernel that is compiled with the kernel_compiler.
2016

17+
// no backend supports compiling for multiple devices yet, so we limit
18+
// the queue and context to just one.
19+
2120
// IMPORTANT: LevelZero YES!
2221
// Even though this test is covering which OpenCL capabilities
2322
// are covered by the kernel_compiler, this is not a test of only
@@ -51,9 +50,9 @@ auto constexpr LocalAccCLSource = R"===(
5150
)===";
5251

5352
void test_local_accessor() {
54-
55-
sycl::queue q;
56-
sycl::context ctx = q.get_context();
53+
sycl::device d{sycl::default_selector_v};
54+
sycl::context ctx{d};
55+
sycl::queue q{ctx, d};
5756

5857
source_kb kbSrc = syclex::create_kernel_bundle_from_source(
5958
ctx, syclex::source_language::opencl, LocalAccCLSource);
@@ -93,8 +92,9 @@ __kernel void usm_kernel(__global int *usmPtr, int multiplier, float added) {
9392
)===";
9493

9594
void test_usm_pointer_and_scalar() {
96-
sycl::queue q;
97-
sycl::context ctx = q.get_context();
95+
sycl::device d{sycl::default_selector_v};
96+
sycl::context ctx{d};
97+
sycl::queue q{ctx, d};
9898

9999
source_kb kbSrc = syclex::create_kernel_bundle_from_source(
100100
ctx, syclex::source_language::opencl, USMCLSource);
@@ -146,8 +146,9 @@ struct pair {
146146
};
147147

148148
void test_struct() {
149-
sycl::queue q;
150-
sycl::context ctx = q.get_context();
149+
sycl::device d{sycl::default_selector_v};
150+
sycl::context ctx{d};
151+
sycl::queue q{ctx, d};
151152

152153
source_kb kbSrc = syclex::create_kernel_bundle_from_source(
153154
ctx, syclex::source_language::opencl, StructSrc);

0 commit comments

Comments
 (0)