Skip to content

Commit c141f9d

Browse files
committed
address review
1 parent b859179 commit c141f9d

File tree

5 files changed

+12
-16
lines changed

5 files changed

+12
-16
lines changed

offload/plugins-nextgen/level_zero/include/AsyncQueue.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace plugin {
2424

2525
/// Abstract queue that supports asynchronous command submission
2626
struct AsyncQueueTy {
27-
/// List of events attahced to submitted commands
27+
/// List of events attached to submitted commands
2828
llvm::SmallVector<ze_event_handle_t> WaitEvents;
2929
/// Pending staging buffer to host copies
3030
llvm::SmallVector<std::tuple<void *, void *, size_t>> H2MList;

offload/plugins-nextgen/level_zero/include/L0Defs.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ enum class AllocOptionTy : int32_t {
3030
/// Host runtime routines being used
3131
extern "C" {
3232
LIBOMP_DECL(int, omp_get_max_teams(void));
33-
LIBOMP_DECL(int, omp_get_thread_limit(void));
3433
LIBOMP_DECL(int, omp_get_teams_thread_limit(void));
35-
LIBOMP_DECL(double, omp_get_wtime(void));
3634
} // extern "C"
3735

3836
#ifndef EXTRACT_BITS
@@ -69,7 +67,7 @@ static Error Plugin::check(int32_t Code, const char *ErrFmt, ArgsTy... Args) {
6967
}
7068

7169
#define L0_UNIMPLEMENTED_ERR \
72-
return Plugin::error(ErrorCode::UNIMPLEMENTED, "%s not implemented yet\n", \
70+
return Plugin::error(ErrorCode::UNIMPLEMENTED, "%s not implemented yet", \
7371
__func__);
7472

7573
} // namespace llvm::omp::target::plugin

offload/plugins-nextgen/level_zero/include/L0Options.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ struct L0OptionsTy {
128128
/// devices and whether immediate command list is fully enabled.
129129
CommandModeTy CommandMode = CommandModeTy::Async;
130130

131+
// Controlso if we need to reduce available HW threads. We need this adjustment
132+
// on XeHPG when Level Zero debug is enabled (ZET_ENABLE_PROGRAM_DEBUGGING=1).
133+
bool ZeDebugEnabled = false;
134+
131135
bool Init = false; // have the options already been processed
132136

133137
// Allocator for long-lived allocations (e.g. spec constants)

offload/plugins-nextgen/level_zero/src/L0Kernel.cpp

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ static std::tuple<int32_t, int32_t> readTeamsThreadLimit() {
6161
int32_t ThreadLimit;
6262
ThreadLimit = omp_get_teams_thread_limit();
6363
DP("omp_get_teams_thread_limit() returned %" PRId32 "\n", ThreadLimit);
64-
// omp_get_thread_limit() would return INT_MAX by default.
64+
// omp_get_teams_thread_limit() would return INT_MAX by default.
6565
// NOTE: Windows.h defines max() macro, so we have to guard
6666
// the call with parentheses.
6767
ThreadLimit =
@@ -406,21 +406,12 @@ int32_t L0KernelTy::getGroupsShape(L0DeviceTy &Device, int32_t NumTeams,
406406
const auto DeviceId = Device.getDeviceId();
407407
const auto &KernelPR = getProperties();
408408

409-
// Detect if we need to reduce available HW threads. We need this adjustment
410-
// on XeHPG when L0 debug is enabled (ZET_ENABLE_PROGRAM_DEBUGGING=1).
411-
static std::once_flag OnceFlag;
412-
static bool ZeDebugEnabled = false;
413-
std::call_once(OnceFlag, []() {
414-
const char *EnvVal = std::getenv("ZET_ENABLE_PROGRAM_DEBUGGING");
415-
if (EnvVal && std::atoi(EnvVal) == 1)
416-
ZeDebugEnabled = true;
417-
});
418-
419409
// Read the most recent global thread limit and max teams.
420410
auto [NumTeamsICV, ThreadLimitICV] = readTeamsThreadLimit();
421411

422412
bool IsXeHPG = Device.isDeviceArch(DeviceArchTy::DeviceArch_XeHPG);
423-
bool HalfNumThreads = ZeDebugEnabled && IsXeHPG;
413+
bool HalfNumThreads =
414+
LevelZeroPluginTy::getOptions().ZeDebugEnabled && IsXeHPG;
424415
uint32_t KernelWidth = KernelPR.Width;
425416
uint32_t SIMDWidth = KernelPR.SIMDWidth;
426417
INFO(OMP_INFOTYPE_PLUGIN_KERNEL, DeviceId,

offload/plugins-nextgen/level_zero/src/L0Options.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,9 @@ void L0OptionsTy::processEnvironmentVars() {
172172
INVALID_OPTION(LIBOMPTARGET_LEVEL_ZERO_COMMAND_MODE,
173173
CommandModeVar.get().c_str());
174174
}
175+
176+
// Detect if we need to enable compatibility with Level Zero debug mode.
177+
ZeDebugEnabled = BoolEnvar("ZET_ENABLE_PROGRAM_DEBUGGING", false);
175178
}
176179

177180
} // namespace llvm::omp::target::plugin

0 commit comments

Comments
 (0)