Skip to content

Commit 1833f44

Browse files
authored
[SYCL][UR] Make v2 L0 the default (L0) adapter for BMG and newer (#19333)
The loader will iterate over all adapters and call urAdapterGet() on them. The adapters will return numAdapters, which will always be 1 for CUDA, HIP, OpenCL and NativeCPU and either 1 or 0 for L0. If we are on BMG or newer, the v2 adapter will return 1, otherwise, the legacy will return 1. llvm-lit still respects sycl_devices: level_zero:gpu means legacy adapter and level_zero_v2:gpu means v2 adapter. This can be changed in later PRs.
1 parent 4f0afd5 commit 1833f44

File tree

10 files changed

+203
-182
lines changed

10 files changed

+203
-182
lines changed

sycl/test-e2e/Regression/reduction_resource_leak_dw.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
// REQUIRES: level_zero, level_zero_dev_kit
2-
// XFAIL: windows && run-mode
3-
// XFAIL-TRACKER: https://github.com/intel/llvm/issues/16418
42
//
53
// RUN: %{build} %level_zero_options -o %t.out
64
// RUN: %{l0_leak_check} %{run} %t.out 2>&1 | FileCheck %s

sycl/test-e2e/format.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,8 @@ def get_extra_env(sycl_devices):
333333
dev_features = test.config.sycl_dev_features[full_dev_name]
334334
if "level_zero_v2_adapter" in dev_features:
335335
expanded += " env UR_LOADER_USE_LEVEL_ZERO_V2=1"
336+
else:
337+
expanded += " env UR_LOADER_USE_LEVEL_ZERO_V2=0"
336338

337339
expanded += " ONEAPI_DEVICE_SELECTOR={} {}".format(
338340
parsed_dev_name, test.config.run_launcher

sycl/test-e2e/lit.cfg.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,8 @@ def get_sycl_ls_verbose(sycl_device, env):
962962

963963
if "v2" in full_name:
964964
env["UR_LOADER_ENABLE_LEVEL_ZERO_V2"] = "1"
965+
else:
966+
env["UR_LOADER_ENABLE_LEVEL_ZERO_V2"] = "0"
965967

966968
env["ONEAPI_DEVICE_SELECTOR"] = sycl_device
967969
if sycl_device.startswith("cuda:"):

unified-runtime/scripts/templates/ldrddi.cpp.mako

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,24 +51,21 @@ namespace ur_loader
5151
%if func_basename == "AdapterGet":
5252
auto context = getContext();
5353

54-
size_t adapterIndex = 0;
55-
if( nullptr != ${obj['params'][1]['name']} && ${obj['params'][0]['name']} !=0)
56-
{
57-
for( auto& platform : context->platforms )
58-
{
59-
if(platform.initStatus != ${X}_RESULT_SUCCESS)
60-
continue;
61-
platform.dditable.${th.get_table_name(n, tags, obj)}.${th.make_pfn_name(n, tags, obj)}( 1, &${obj['params'][1]['name']}[adapterIndex], nullptr );
62-
adapterIndex++;
63-
if (adapterIndex == NumEntries) {
64-
break;
65-
}
66-
}
54+
uint32_t numAdapters = 0;
55+
for (auto &platform : context->platforms) {
56+
if (platform.initStatus != ${X}_RESULT_SUCCESS)
57+
continue;
58+
59+
uint32_t adapter;
60+
ur_adapter_handle_t *adapterHandle = numAdapters < NumEntries ? &${obj['params'][1]['name']}[numAdapters] : nullptr;
61+
platform.dditable.${th.get_table_name(n, tags, obj)}.${th.make_pfn_name(n, tags, obj)}( 1, adapterHandle, &adapter );
62+
63+
numAdapters += adapter;
6764
}
6865

6966
if( ${obj['params'][2]['name']} != nullptr )
7067
{
71-
*${obj['params'][2]['name']} = static_cast<uint32_t>(context->platforms.size());
68+
*${obj['params'][2]['name']} = numAdapters;
7269
}
7370

7471
return ${X}_RESULT_SUCCESS;

0 commit comments

Comments
 (0)