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 4 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
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);
// Initialize Level Zero driver is required if this test is linked
// statically with Level Zero loader, the driver will not be init otherwise.
Comment on lines +64 to +65
Copy link
Contributor

Choose a reason for hiding this comment

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

small nit here and below in other tests:

Suggested change
// 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(0);
assert(result == ZE_RESULT_SUCCESS);

uint32_t driverCount = 0;
assert(zeDriverGet(&driverCount, nullptr) == 0);
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;

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

Choose a reason for hiding this comment

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

nit here and in other tests below:

Suggested change
std::cout << "zeInit failed\n";
std::cerr << "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,14 @@
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.
ze_result_t result = zeInit(ZE_INIT_FLAG_GPU_ONLY);
if (result != ZE_RESULT_SUCCESS) {
std::cout << "zeInit failed\n";
Copy link
Contributor

Choose a reason for hiding this comment

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

This test use asserts, so to align with it:

Suggested change
std::cout << "zeInit failed\n";
assert((result == ZE_RESULT_SUCCESS) && "zeInit failed");

return 1;
}

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

constexpr int Size = 100;
queue Queue;
auto D = Queue.get_device();
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() {
// Initialize Level Zero driver is required if this test is linked
// statically with Level Zero loader, the driver will not be init otherwise.
ze_result_t result = zeInit(ZE_INIT_FLAG_GPU_ONLY);
if (result != ZE_RESULT_SUCCESS) {
std::cout << "zeInit failed\n";
return 1;
}

device D{gpu_selector_v};

try {
Expand Down
8 changes: 8 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,14 @@ extern "C" SYCL_EXT_ONEAPI_FUNCTION_PROPERTY(
}

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.
ze_result_t result = zeInit(ZE_INIT_FLAG_GPU_ONLY);
if (result != ZE_RESULT_SUCCESS) {
std::cout << "zeInit failed\n";
Comment on lines +26 to +27
Copy link
Contributor

Choose a reason for hiding this comment

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

Better to use assert here as it is already used in this test

return 1;
}

sycl::queue q;
sycl::context ctxt = q.get_context();
sycl::device d = ctxt.get_devices()[0];
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() {
// Initialize Level Zero driver is required if this test is linked
// statically with Level Zero loader, the driver will not be init otherwise.
ze_result_t result = zeInit(ZE_INIT_FLAG_GPU_ONLY);
if (result != ZE_RESULT_SUCCESS) {
std::cout << "zeInit failed\n";
return 1;
}

int failures = 0;

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