Files
compute-runtime/shared/source/utilities/wait_util.cpp
Lukasz Jobczyk 8a85a96ed2 feature: Add 3-level wait scheme with tpause intrinsic
Related-To: NEO-14336

Signed-off-by: Lukasz Jobczyk <lukasz.jobczyk@intel.com>
2025-03-21 12:12:57 +01:00

70 lines
1.8 KiB
C++

/*
* Copyright (C) 2021-2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/utilities/wait_util.h"
#include "shared/source/debug_settings/debug_settings_manager.h"
#include "shared/source/utilities/cpu_info.h"
namespace NEO {
namespace WaitUtils {
WaitpkgUse waitpkgUse = WaitpkgUse::uninitialized;
int64_t waitPkgThresholdInMicroSeconds = defaultWaitPkgThresholdInMicroSeconds;
uint64_t waitpkgCounterValue = defaultCounterValue;
uint32_t waitpkgControlValue = defaultControlValue;
uint32_t waitCount = defaultWaitCount;
#ifdef SUPPORTS_WAITPKG
bool waitpkgSupport = SUPPORTS_WAITPKG;
#else
bool waitpkgSupport = false;
#endif
void init(WaitpkgUse inputWaitpkgUse) {
if (debugManager.flags.WaitLoopCount.get() != -1) {
waitCount = debugManager.flags.WaitLoopCount.get();
}
if (waitpkgUse > WaitpkgUse::noUse) {
return;
}
if (!(waitpkgSupport && CpuInfo::getInstance().isFeatureSupported(CpuInfo::featureWaitPkg))) {
waitpkgUse = WaitpkgUse::noUse;
return;
}
if (debugManager.flags.EnableWaitpkg.get() != -1) {
inputWaitpkgUse = static_cast<WaitpkgUse>(debugManager.flags.EnableWaitpkg.get());
}
waitpkgUse = inputWaitpkgUse;
if (waitpkgUse == WaitpkgUse::umonitorAndUmwait) {
waitCount = 0u;
}
if (debugManager.flags.WaitpkgCounterValue.get() != -1) {
waitpkgCounterValue = debugManager.flags.WaitpkgCounterValue.get();
}
if (debugManager.flags.WaitpkgControlValue.get() != -1) {
waitpkgControlValue = debugManager.flags.WaitpkgControlValue.get();
}
if (debugManager.flags.WaitpkgThreshold.get() != -1) {
waitPkgThresholdInMicroSeconds = debugManager.flags.WaitpkgThreshold.get();
}
}
} // namespace WaitUtils
} // namespace NEO