diff --git a/sycl/doc/EnvironmentVariables.md b/sycl/doc/EnvironmentVariables.md index cb9446ff3de11..2fd2acf037367 100644 --- a/sycl/doc/EnvironmentVariables.md +++ b/sycl/doc/EnvironmentVariables.md @@ -32,6 +32,7 @@ subject to change. Do not rely on these variables in production code. | `SYCL_PI_LEVEL_ZERO_BATCH_SIZE` | Integer | Sets a preferred number of commands to batch into a command list before executing the command list. A value of 0 causes the batch size to be adjusted dynamically. A value greater than 0 specifies fixed size batching, with the batch size set to the specified value. The default is 0. | | `SYCL_PI_LEVEL_ZERO_FILTER_EVENT_WAIT_LIST` | Integer | When set to 0, disables filtering of signaled events from wait lists when using the Level Zero backend. The default is 1. | | `SYCL_PI_LEVEL_ZERO_USE_COPY_ENGINE` | Integer | Allows the use of copy engine, if available in the device, in Level Zero plugin to transfer SYCL buffer or image data between the host and/or device(s) and to fill SYCL buffer or image data in device or shared memory. The default is 1. | +| `SYCL_PI_LEVEL_ZERO_USE_COPY_ENGINE_FOR_D2D_COPY` (experimental) | Integer | Allows the use of copy engine, if available in the device, in Level Zero plugin for device to device copy operations. The default is 0. This option is experimental and will be removed once heuristics are added to make a decision about use of copy engine for device to device copy operations. | | `SYCL_PI_LEVEL_ZERO_TRACK_INDIRECT_ACCESS_MEMORY` | Any(\*) | Enable support of the kernels with indirect access and corresponding deferred release of memory allocations in the Level Zero plugin. | | `SYCL_PARALLEL_FOR_RANGE_ROUNDING_TRACE` | Any(\*) | Enables tracing of `parallel_for` invocations with rounded-up ranges. | | `SYCL_DISABLE_PARALLEL_FOR_RANGE_ROUNDING` | Any(\*) | Disables automatic rounding-up of `parallel_for` invocation ranges. | diff --git a/sycl/plugins/level_zero/pi_level_zero.cpp b/sycl/plugins/level_zero/pi_level_zero.cpp index ea06b94c0aee8..b1dbc3317ac48 100644 --- a/sycl/plugins/level_zero/pi_level_zero.cpp +++ b/sycl/plugins/level_zero/pi_level_zero.cpp @@ -46,6 +46,14 @@ static const pi_uint32 ZeSerialize = [] { return SerializeModeValue; }(); +// This is an experimental option to test performance of device to device copy +// operations on copy engines (versus compute engine) +static const bool UseCopyEngineForD2DCopy = [] { + const char *CopyEngineForD2DCopy = + std::getenv("SYCL_PI_LEVEL_ZERO_USE_COPY_ENGINE_FOR_D2D_COPY"); + return (CopyEngineForD2DCopy && (std::stoi(CopyEngineForD2DCopy) != 0)); +}(); + static const bool CopyEngineRequested = [] { const char *CopyEngine = std::getenv("SYCL_PI_LEVEL_ZERO_USE_COPY_ENGINE"); bool UseCopyEngine = (!CopyEngine || (std::stoi(CopyEngine) != 0)); @@ -5034,6 +5042,10 @@ pi_result piEnqueueMemBufferCopy(pi_queue Queue, pi_mem SrcBuffer, // Copy engine is preferred only for host to device transfer. // Device to device transfers run faster on compute engines. bool PreferCopyEngine = (SrcBuffer->OnHost || DstBuffer->OnHost); + + // Temporary option added to use copy engine for D2D copy + PreferCopyEngine |= UseCopyEngineForD2DCopy; + return enqueueMemCopyHelper( PI_COMMAND_TYPE_MEM_BUFFER_COPY, Queue, pi_cast(DstBuffer->getZeHandle()) + DstOffset, @@ -6281,6 +6293,10 @@ pi_result piextUSMEnqueueMemcpy(pi_queue Queue, pi_bool Blocking, void *DstPtr, // (versus compute engine). bool PreferCopyEngine = !IsDevicePointer(Queue->Context, SrcPtr) || !IsDevicePointer(Queue->Context, DstPtr); + + // Temporary option added to use copy engine for D2D copy + PreferCopyEngine |= UseCopyEngineForD2DCopy; + return enqueueMemCopyHelper( // TODO: do we need a new command type for this? PI_COMMAND_TYPE_MEM_BUFFER_COPY, Queue, DstPtr, Blocking, Size, SrcPtr,