Skip to content

Commit e1c0bc1

Browse files
authored
[SYCL][E2E] Add missing zeInit to interop tests (#17699)
Level Zero loader is now linked statically with adapters and tests. This means that both adapters and tests need to call zeInit to initalize the loader.
1 parent 5af9fcf commit e1c0bc1

10 files changed

+79
-0
lines changed

sycl/test-e2e/Adapters/interop-level-zero-buffer-multi-dim.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ using namespace sycl;
1616
int main() {
1717
#ifdef SYCL_EXT_ONEAPI_BACKEND_LEVEL_ZERO
1818
try {
19+
// Initialize Level Zero driver is required if this test is linked
20+
// statically with Level Zero loader, the driver will not be init otherwise.
21+
ze_result_t result = zeInit(ZE_INIT_FLAG_GPU_ONLY);
22+
if (result != ZE_RESULT_SUCCESS) {
23+
std::cout << "zeInit failed\n";
24+
return 1;
25+
}
26+
1927
platform Plt{gpu_selector_v};
2028

2129
auto Devices = Plt.get_devices();

sycl/test-e2e/Adapters/interop-level-zero-buffer-ownership.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,14 @@ void test_copyback_and_free(
119119
int main() {
120120
#ifdef SYCL_EXT_ONEAPI_BACKEND_LEVEL_ZERO
121121
try {
122+
// Initialize Level Zero driver is required if this test is linked
123+
// statically with Level Zero loader, the driver will not be init otherwise.
124+
ze_result_t result = zeInit(ZE_INIT_FLAG_GPU_ONLY);
125+
if (result != ZE_RESULT_SUCCESS) {
126+
std::cout << "zeInit failed\n";
127+
return 1;
128+
}
129+
122130
platform Plt{gpu_selector_v};
123131

124132
auto Devices = Plt.get_devices();

sycl/test-e2e/Adapters/interop-level-zero-buffer.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ class DiscreteSelector : public sycl::device_selector {
3636
int main() {
3737
#ifdef SYCL_EXT_ONEAPI_BACKEND_LEVEL_ZERO
3838
try {
39+
// Initialize Level Zero driver is required if this test is linked
40+
// statically with Level Zero loader, the driver will not be init otherwise.
41+
ze_result_t result = zeInit(ZE_INIT_FLAG_GPU_ONLY);
42+
if (result != ZE_RESULT_SUCCESS) {
43+
std::cout << "zeInit failed\n";
44+
return 1;
45+
}
46+
3947
queue Queue{};
4048

4149
auto Context = Queue.get_info<info::queue::context>();

sycl/test-e2e/Adapters/interop-level-zero-get-native-mem.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ constexpr size_t SIZE = 16;
2323
int main() {
2424
#ifdef SYCL_EXT_ONEAPI_BACKEND_LEVEL_ZERO
2525
try {
26+
// Initialize Level Zero driver is required if this test is linked
27+
// statically with Level Zero loader, the driver will not be init otherwise.
28+
ze_result_t result = zeInit(ZE_INIT_FLAG_GPU_ONLY);
29+
if (result != ZE_RESULT_SUCCESS) {
30+
std::cout << "zeInit failed\n";
31+
return 1;
32+
}
33+
2634
platform Plt{gpu_selector_v};
2735

2836
auto Devices = Plt.get_devices();

sycl/test-e2e/Adapters/interop-level-zero-image-get-native-mem.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ using namespace sycl;
4242

4343
int main() {
4444
#ifdef SYCL_EXT_ONEAPI_BACKEND_LEVEL_ZERO
45+
// Initialize Level Zero driver is required if this test is linked
46+
// statically with Level Zero loader, the driver will not be init otherwise.
47+
ze_result_t result = zeInit(ZE_INIT_FLAG_GPU_ONLY);
48+
if (result != ZE_RESULT_SUCCESS) {
49+
std::cout << "zeInit failed\n";
50+
return 1;
51+
}
52+
4553
constexpr auto BE = sycl::backend::ext_oneapi_level_zero;
4654
sycl::device D =
4755
sycl::ext::oneapi::filter_selector("level_zero:gpu").select_device();

sycl/test-e2e/Adapters/interop-level-zero-image-ownership.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,14 @@ void test(sycl::ext::oneapi::level_zero::ownership Ownership) {
144144

145145
int main() {
146146
#ifdef SYCL_EXT_ONEAPI_BACKEND_LEVEL_ZERO
147+
// Initialize Level Zero driver is required if this test is linked
148+
// statically with Level Zero loader, the driver will not be init otherwise.
149+
ze_result_t result = zeInit(ZE_INIT_FLAG_GPU_ONLY);
150+
if (result != ZE_RESULT_SUCCESS) {
151+
std::cout << "zeInit failed\n";
152+
return 1;
153+
}
154+
147155
std::cout << "test ownership::transfer" << std::endl;
148156
test(sycl::ext::oneapi::level_zero::ownership::transfer);
149157

sycl/test-e2e/Adapters/interop-level-zero-image.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ using namespace sycl;
3232

3333
int main() {
3434
#ifdef SYCL_EXT_ONEAPI_BACKEND_LEVEL_ZERO
35+
// Initialize Level Zero driver is required if this test is linked
36+
// statically with Level Zero loader, the driver will not be init otherwise.
37+
ze_result_t result = zeInit(ZE_INIT_FLAG_GPU_ONLY);
38+
if (result != ZE_RESULT_SUCCESS) {
39+
std::cout << "zeInit failed\n";
40+
return 1;
41+
}
42+
3543
constexpr auto BE = sycl::backend::ext_oneapi_level_zero;
3644

3745
platform Plt{gpu_selector_v};

sycl/test-e2e/Adapters/interop-level-zero-keep-ownership.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@
1414
using namespace sycl;
1515

1616
int main() {
17+
// Initialize Level Zero driver is required if this test is linked
18+
// statically with Level Zero loader, the driver will not be init otherwise.
19+
ze_result_t result = zeInit(ZE_INIT_FLAG_GPU_ONLY);
20+
if (result != ZE_RESULT_SUCCESS) {
21+
std::cout << "zeInit failed\n";
22+
return 1;
23+
}
1724

1825
// Creat SYCL platform/device
1926
device Device(gpu_selector_v);

sycl/test-e2e/Adapters/interop-level-zero.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ using namespace sycl;
1616

1717
int main() {
1818
#ifdef SYCL_EXT_ONEAPI_BACKEND_LEVEL_ZERO
19+
// Initialize Level Zero driver is required if this test is linked
20+
// statically with Level Zero loader, the driver will not be init otherwise.
21+
ze_result_t result = zeInit(ZE_INIT_FLAG_GPU_ONLY);
22+
if (result != ZE_RESULT_SUCCESS) {
23+
std::cout << "zeInit failed\n";
24+
return 1;
25+
}
26+
1927
queue Queue{};
2028

2129
event DefaultEvent;

sycl/test-e2e/Adapters/level_zero_batch_barrier.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ void submit_kernel(queue &q) {
2121
}
2222

2323
int main(int argc, char *argv[]) {
24+
// Initialize Level Zero driver is required if this test is linked
25+
// statically with Level Zero loader, the driver will not be init otherwise.
26+
ze_result_t result = zeInit(ZE_INIT_FLAG_GPU_ONLY);
27+
if (result != ZE_RESULT_SUCCESS) {
28+
std::cout << "zeInit failed\n";
29+
return 1;
30+
}
31+
2432
queue q;
2533

2634
submit_kernel(q); // starts a batch

0 commit comments

Comments
 (0)