Use wait utils while waiting for timestamps

Signed-off-by: Lukasz Jobczyk <lukasz.jobczyk@intel.com>
This commit is contained in:
Lukasz Jobczyk
2021-12-01 16:37:46 +00:00
committed by Compute-Runtime-Automation
parent 4d433d8674
commit 63116e4100
12 changed files with 122 additions and 32 deletions

View File

@@ -978,34 +978,6 @@ bool CommandQueue::isTimestampWaitEnabled() {
return enabled;
}
void CommandQueue::waitForTimestamps(uint32_t taskCount) {
if (isTimestampWaitEnabled()) {
bool waited = false;
for (const auto &timestamp : timestampPacketContainer->peekNodes()) {
for (uint32_t i = 0; i < timestamp->getPacketsUsed(); i++) {
while (timestamp->getContextEndValue(i) == 1) {
}
waited = true;
}
}
if (isOOQEnabled()) {
for (const auto &timestamp : deferredTimestampPackets->peekNodes()) {
for (uint32_t i = 0; i < timestamp->getPacketsUsed(); i++) {
while (timestamp->getContextEndValue(i) == 1) {
}
waited = true;
}
}
}
if (waited) {
getGpgpuCommandStreamReceiver().updateTagFromCpu(taskCount);
}
}
}
void CommandQueue::waitForAllEngines(bool blockedQueue, PrintfHandler *printfHandler, bool cleanTemporaryAllocationsList) {
if (blockedQueue) {
while (isQueueBlocked()) {

View File

@@ -216,7 +216,7 @@ class CommandQueue : public BaseObject<_cl_command_queue> {
bool isCompleted(uint32_t gpgpuTaskCount, CopyEngineState bcsState) const;
bool isTimestampWaitEnabled();
void waitForTimestamps(uint32_t taskCount);
virtual void waitForTimestamps(uint32_t taskCount) = 0;
MOCKABLE_VIRTUAL bool isQueueBlocked();

View File

@@ -450,6 +450,8 @@ class CommandQueueHw : public CommandQueue {
bool isCacheFlushCommand(uint32_t commandType) const override;
void waitForTimestamps(uint32_t taskCount) override;
MOCKABLE_VIRTUAL bool isCacheFlushForBcsRequired() const;
protected:

View File

@@ -6,6 +6,7 @@
*/
#include "shared/source/helpers/blit_commands_helper.h"
#include "shared/source/utilities/wait_util.h"
#include "opencl/source/built_ins/aux_translation_builtin.h"
#include "opencl/source/command_queue/enqueue_barrier.h"
@@ -134,6 +135,39 @@ bool CommandQueueHw<Family>::isCacheFlushForBcsRequired() const {
return true;
}
template <typename TSPacketType>
inline bool waitForTimestampsWithinContainer(TimestampPacketContainer *container) {
bool waited = false;
for (const auto &timestamp : container->peekNodes()) {
for (uint32_t i = 0; i < timestamp->getPacketsUsed(); i++) {
while (timestamp->getContextEndValue(i) == 1) {
WaitUtils::waitFunctionWithPredicate<const TSPacketType>(static_cast<TSPacketType const *>(timestamp->getContextEndAddress(i)), 1u, std::not_equal_to<TSPacketType>());
}
waited = true;
}
}
return waited;
}
template <typename Family>
void CommandQueueHw<Family>::waitForTimestamps(uint32_t taskCount) {
using TSPacketType = typename Family::TimestampPacketType;
if (isTimestampWaitEnabled()) {
bool waited = waitForTimestampsWithinContainer<TSPacketType>(timestampPacketContainer.get());
if (isOOQEnabled()) {
waited |= waitForTimestampsWithinContainer<TSPacketType>(deferredTimestampPackets.get());
}
if (waited) {
getGpgpuCommandStreamReceiver().updateTagFromCpu(taskCount);
}
}
}
template <typename Family>
void CommandQueueHw<Family>::setupBlitAuxTranslation(MultiDispatchInfo &multiDispatchInfo) {
multiDispatchInfo.begin()->dispatchInitCommands.registerMethod(