Skip to content

Commit de1477c

Browse files
Addressed Pull-Request Comments
Removed unnecessary lambda function from PiPlatformsGet.
1 parent bb121fc commit de1477c

File tree

1 file changed

+14
-20
lines changed

1 file changed

+14
-20
lines changed

sycl/plugins/level_zero/pi_level_zero.cpp

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -664,23 +664,17 @@ pi_result piPlatformsGet(pi_uint32 NumEntries, pi_platform *Platforms,
664664

665665
std::lock_guard<std::mutex> Lock(*PiPlatformsCacheMutex);
666666
if (!PiPlatformCachePopulated) {
667-
// We will retrieve the Max CommandList Cache in this lamda function so that
668-
// it only has to be executed once
669-
static pi_uint32 CommandListCacheSizeValue = ([] {
670-
const char *CommandListCacheSize =
671-
std::getenv("SYCL_PI_LEVEL0_MAX_COMMAND_LIST_CACHE");
672-
pi_uint32 CommandListCacheSizeValue;
673-
try {
674-
CommandListCacheSizeValue =
675-
CommandListCacheSize ? std::stoi(CommandListCacheSize) : 20000;
676-
} catch (std::exception const &) {
677-
zePrint(
678-
"SYCL_PI_LEVEL0_MAX_COMMAND_LIST_CACHE: invalid value provided, "
679-
"default set.\n");
680-
CommandListCacheSizeValue = 20000;
681-
}
682-
return CommandListCacheSizeValue;
683-
})();
667+
const char *CommandListCacheSize =
668+
std::getenv("SYCL_PI_LEVEL0_MAX_COMMAND_LIST_CACHE");
669+
pi_uint32 CommandListCacheSizeValue;
670+
try {
671+
CommandListCacheSizeValue =
672+
CommandListCacheSize ? std::stoi(CommandListCacheSize) : 20000;
673+
} catch (std::exception const &) {
674+
zePrint("SYCL_PI_LEVEL0_MAX_COMMAND_LIST_CACHE: invalid value provided, "
675+
"default set.\n");
676+
CommandListCacheSizeValue = 20000;
677+
}
684678

685679
try {
686680

@@ -821,8 +815,8 @@ pi_result piextPlatformCreateWithNativeHandle(pi_native_handle NativeHandle,
821815
}
822816

823817
if (NumPlatforms) {
824-
std::vector<pi_platform> PlatformCache(NumPlatforms);
825-
Res = piPlatformsGet(NumPlatforms, PlatformCache.data(), nullptr);
818+
std::vector<pi_platform> Platforms(NumPlatforms);
819+
Res = piPlatformsGet(NumPlatforms, Platforms.data(), nullptr);
826820
if (Res != PI_SUCCESS) {
827821
return Res;
828822
}
@@ -832,7 +826,7 @@ pi_result piextPlatformCreateWithNativeHandle(pi_native_handle NativeHandle,
832826
// of the Level Zero drivers when we initialized the platform cache, so the
833827
// "NativeHandle" must already be in the cache. If it is not, this must not
834828
// be a valid Level Zero driver.
835-
for (const pi_platform &CachedPlatform : PlatformCache) {
829+
for (const pi_platform &CachedPlatform : Platforms) {
836830
if (CachedPlatform->ZeDriver == ZeDriver) {
837831
*Platform = CachedPlatform;
838832
return PI_SUCCESS;

0 commit comments

Comments
 (0)