2021-03-30 18:11:00 +00:00
|
|
|
/*
|
2025-03-07 10:32:00 +00:00
|
|
|
* Copyright (C) 2021-2025 Intel Corporation
|
2021-03-30 18:11:00 +00:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "shared/source/utilities/wait_util.h"
|
|
|
|
|
|
|
|
|
|
#include "shared/source/debug_settings/debug_settings_manager.h"
|
2023-12-14 13:12:20 +00:00
|
|
|
#include "shared/source/utilities/cpu_info.h"
|
2021-03-30 18:11:00 +00:00
|
|
|
|
|
|
|
|
namespace NEO {
|
|
|
|
|
|
|
|
|
|
namespace WaitUtils {
|
|
|
|
|
|
2025-03-21 08:27:46 +00:00
|
|
|
WaitpkgUse waitpkgUse = WaitpkgUse::uninitialized;
|
|
|
|
|
|
|
|
|
|
int64_t waitPkgThresholdInMicroSeconds = defaultWaitPkgThresholdInMicroSeconds;
|
2024-01-18 11:39:39 +00:00
|
|
|
uint64_t waitpkgCounterValue = defaultCounterValue;
|
|
|
|
|
uint32_t waitpkgControlValue = defaultControlValue;
|
2021-03-30 18:11:00 +00:00
|
|
|
uint32_t waitCount = defaultWaitCount;
|
|
|
|
|
|
2023-12-14 13:12:20 +00:00
|
|
|
#ifdef SUPPORTS_WAITPKG
|
|
|
|
|
bool waitpkgSupport = SUPPORTS_WAITPKG;
|
|
|
|
|
#else
|
|
|
|
|
bool waitpkgSupport = false;
|
|
|
|
|
#endif
|
|
|
|
|
|
2025-03-21 08:27:46 +00:00
|
|
|
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;
|
2025-03-07 10:32:00 +00:00
|
|
|
return;
|
2023-12-14 13:12:20 +00:00
|
|
|
}
|
2025-03-07 10:32:00 +00:00
|
|
|
|
|
|
|
|
if (debugManager.flags.EnableWaitpkg.get() != -1) {
|
2025-03-21 08:27:46 +00:00
|
|
|
inputWaitpkgUse = static_cast<WaitpkgUse>(debugManager.flags.EnableWaitpkg.get());
|
2025-03-07 10:32:00 +00:00
|
|
|
}
|
|
|
|
|
|
2025-03-21 08:27:46 +00:00
|
|
|
waitpkgUse = inputWaitpkgUse;
|
|
|
|
|
|
|
|
|
|
if (waitpkgUse == WaitpkgUse::umonitorAndUmwait) {
|
|
|
|
|
waitCount = 0u;
|
2023-12-14 13:12:20 +00:00
|
|
|
}
|
|
|
|
|
|
2025-03-21 08:27:46 +00:00
|
|
|
if (debugManager.flags.WaitpkgCounterValue.get() != -1) {
|
|
|
|
|
waitpkgCounterValue = debugManager.flags.WaitpkgCounterValue.get();
|
2023-12-14 13:12:20 +00:00
|
|
|
}
|
2025-03-07 10:32:00 +00:00
|
|
|
|
2025-03-21 08:27:46 +00:00
|
|
|
if (debugManager.flags.WaitpkgControlValue.get() != -1) {
|
|
|
|
|
waitpkgControlValue = debugManager.flags.WaitpkgControlValue.get();
|
2023-12-14 13:12:20 +00:00
|
|
|
}
|
|
|
|
|
|
2025-03-21 08:27:46 +00:00
|
|
|
if (debugManager.flags.WaitpkgThreshold.get() != -1) {
|
|
|
|
|
waitPkgThresholdInMicroSeconds = debugManager.flags.WaitpkgThreshold.get();
|
2021-03-30 18:11:00 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace WaitUtils
|
|
|
|
|
|
|
|
|
|
} // namespace NEO
|