Skip to content

Commit c36c2bf

Browse files
author
Jaime Arteaga
committed
Change env var to UR_L0_USE_OPTIMIZED_32BIT_ACCESS
This is closer to the actual functionality being selected, and also aligns with having large allocations by default. Signed-off-by: Jaime Arteaga <[email protected]>
1 parent 748b234 commit c36c2bf

File tree

4 files changed

+19
-14
lines changed

4 files changed

+19
-14
lines changed

source/adapters/level_zero/device.cpp

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(
267267
return ReturnValue(uint32_t{64});
268268
}
269269
case UR_DEVICE_INFO_MAX_MEM_ALLOC_SIZE:
270-
// if using large allocations, then return total size in the device.
271-
// if not, then return L0's maxMemAllocSize.
272-
if (Device->useLargeAllocations()) {
270+
// if not optimized for 32-bit access, return total memory size.
271+
// otherwise, return only maximum allocatable size.
272+
if (Device->useOptimized32bitAccess() == 0) {
273273
return ReturnValue(uint64_t{getGlobalMemSize(Device)});
274274
} else {
275275
return ReturnValue(uint64_t{Device->ZeDeviceProperties->maxMemAllocSize});
@@ -910,15 +910,20 @@ ur_device_handle_t_::useImmediateCommandLists() {
910910
}
911911
}
912912

913-
bool ur_device_handle_t_::useLargeAllocations() {
914-
static const bool UseLargeAllocations = [this] {
915-
const char *UrRet = std::getenv("UR_L0_ALLOW_LARGE_ALLOCATIONS");
913+
int32_t ur_device_handle_t_::useOptimized32bitAccess() {
914+
static const int32_t Optimize32bitAccessMode = [this] {
915+
// If device is Intel(R) Data Center GPU Max,
916+
// use default provided by L0 driver.
917+
// TODO: Use IP versioning to select based on range of devices
918+
if (this->isPVC())
919+
return -1;
920+
const char *UrRet = std::getenv("UR_L0_USE_OPTIMIZED_32BIT_ACCESS");
916921
if (!UrRet)
917-
return (this->isPVC() ? true : false);
918-
return std::atoi(UrRet) != 0;
922+
return 0;
923+
return std::atoi(UrRet);
919924
}();
920925

921-
return UseLargeAllocations;
926+
return Optimize32bitAccessMode;
922927
}
923928

924929
ur_result_t ur_device_handle_t_::initialize(int SubSubDeviceOrdinal,

source/adapters/level_zero/device.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ struct ur_device_handle_t_ : _ur_object {
155155
// provide support for only one, like for Intel(R)
156156
// Data Center GPU Max, for which L0 driver only
157157
// supports stateless.
158-
bool useLargeAllocations();
158+
int32_t useOptimized32bitAccess();
159159

160160
bool isSubDevice() { return RootDevice != nullptr; }
161161

source/adapters/level_zero/program.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramBuildExp(
161161
ZeBuildOptions += pOptions;
162162
}
163163

164-
if (phDevices[0]->useLargeAllocations()) {
164+
if (phDevices[0]->useOptimized32bitAccess() == 0) {
165165
ZeBuildOptions += " -ze-opt-greater-than-4GB-buffer-required";
166166
}
167167

@@ -256,7 +256,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramCompile(
256256
// ze-opt-greater-than-4GB-buffer-required to disable
257257
// stateful optimizations and be able to use larger than
258258
// 4GB allocations on these kernels.
259-
if (Context->Devices[0]->useLargeAllocations()) {
259+
if (Context->Devices[0]->useOptimized32bitAccess() == 0) {
260260
Program->BuildFlags += " -ze-opt-greater-than-4GB-buffer-required";
261261
}
262262
}

source/adapters/level_zero/usm.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,11 @@ static ur_result_t USMDeviceAllocImpl(void **ResultPtr,
178178
ZeDesc.flags = 0;
179179
ZeDesc.ordinal = 0;
180180

181-
ZeStruct<ze_relaxed_allocation_limits_exp_desc_t> RelaxedDesc;
182-
if (Device->useLargeAllocations() &&
181+
if (Device->useOptimized32bitAccess() == 0 &&
183182
(Size > Device->ZeDeviceProperties->maxMemAllocSize)) {
184183
// Tell Level-Zero to accept Size > maxMemAllocSize if
185184
// large allocations are used.
185+
ZeStruct<ze_relaxed_allocation_limits_exp_desc_t> RelaxedDesc;
186186
RelaxedDesc.flags = ZE_RELAXED_ALLOCATION_LIMITS_EXP_FLAG_MAX_SIZE;
187187
ZeDesc.pNext = &RelaxedDesc;
188188
}

0 commit comments

Comments
 (0)