Skip to content

Commit 1a0d7f1

Browse files
[SYCL] Call getenv/stoi only once (#7308)
Signed-off-by: Sergey V Maslov <[email protected]>
1 parent ab2a42c commit 1a0d7f1

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

sycl/plugins/level_zero/pi_level_zero.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6913,6 +6913,13 @@ pi_result piEnqueueMemBufferCopyRect(
69136913

69146914
} // extern "C"
69156915

6916+
// Default to using compute engine for fill operation, but allow to
6917+
// override this with an environment variable.
6918+
static bool PreferCopyEngine = [] {
6919+
const char *Env = std::getenv("SYCL_PI_LEVEL_ZERO_USE_COPY_ENGINE_FOR_FILL");
6920+
return Env ? std::stoi(Env) != 0 : false;
6921+
}();
6922+
69166923
// PI interfaces must have queue's and buffer's mutexes locked on entry.
69176924
static pi_result
69186925
enqueueMemFillHelper(pi_command_type CommandType, pi_queue Queue, void *Ptr,
@@ -6926,13 +6933,6 @@ enqueueMemFillHelper(pi_command_type CommandType, pi_queue Queue, void *Ptr,
69266933

69276934
auto &Device = Queue->Device;
69286935

6929-
// Default to using compute engine for fill operation, but allow to
6930-
// override this with an environment variable.
6931-
const char *PreferCopyEngineEnv =
6932-
std::getenv("SYCL_PI_LEVEL_ZERO_USE_COPY_ENGINE_FOR_FILL");
6933-
bool PreferCopyEngine =
6934-
PreferCopyEngineEnv ? std::stoi(PreferCopyEngineEnv) != 0 : false;
6935-
69366936
// Make sure that pattern size matches the capability of the copy queues.
69376937
// Check both main and link groups as we don't known which one will be used.
69386938
//

0 commit comments

Comments
 (0)