Skip to content

Commit bd03e0d

Browse files
[SYCL][L0] Add an env var to control buffer migration in context with single root-device (#7178)
Changed the default to perform regular migration, as opposed to have single root-device allocation to serve all [sub-]devices. Signed-off-by: Sergey V Maslov <[email protected]> Signed-off-by: Sergey V Maslov <[email protected]>
1 parent dcbed11 commit bd03e0d

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

sycl/doc/EnvironmentVariables.md

100644100755
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ variables in production code.</span>
238238
| `SYCL_PI_LEVEL_ZERO_USE_IMMEDIATE_COMMANDLISTS` | Integer | When set to a positive value enables use of Level Zero immediate commandlists, which means there is no batching and all commands are immediately submitted for execution. Default is 0. Note: When immediate commandlist usage is enabled it is necessary to also set SYCL_PI_LEVEL_ZERO_DEVICE_SCOPE_EVENTS to either 0 or 1. |
239239
| `SYCL_PI_LEVEL_ZERO_USE_MULTIPLE_COMMANDLIST_BARRIERS` | Integer | When set to a positive value enables use of multiple Level Zero commandlists when submitting barriers. Default is 1. |
240240
| `SYCL_PI_LEVEL_ZERO_USE_COPY_ENGINE_FOR_FILL` | Integer | When set to a positive value enables use of a copy engine for memory fill operations. Default is 0. |
241+
| `SYCL_PI_LEVEL_ZERO_SINGLE_ROOT_DEVICE_BUFFER_MIGRATION` | Integer | When set to "0" tells to use single root-device allocation for all devices in a context where all devices have same root. Otherwise performs regular buffer migration. Default is 1. |
241242

242243
## Debugging variables for CUDA Plugin
243244

sycl/plugins/level_zero/pi_level_zero.cpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8812,10 +8812,29 @@ pi_result _pi_buffer::getZeHandle(char *&ZeHandle, access_mode_t AccessMode,
88128812
LastDeviceWithValidAllocation = Device;
88138813
return PI_SUCCESS;
88148814
}
8815+
// Reads user setting on how to deal with buffers in contexts where
8816+
// all devices have the same root-device. Returns "true" if the
8817+
// preference is to have allocate on each [sub-]device and migrate
8818+
// normally (copy) to other sub-devices as needed. Returns "false"
8819+
// if the preference is to have single root-device allocations
8820+
// serve the needs of all [sub-]devices, meaning potentially more
8821+
// cross-tile traffic.
8822+
//
8823+
static const bool SingleRootDeviceBufferMigration = [] {
8824+
const char *EnvStr =
8825+
std::getenv("SYCL_PI_LEVEL_ZERO_SINGLE_ROOT_DEVICE_BUFFER_MIGRATION");
8826+
if (EnvStr)
8827+
return (std::stoi(EnvStr) != 0);
8828+
// The default is to migrate normally, which may not always be the
8829+
// best option (depends on buffer access patterns), but is an
8830+
// overall win on the set of the available benchmarks.
8831+
return true;
8832+
}();
88158833

88168834
// Peform actual device allocation as needed.
88178835
if (!Allocation.ZeHandle) {
8818-
if (Context->SingleRootDevice && Context->SingleRootDevice != Device) {
8836+
if (!SingleRootDeviceBufferMigration && Context->SingleRootDevice &&
8837+
Context->SingleRootDevice != Device) {
88198838
// If all devices in the context are sub-devices of the same device
88208839
// then we reuse root-device allocation by all sub-devices in the
88218840
// context.

0 commit comments

Comments
 (0)