Skip to content

call getenv/stoi only once #7308

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions sycl/plugins/level_zero/pi_level_zero.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6913,6 +6913,13 @@ 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,
Expand All @@ -6926,13 +6933,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.
//
Expand Down