From ec4e42c89124483a2ce252b9d78af0241b3dab01 Mon Sep 17 00:00:00 2001 From: smaslov-intel Date: Mon, 7 Nov 2022 11:20:38 -0800 Subject: [PATCH 1/2] call getenv/stoi only once --- sycl/plugins/level_zero/pi_level_zero.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/sycl/plugins/level_zero/pi_level_zero.cpp b/sycl/plugins/level_zero/pi_level_zero.cpp index 9a2997427890d..65dda02690202 100644 --- a/sycl/plugins/level_zero/pi_level_zero.cpp +++ b/sycl/plugins/level_zero/pi_level_zero.cpp @@ -6913,6 +6913,14 @@ pi_result piEnqueueMemBufferCopyRect( } // extern "C" +// Default to using compute engine for fill operation, but allow to +// override this with an environment variable. +static bool PreferCopyEngine = [] { + const char * Env = + std::getenv("SYCL_PI_LEVEL_ZERO_USE_COPY_ENGINE_FOR_FILL"); + return Env ? std::stoi(Env) != 0 : false; +}(); + // PI interfaces must have queue's and buffer's mutexes locked on entry. static pi_result enqueueMemFillHelper(pi_command_type CommandType, pi_queue Queue, void *Ptr, @@ -6926,13 +6934,6 @@ enqueueMemFillHelper(pi_command_type CommandType, pi_queue Queue, void *Ptr, auto &Device = Queue->Device; - // Default to using compute engine for fill operation, but allow to - // override this with an environment variable. - const char *PreferCopyEngineEnv = - std::getenv("SYCL_PI_LEVEL_ZERO_USE_COPY_ENGINE_FOR_FILL"); - bool PreferCopyEngine = - PreferCopyEngineEnv ? std::stoi(PreferCopyEngineEnv) != 0 : false; - // Make sure that pattern size matches the capability of the copy queues. // Check both main and link groups as we don't known which one will be used. // From b627fefeea71d095a1623f0b285b541f5324201f Mon Sep 17 00:00:00 2001 From: Sergey V Maslov Date: Mon, 7 Nov 2022 13:30:30 -0800 Subject: [PATCH 2/2] clang-format Signed-off-by: Sergey V Maslov --- sycl/plugins/level_zero/pi_level_zero.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sycl/plugins/level_zero/pi_level_zero.cpp b/sycl/plugins/level_zero/pi_level_zero.cpp index 65dda02690202..0fa38935a62ec 100644 --- a/sycl/plugins/level_zero/pi_level_zero.cpp +++ b/sycl/plugins/level_zero/pi_level_zero.cpp @@ -6916,8 +6916,7 @@ pi_result piEnqueueMemBufferCopyRect( // Default to using compute engine for fill operation, but allow to // override this with an environment variable. static bool PreferCopyEngine = [] { - const char * Env = - std::getenv("SYCL_PI_LEVEL_ZERO_USE_COPY_ENGINE_FOR_FILL"); + const char *Env = std::getenv("SYCL_PI_LEVEL_ZERO_USE_COPY_ENGINE_FOR_FILL"); return Env ? std::stoi(Env) != 0 : false; }();