Files
compute-runtime/shared/source/utilities/wait_util.h
Zbigniew Zdanowicz 97505aebb6 Change default number of iterations in wait function
Related-To: NEO-4759

Signed-off-by: Zbigniew Zdanowicz <zbigniew.zdanowicz@intel.com>
2021-04-01 13:09:08 +02:00

38 lines
697 B
C++

/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "shared/source/utilities/cpuintrinsics.h"
#include <cstdint>
#include <thread>
namespace NEO {
namespace WaitUtils {
constexpr uint32_t defaultWaitCount = 1u;
extern uint32_t waitCount;
inline bool waitFunction(volatile uint32_t *pollAddress, uint32_t expectedValue) {
for (uint32_t i = 0; i < waitCount; i++) {
CpuIntrinsics::pause();
}
if (pollAddress != nullptr) {
if (*pollAddress >= expectedValue) {
return true;
}
}
std::this_thread::yield();
return false;
}
void init();
} // namespace WaitUtils
} // namespace NEO