Skip to content

[SYCL][L0] Fix absence of zeInit in Level Zero LIT e2e tests #18956

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: sycl
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions sycl/test-e2e/Adapters/level_zero/batch_barrier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ int main(int argc, char *argv[]) {
// CHECK: ---> urEnqueueKernelLaunch
// CHECK-NOT: zeCommandQueueExecuteCommandLists

// Initialize Level Zero driver is required if this test is linked
// statically with Level Zero loader, the driver will not be init otherwise.
// Initializing Level Zero driver is required if this test is linked
// statically with Level Zero loader, otherwise the driver will not be initialized.
ze_result_t result = zeInit(ZE_INIT_FLAG_GPU_ONLY);
if (result != ZE_RESULT_SUCCESS) {
std::cout << "zeInit failed\n";
std::cout << "zeInit failed" << std::endl;
return 1;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ int main() {
return 0;
}

// Initialize Level Zero driver is required if this test is linked
// statically with Level Zero loader, the driver will not be init otherwise.
// Initializing Level Zero driver is required if this test is linked
// statically with Level Zero loader, otherwise the driver will not be initialized.
ze_result_t result = zeInit(ZE_INIT_FLAG_GPU_ONLY);
if (result != ZE_RESULT_SUCCESS) {
std::cout << "zeInit failed\n";
std::cout << "zeInit failed" << std::endl;
return 1;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,11 @@ int main() {
return 0;
}

// Initialize Level Zero driver is required if this test is linked
// statically with Level Zero loader, the driver will not be init otherwise.
// Initializing Level Zero driver is required if this test is linked
// statically with Level Zero loader, otherwise the driver will not be initialized.
ze_result_t result = zeInit(ZE_INIT_FLAG_GPU_ONLY);
if (result != ZE_RESULT_SUCCESS) {
std::cout << "zeInit failed\n";
std::cout << "zeInit failed" << std::endl;
return 1;
}

Expand Down
9 changes: 3 additions & 6 deletions sycl/test-e2e/Adapters/level_zero/interop-buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,10 @@ int main() {
auto ZeContext = get_native<backend::ext_oneapi_level_zero>(Context);
auto ZeDevice = get_native<backend::ext_oneapi_level_zero>(Device);

// Initialize Level Zero driver is required if this test is linked
// statically with Level Zero loader, the driver will not be init otherwise.
// Initializing Level Zero driver is required if this test is linked
// statically with Level Zero loader, otherwise the driver will not be initialized.
ze_result_t result = zeInit(ZE_INIT_FLAG_GPU_ONLY);
if (result != ZE_RESULT_SUCCESS) {
std::cout << "zeInit failed\n";
return 1;
}
assert(result == ZE_RESULT_SUCCESS);

ze_host_mem_alloc_desc_t HostDesc = {};
HostDesc.stype = ZE_STRUCTURE_TYPE_HOST_MEM_ALLOC_DESC;
Expand Down
2 changes: 1 addition & 1 deletion sycl/test-e2e/Adapters/level_zero/interop-direct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ int main() {
// Init L0
ze_result_t result = zeInit(0);
if (result != ZE_RESULT_SUCCESS) {
std::cout << "zeInit failed\n";
std::cout << "zeInit failed" << std::endl;
return 1;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ int main() {
return 0;
}

// Initialize Level Zero driver is required if this test is linked
// statically with Level Zero loader, the driver will not be init otherwise.
// Initializing Level Zero driver is required if this test is linked
// statically with Level Zero loader, otherwise the driver will not be initialized.
ze_result_t result = zeInit(ZE_INIT_FLAG_GPU_ONLY);
if (result != ZE_RESULT_SUCCESS) {
std::cout << "zeInit failed\n";
std::cout << "zeInit failed" << std::endl;
return 1;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ int main() {
sycl::device D =
sycl::ext::oneapi::filter_selector("level_zero:gpu").select_device();

// Initialize Level Zero driver is required if this test is linked
// statically with Level Zero loader, the driver will not be init otherwise.
// Initializing Level Zero driver is required if this test is linked
// statically with Level Zero loader, otherwise the driver will not be initialized.
ze_result_t result = zeInit(ZE_INIT_FLAG_GPU_ONLY);
if (result != ZE_RESULT_SUCCESS) {
std::cout << "zeInit failed\n";
std::cout << "zeInit failed" << std::endl;
return 1;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,11 @@ int main() {
#ifdef SYCL_EXT_ONEAPI_BACKEND_LEVEL_ZERO
platform Plt{gpu_selector_v};

// Initialize Level Zero driver is required if this test is linked
// statically with Level Zero loader, the driver will not be init otherwise.
// Initializing Level Zero driver is required if this test is linked
// statically with Level Zero loader, otherwise the driver will not be initialized.
ze_result_t result = zeInit(ZE_INIT_FLAG_GPU_ONLY);
if (result != ZE_RESULT_SUCCESS) {
std::cout << "zeInit failed\n";
std::cout << "zeInit failed" << std::endl;
return 1;
}

Expand Down
6 changes: 3 additions & 3 deletions sycl/test-e2e/Adapters/level_zero/interop-image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ int main() {

auto Devices = Plt.get_devices();

// Initialize Level Zero driver is required if this test is linked
// statically with Level Zero loader, the driver will not be init otherwise.
// Initializing Level Zero driver is required if this test is linked
// statically with Level Zero loader, otherwise the driver will not be initialized.
ze_result_t result = zeInit(ZE_INIT_FLAG_GPU_ONLY);
if (result != ZE_RESULT_SUCCESS) {
std::cout << "zeInit failed\n";
std::cout << "zeInit failed" << std::endl;
return 1;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ int main() {
device Device(gpu_selector_v);
platform Platform = Device.get_info<info::device::platform>();

// Initialize Level Zero driver is required if this test is linked
// statically with Level Zero loader, the driver will not be init otherwise.
// Initializing Level Zero driver is required if this test is linked
// statically with Level Zero loader, otherwise the driver will not be initialized.
ze_result_t result = zeInit(ZE_INIT_FLAG_GPU_ONLY);
if (result != ZE_RESULT_SUCCESS) {
std::cout << "zeInit failed\n";
std::cout << "zeInit failed" << std::endl;
return 1;
}

Expand Down
5 changes: 4 additions & 1 deletion sycl/test-e2e/Adapters/level_zero/interop-thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ ze_event_pool_handle_t event_pool = {};
std::vector<operation> old_ops;

void init() {
zeInit(0);
// Initializing Level Zero driver is required if this test is linked
// statically with Level Zero loader, otherwise the driver will not be initialized.
ze_result_t result = zeInit(0);
assert(result == ZE_RESULT_SUCCESS);

uint32_t driverCount = 0;
assert(zeDriverGet(&driverCount, nullptr) == 0);
Expand Down
6 changes: 3 additions & 3 deletions sycl/test-e2e/Adapters/level_zero/interop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ using namespace sycl;

int main() {
#ifdef SYCL_EXT_ONEAPI_BACKEND_LEVEL_ZERO
// Initialize Level Zero driver is required if this test is linked
// statically with Level Zero loader, the driver will not be init otherwise.
// Initializing Level Zero driver is required if this test is linked
// statically with Level Zero loader, otherwise the driver will not be initialized.
ze_result_t result = zeInit(ZE_INIT_FLAG_GPU_ONLY);
if (result != ZE_RESULT_SUCCESS) {
std::cout << "zeInit failed\n";
std::cout << "zeInit failed" << std::endl;
return 1;
}

Expand Down
9 changes: 9 additions & 0 deletions sycl/test-e2e/Adapters/level_zero/uuid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ int main() {
auto zedev = sycl::get_native<sycl::backend::ext_oneapi_level_zero>(dev);
ze_device_properties_t device_properties{};
device_properties.stype = ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES;

// Initializing Level Zero driver is required if this test is linked
// statically with Level Zero loader, otherwise the driver will not be initialized.
ze_result_t result = zeInit(ZE_INIT_FLAG_GPU_ONLY);
if (result != ZE_RESULT_SUCCESS) {
std::cout << "zeInit failed" << std::endl;
return 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+ some small enhancement here and below:

Suggested change
return 1;
return result;

Copy link
Contributor Author

@idubinov idubinov Jun 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ZE_RESULT_SUCCESS is not equal to test's success return code. May be in current implementation both of them are equal 0, but not in general.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe print this result value to output for the future easier debugging session, or return it in other way?

}

zeDeviceGetProperties(zedev, &device_properties);
std::stringstream uuid_l0;
for (int i = 0; i < ZE_MAX_DEVICE_UUID_SIZE; ++i)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
using namespace sycl;

int main() {
// Initializing Level Zero driver is required if this test is linked
// statically with Level Zero loader, otherwise the driver will not be initialized.
ze_result_t result = zeInit(ZE_INIT_FLAG_GPU_ONLY);
assert(result == ZE_RESULT_SUCCESS && "zeInit failed");

queue Queue;
device Dev = Queue.get_device();
bool Result;
Expand Down
8 changes: 8 additions & 0 deletions sycl/test-e2e/Basic/buffer/buffer_create.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@
using namespace sycl;

int main() {
// Initializing Level Zero driver is required if this test is linked
// statically with Level Zero loader, otherwise the driver will not be initialized.
ze_result_t result = zeInit(ZE_INIT_FLAG_GPU_ONLY);
if (result != ZE_RESULT_SUCCESS) {
std::cout << "zeInit failed" << std::endl;
return 1;
}

constexpr int Size = 100;
queue Queue;
auto D = Queue.get_device();
Expand Down
6 changes: 3 additions & 3 deletions sycl/test-e2e/Basic/interop/get_native_ze.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ constexpr auto BE = sycl::backend::ext_oneapi_level_zero;
class TestKernel;

int main() {
// Initialize Level Zero driver is required if this test is linked
// statically with Level Zero loader, the driver will not be init otherwise.
// Initializing Level Zero driver is required if this test is linked
// statically with Level Zero loader, otherwise the driver will not be initialized.
ze_result_t result = zeInit(ZE_INIT_FLAG_GPU_ONLY);
if (result != ZE_RESULT_SUCCESS) {
std::cout << "zeInit failed\n";
std::cout << "zeInit failed" << std::endl;
return 1;
}

Expand Down
8 changes: 8 additions & 0 deletions sycl/test-e2e/Basic/interop/make_kernel_subdevice_l0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ ze_kernel_handle_t create_kernel(ze_module_handle_t module,
}

int main() {
// Initializing Level Zero driver is required if this test is linked
// statically with Level Zero loader, otherwise the driver will not be initialized.
ze_result_t result = zeInit(ZE_INIT_FLAG_GPU_ONLY);
if (result != ZE_RESULT_SUCCESS) {
std::cout << "zeInit failed" << std::endl;
return 1;
}

device D{gpu_selector_v};

try {
Expand Down
4 changes: 3 additions & 1 deletion sycl/test-e2e/Basic/interop/ze_context_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ int main(int argc, char *argv[]) {
int level0DriverIndex = 0;
int level0DeviceIndex = 0;

zeInit(0);
ze_result_t result = zeInit(0);
assert(result == ZE_RESULT_SUCCESS);

uint32_t level0NumDrivers = 0;
zeDriverGet(&level0NumDrivers, nullptr);

Expand Down
5 changes: 5 additions & 0 deletions sycl/test-e2e/DeviceImageBackendContent/L0_interop_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ extern "C" SYCL_EXT_ONEAPI_FUNCTION_PROPERTY(
}

int main() {
// Initializing Level Zero driver is required if this test is linked
// statically with Level Zero loader, otherwise the driver will not be initialized.
ze_result_t result = zeInit(ZE_INIT_FLAG_GPU_ONLY);
assert(result == ZE_RESULT_SUCCESS);

sycl::queue q;
sycl::context ctxt = q.get_context();
sycl::device d = ctxt.get_devices()[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ bool is_discrete(const device &Device) {
}

int main() {
// Initialize Level Zero driver is required if this test is linked
// statically with Level Zero loader, the driver will not be init otherwise.
// Initializing Level Zero driver is required if this test is linked
// statically with Level Zero loader, otherwise the driver will not be initialized.
ze_result_t result = zeInit(ZE_INIT_FLAG_GPU_ONLY);
if (result != ZE_RESULT_SUCCESS) {
std::cout << "zeInit failed\n";
std::cout << "zeInit failed" << std::endl;
return 1;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ int main(int, char **argv) {
return 0;
}

// Initialize Level Zero driver is required if this test is linked
// statically with Level Zero loader, the driver will not be init otherwise.
// Initializing Level Zero driver is required if this test is linked
// statically with Level Zero loader, otherwise the driver will not be initialized.
ze_result_t result = zeInit(ZE_INIT_FLAG_GPU_ONLY);
if (result != ZE_RESULT_SUCCESS) {
std::cout << "zeInit failed\n";
std::cout << "zeInit failed" << std::endl;
return 1;
}

Expand Down
6 changes: 3 additions & 3 deletions sycl/test-e2e/Graph/NativeCommand/level-zero_usm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ namespace exp_ext = sycl::ext::oneapi::experimental;
using namespace sycl;

int main() {
// Initialize Level Zero driver is required if this test is linked
// statically with Level Zero loader, the driver will not be init otherwise.
// Initializing Level Zero driver is required if this test is linked
// statically with Level Zero loader, otherwise the driver will not be initialized.
ze_result_t result = zeInit(ZE_INIT_FLAG_GPU_ONLY);
if (result != ZE_RESULT_SUCCESS) {
std::cout << "zeInit failed\n";
std::cout << "zeInit failed" << std::endl;
return 1;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ namespace exp_ext = sycl::ext::oneapi::experimental;
using namespace sycl;

int main() {
// Initialize Level Zero driver is required if this test is linked
// statically with Level Zero loader, the driver will not be init otherwise.
// Initializing Level Zero driver is required if this test is linked
// statically with Level Zero loader, otherwise the driver will not be initialized.
ze_result_t result = zeInit(ZE_INIT_FLAG_GPU_ONLY);
if (result != ZE_RESULT_SUCCESS) {
std::cout << "zeInit failed\n";
std::cout << "zeInit failed" << std::endl;
return 1;
}

Expand Down
8 changes: 8 additions & 0 deletions sycl/test-e2e/Regression/cache_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,14 @@ int queryFromNativeHandle(std::vector<sycl::platform> *platform_list,
}

int main() {
// Initializing Level Zero driver is required if this test is linked
// statically with Level Zero loader, otherwise the driver will not be initialized.
ze_result_t result = zeInit(ZE_INIT_FLAG_GPU_ONLY);
if (result != ZE_RESULT_SUCCESS) {
std::cout << "zeInit failed" << std::endl;
return 1;
}

int failures = 0;

// Query for a list of all of the available platforms and devices.
Expand Down
Loading