mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-05 09:09:04 +08:00
Detect GPU hang in clWaitForEvents
This change: - moves NEO::WaitStatus to a separate file - enables detection of GPU hang in clWaitForEvents - adjusts most of blocking calls in CommandStreamReceiver to return WaitStatus - adds ULTs to cover the new code Related-To: NEO-6681 Signed-off-by: Patryk Wrobel <patryk.wrobel@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
f2e1361541
commit
7f729b7f89
@@ -229,19 +229,25 @@ bool CommandQueue::isCompleted(uint32_t gpgpuTaskCount, CopyEngineState bcsState
|
||||
return false;
|
||||
}
|
||||
|
||||
void CommandQueue::waitUntilComplete(uint32_t gpgpuTaskCountToWait, Range<CopyEngineState> copyEnginesToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep, bool cleanTemporaryAllocationList, bool skipWait) {
|
||||
WaitStatus CommandQueue::waitUntilComplete(uint32_t gpgpuTaskCountToWait, Range<CopyEngineState> copyEnginesToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep, bool cleanTemporaryAllocationList, bool skipWait) {
|
||||
WAIT_ENTER()
|
||||
|
||||
WaitStatus waitStatus{WaitStatus::Ready};
|
||||
|
||||
DBG_LOG(LogTaskCounts, __FUNCTION__, "Waiting for taskCount:", gpgpuTaskCountToWait);
|
||||
DBG_LOG(LogTaskCounts, __FUNCTION__, "Line: ", __LINE__, "Current taskCount:", getHwTag());
|
||||
|
||||
if (!skipWait) {
|
||||
bool forcePowerSavingMode = this->throttle == QueueThrottle::LOW;
|
||||
|
||||
getGpgpuCommandStreamReceiver().waitForTaskCountWithKmdNotifyFallback(gpgpuTaskCountToWait,
|
||||
flushStampToWait,
|
||||
useQuickKmdSleep,
|
||||
forcePowerSavingMode);
|
||||
waitStatus = getGpgpuCommandStreamReceiver().waitForTaskCountWithKmdNotifyFallback(gpgpuTaskCountToWait,
|
||||
flushStampToWait,
|
||||
useQuickKmdSleep,
|
||||
forcePowerSavingMode);
|
||||
if (waitStatus == WaitStatus::GpuHang) {
|
||||
return WaitStatus::GpuHang;
|
||||
}
|
||||
|
||||
DEBUG_BREAK_IF(getHwTag() < gpgpuTaskCountToWait);
|
||||
|
||||
if (gtpinIsGTPinInitialized()) {
|
||||
@@ -251,17 +257,25 @@ void CommandQueue::waitUntilComplete(uint32_t gpgpuTaskCountToWait, Range<CopyEn
|
||||
|
||||
for (const CopyEngineState ©Engine : copyEnginesToWait) {
|
||||
auto bcsCsr = getBcsCommandStreamReceiver(copyEngine.engineType);
|
||||
bcsCsr->waitForTaskCountWithKmdNotifyFallback(copyEngine.taskCount, 0, false, false);
|
||||
bcsCsr->waitForTaskCountAndCleanTemporaryAllocationList(copyEngine.taskCount);
|
||||
|
||||
waitStatus = bcsCsr->waitForTaskCountWithKmdNotifyFallback(copyEngine.taskCount, 0, false, false);
|
||||
if (waitStatus == WaitStatus::GpuHang) {
|
||||
return WaitStatus::GpuHang;
|
||||
}
|
||||
|
||||
waitStatus = bcsCsr->waitForTaskCountAndCleanTemporaryAllocationList(copyEngine.taskCount);
|
||||
if (waitStatus == WaitStatus::GpuHang) {
|
||||
return WaitStatus::GpuHang;
|
||||
}
|
||||
}
|
||||
|
||||
if (cleanTemporaryAllocationList) {
|
||||
getGpgpuCommandStreamReceiver().waitForTaskCountAndCleanTemporaryAllocationList(gpgpuTaskCountToWait);
|
||||
} else {
|
||||
getGpgpuCommandStreamReceiver().waitForTaskCount(gpgpuTaskCountToWait);
|
||||
}
|
||||
waitStatus = cleanTemporaryAllocationList
|
||||
? getGpgpuCommandStreamReceiver().waitForTaskCountAndCleanTemporaryAllocationList(gpgpuTaskCountToWait)
|
||||
: getGpgpuCommandStreamReceiver().waitForTaskCount(gpgpuTaskCountToWait);
|
||||
|
||||
WAIT_LEAVE()
|
||||
|
||||
return waitStatus;
|
||||
}
|
||||
|
||||
bool CommandQueue::isQueueBlocked() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -209,9 +209,9 @@ class CommandQueue : public BaseObject<_cl_command_queue> {
|
||||
|
||||
MOCKABLE_VIRTUAL bool isQueueBlocked();
|
||||
|
||||
MOCKABLE_VIRTUAL void waitUntilComplete(uint32_t gpgpuTaskCountToWait, Range<CopyEngineState> copyEnginesToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep, bool cleanTemporaryAllocationList, bool skipWait);
|
||||
MOCKABLE_VIRTUAL void waitUntilComplete(uint32_t gpgpuTaskCountToWait, Range<CopyEngineState> copyEnginesToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep) {
|
||||
this->waitUntilComplete(gpgpuTaskCountToWait, copyEnginesToWait, flushStampToWait, useQuickKmdSleep, true, false);
|
||||
MOCKABLE_VIRTUAL WaitStatus waitUntilComplete(uint32_t gpgpuTaskCountToWait, Range<CopyEngineState> copyEnginesToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep, bool cleanTemporaryAllocationList, bool skipWait);
|
||||
MOCKABLE_VIRTUAL WaitStatus waitUntilComplete(uint32_t gpgpuTaskCountToWait, Range<CopyEngineState> copyEnginesToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep) {
|
||||
return this->waitUntilComplete(gpgpuTaskCountToWait, copyEnginesToWait, flushStampToWait, useQuickKmdSleep, true, false);
|
||||
}
|
||||
MOCKABLE_VIRTUAL void waitForAllEngines(bool blockedQueue, PrintfHandler *printfHandler, bool cleanTemporaryAllocationsList);
|
||||
MOCKABLE_VIRTUAL void waitForAllEngines(bool blockedQueue, PrintfHandler *printfHandler) {
|
||||
@@ -223,7 +223,7 @@ class CommandQueue : public BaseObject<_cl_command_queue> {
|
||||
const cl_event *eventWaitList);
|
||||
|
||||
MOCKABLE_VIRTUAL CommandStreamReceiver &getGpgpuCommandStreamReceiver() const;
|
||||
CommandStreamReceiver *getBcsCommandStreamReceiver(aub_stream::EngineType bcsEngineType) const;
|
||||
MOCKABLE_VIRTUAL CommandStreamReceiver *getBcsCommandStreamReceiver(aub_stream::EngineType bcsEngineType) const;
|
||||
CommandStreamReceiver *getBcsForAuxTranslation() const;
|
||||
MOCKABLE_VIRTUAL CommandStreamReceiver &selectCsrForBuiltinOperation(const CsrSelectionArgs &args) const;
|
||||
Device &getDevice() const noexcept;
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
#include "opencl/source/helpers/hardware_commands_helper.h"
|
||||
#include "opencl/source/mem_obj/mem_obj.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
Event::Event(
|
||||
@@ -417,15 +419,18 @@ void Event::getBoundaryTimestampValues(TimestampPacketContainer *timestampContai
|
||||
}
|
||||
}
|
||||
|
||||
inline bool Event::wait(bool blocking, bool useQuickKmdSleep) {
|
||||
inline WaitStatus Event::wait(bool blocking, bool useQuickKmdSleep) {
|
||||
while (this->taskCount == CompletionStamp::notReady) {
|
||||
if (blocking == false) {
|
||||
return false;
|
||||
return WaitStatus::NotReady;
|
||||
}
|
||||
}
|
||||
|
||||
Range<CopyEngineState> states{&bcsState, bcsState.isValid() ? 1u : 0u};
|
||||
cmdQueue->waitUntilComplete(taskCount.load(), states, flushStamp->peekStamp(), useQuickKmdSleep);
|
||||
const auto waitStatus = cmdQueue->waitUntilComplete(taskCount.load(), states, flushStamp->peekStamp(), useQuickKmdSleep);
|
||||
if (waitStatus == WaitStatus::GpuHang) {
|
||||
return WaitStatus::GpuHang;
|
||||
}
|
||||
updateExecutionStatus();
|
||||
|
||||
DEBUG_BREAK_IF(this->taskLevel == CompletionStamp::notReady && this->executionStatus >= 0);
|
||||
@@ -433,7 +438,7 @@ inline bool Event::wait(bool blocking, bool useQuickKmdSleep) {
|
||||
auto *allocationStorage = cmdQueue->getGpgpuCommandStreamReceiver().getInternalAllocationStorage();
|
||||
allocationStorage->cleanAllocationList(this->taskCount, TEMPORARY_ALLOCATION);
|
||||
|
||||
return true;
|
||||
return WaitStatus::Ready;
|
||||
}
|
||||
|
||||
void Event::updateExecutionStatus() {
|
||||
@@ -630,16 +635,23 @@ cl_int Event::waitForEvents(cl_uint numEvents,
|
||||
// pointers to workerLists - for fast swap operations
|
||||
WorkerListT *currentlyPendingEvents = &workerList1;
|
||||
WorkerListT *pendingEventsLeft = &workerList2;
|
||||
WaitStatus eventWaitStatus = WaitStatus::NotReady;
|
||||
|
||||
while (currentlyPendingEvents->size() > 0) {
|
||||
for (auto &e : *currentlyPendingEvents) {
|
||||
Event *event = castToObjectOrAbort<Event>(e);
|
||||
for (auto current = currentlyPendingEvents->begin(), end = currentlyPendingEvents->end(); current != end; ++current) {
|
||||
Event *event = castToObjectOrAbort<Event>(*current);
|
||||
if (event->peekExecutionStatus() < CL_COMPLETE) {
|
||||
return CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST;
|
||||
}
|
||||
|
||||
if (event->wait(false, false) == false) {
|
||||
eventWaitStatus = event->wait(false, false);
|
||||
if (eventWaitStatus == WaitStatus::NotReady) {
|
||||
pendingEventsLeft->push_back(event);
|
||||
} else if (eventWaitStatus == WaitStatus::GpuHang) {
|
||||
setExecutionStatusToAbortedDueToGpuHang(pendingEventsLeft->begin(), pendingEventsLeft->end());
|
||||
setExecutionStatusToAbortedDueToGpuHang(current, end);
|
||||
|
||||
return CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -650,6 +662,13 @@ cl_int Event::waitForEvents(cl_uint numEvents,
|
||||
return CL_SUCCESS;
|
||||
}
|
||||
|
||||
inline void Event::setExecutionStatusToAbortedDueToGpuHang(cl_event *first, cl_event *last) {
|
||||
std::for_each(first, last, [](cl_event &e) {
|
||||
Event *event = castToObjectOrAbort<Event>(e);
|
||||
event->transitionExecutionStatus(executionAbortedDueToGpuHang);
|
||||
});
|
||||
}
|
||||
|
||||
uint32_t Event::getTaskLevel() {
|
||||
return taskLevel;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/source/command_stream/wait_status.h"
|
||||
#include "shared/source/helpers/flush_stamp.h"
|
||||
#include "shared/source/os_interface/os_time.h"
|
||||
#include "shared/source/os_interface/performance_counters.h"
|
||||
@@ -80,6 +81,7 @@ class Event : public BaseObject<_cl_event>, public IDNode<Event> {
|
||||
};
|
||||
|
||||
static const cl_ulong objectMagic = 0x80134213A43C981ALL;
|
||||
static constexpr cl_int executionAbortedDueToGpuHang = -777;
|
||||
|
||||
Event(CommandQueue *cmdQueue, cl_command_type cmdType,
|
||||
uint32_t taskLevel, uint32_t taskCount);
|
||||
@@ -206,9 +208,8 @@ class Event : public BaseObject<_cl_event>, public IDNode<Event> {
|
||||
// adds a callback (execution state change listener) to this event's list of callbacks
|
||||
void addCallback(Callback::ClbFuncT fn, cl_int type, void *data);
|
||||
|
||||
//returns true on success
|
||||
//if(blocking==false), will return with false instead of blocking while waiting for completion
|
||||
virtual bool wait(bool blocking, bool useQuickKmdSleep);
|
||||
//if(blocking==false), will return with WaitStatus::NotReady instead of blocking while waiting for completion
|
||||
virtual WaitStatus wait(bool blocking, bool useQuickKmdSleep);
|
||||
|
||||
bool isUserEvent() const {
|
||||
return (CL_COMMAND_USER == cmdType);
|
||||
@@ -347,6 +348,8 @@ class Event : public BaseObject<_cl_event>, public IDNode<Event> {
|
||||
void unblockEventsBlockedByThis(int32_t transitionStatus);
|
||||
void submitCommand(bool abortBlockedTasks);
|
||||
|
||||
static void setExecutionStatusToAbortedDueToGpuHang(cl_event *first, cl_event *last);
|
||||
|
||||
bool currentCmdQVirtualEvent;
|
||||
std::atomic<Command *> cmdToSubmit;
|
||||
std::atomic<Command *> submittedCmd;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -24,13 +24,13 @@ void UserEvent::updateExecutionStatus() {
|
||||
return;
|
||||
}
|
||||
|
||||
bool UserEvent::wait(bool blocking, bool useQuickKmdSleep) {
|
||||
WaitStatus UserEvent::wait(bool blocking, bool useQuickKmdSleep) {
|
||||
while (updateStatusAndCheckCompletion() == false) {
|
||||
if (blocking == false) {
|
||||
return false;
|
||||
return WaitStatus::NotReady;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return WaitStatus::Ready;
|
||||
}
|
||||
|
||||
uint32_t UserEvent::getTaskLevel() {
|
||||
@@ -53,16 +53,15 @@ VirtualEvent::VirtualEvent(CommandQueue *cmdQ, Context *ctx)
|
||||
}
|
||||
|
||||
void VirtualEvent::updateExecutionStatus() {
|
||||
;
|
||||
}
|
||||
|
||||
bool VirtualEvent::wait(bool blocking, bool useQuickKmdSleep) {
|
||||
WaitStatus VirtualEvent::wait(bool blocking, bool useQuickKmdSleep) {
|
||||
while (updateStatusAndCheckCompletion() == false) {
|
||||
if (blocking == false) {
|
||||
return false;
|
||||
return WaitStatus::NotReady;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return WaitStatus::Ready;
|
||||
}
|
||||
|
||||
uint32_t VirtualEvent::getTaskLevel() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -18,7 +18,7 @@ class UserEvent : public Event {
|
||||
|
||||
~UserEvent() override = default;
|
||||
|
||||
bool wait(bool blocking, bool useQuickKmdSleep) override;
|
||||
WaitStatus wait(bool blocking, bool useQuickKmdSleep) override;
|
||||
|
||||
void updateExecutionStatus() override;
|
||||
|
||||
@@ -33,7 +33,7 @@ class VirtualEvent : public Event {
|
||||
|
||||
~VirtualEvent() override = default;
|
||||
|
||||
bool wait(bool blocking, bool useQuickKmdSleep) override;
|
||||
WaitStatus wait(bool blocking, bool useQuickKmdSleep) override;
|
||||
|
||||
bool setStatus(cl_int status) override;
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/command_stream/wait_status.h"
|
||||
#include "shared/source/helpers/array_count.h"
|
||||
|
||||
#include "opencl/source/command_queue/command_queue.h"
|
||||
@@ -60,9 +61,9 @@ TEST_F(clEnqueueWaitForEventsTests, GivenProperParamsWhenClEnqueueWaitForEventsI
|
||||
MyEvent(Context *context)
|
||||
: UserEvent(context) {
|
||||
}
|
||||
bool wait(bool blocking, bool quickKmdSleep) override {
|
||||
WaitStatus wait(bool blocking, bool quickKmdSleep) override {
|
||||
wasWaitCalled = true;
|
||||
return true;
|
||||
return WaitStatus::Ready;
|
||||
};
|
||||
bool wasWaitCalled = false;
|
||||
};
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "shared/source/command_stream/command_stream_receiver.h"
|
||||
#include "shared/source/command_stream/wait_status.h"
|
||||
#include "shared/source/helpers/array_count.h"
|
||||
#include "shared/source/helpers/basic_math.h"
|
||||
#include "shared/source/helpers/engine_node_helper.h"
|
||||
@@ -903,9 +904,11 @@ struct WaitForQueueCompletionTests : public ::testing::Test {
|
||||
template <typename Family>
|
||||
struct MyCmdQueue : public CommandQueueHw<Family> {
|
||||
MyCmdQueue(Context *context, ClDevice *device) : CommandQueueHw<Family>(context, device, nullptr, false){};
|
||||
void waitUntilComplete(uint32_t gpgpuTaskCountToWait, Range<CopyEngineState> copyEnginesToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep, bool cleanTemporaryAllocationList, bool skipWait) override {
|
||||
WaitStatus waitUntilComplete(uint32_t gpgpuTaskCountToWait, Range<CopyEngineState> copyEnginesToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep, bool cleanTemporaryAllocationList, bool skipWait) override {
|
||||
requestedUseQuickKmdSleep = useQuickKmdSleep;
|
||||
waitUntilCompleteCounter++;
|
||||
|
||||
return WaitStatus::Ready;
|
||||
}
|
||||
bool isQueueBlocked() override {
|
||||
return false;
|
||||
@@ -957,16 +960,29 @@ class CommandStreamReceiverHwMock : public CommandStreamReceiverHw<GfxFamily> {
|
||||
uint32_t rootDeviceIndex,
|
||||
const DeviceBitfield deviceBitfield)
|
||||
: CommandStreamReceiverHw<GfxFamily>(executionEnvironment, rootDeviceIndex, deviceBitfield) {}
|
||||
bool wiatForTaskCountCalled = false;
|
||||
|
||||
WaitStatus waitForTaskCountWithKmdNotifyFallback(uint32_t taskCountToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep, bool forcePowerSavingMode) override {
|
||||
return WaitStatus::Ready;
|
||||
waitForTaskCountWithKmdNotifyFallbackCounter++;
|
||||
return waitForTaskCountWithKmdNotifyFallbackReturnValue;
|
||||
}
|
||||
|
||||
void waitForTaskCount(uint32_t requiredTaskCount) override {
|
||||
wiatForTaskCountCalled = true;
|
||||
return;
|
||||
WaitStatus waitForTaskCount(uint32_t requiredTaskCount) override {
|
||||
waitForTaskCountCalledCounter++;
|
||||
return waitForTaskCountReturnValue;
|
||||
}
|
||||
|
||||
WaitStatus waitForTaskCountAndCleanTemporaryAllocationList(uint32_t requiredTaskCount) override {
|
||||
waitForTaskCountAndCleanTemporaryAllocationListCalledCounter++;
|
||||
return waitForTaskCountAndCleanTemporaryAllocationListReturnValue;
|
||||
}
|
||||
|
||||
int waitForTaskCountCalledCounter{0};
|
||||
int waitForTaskCountWithKmdNotifyFallbackCounter{0};
|
||||
int waitForTaskCountAndCleanTemporaryAllocationListCalledCounter{0};
|
||||
|
||||
WaitStatus waitForTaskCountReturnValue{WaitStatus::Ready};
|
||||
WaitStatus waitForTaskCountWithKmdNotifyFallbackReturnValue{WaitStatus::Ready};
|
||||
WaitStatus waitForTaskCountAndCleanTemporaryAllocationListReturnValue{WaitStatus::Ready};
|
||||
};
|
||||
|
||||
struct WaitUntilCompletionTests : public ::testing::Test {
|
||||
@@ -976,6 +992,12 @@ struct WaitUntilCompletionTests : public ::testing::Test {
|
||||
using CommandQueue::gpgpuEngine;
|
||||
|
||||
MyCmdQueue(Context *context, ClDevice *device) : CommandQueueHw<Family>(context, device, nullptr, false){};
|
||||
|
||||
CommandStreamReceiver *getBcsCommandStreamReceiver(aub_stream::EngineType bcsEngineType) const override {
|
||||
return bcsCsrToReturn;
|
||||
}
|
||||
|
||||
CommandStreamReceiver *bcsCsrToReturn{nullptr};
|
||||
};
|
||||
|
||||
void SetUp() override {
|
||||
@@ -987,20 +1009,182 @@ struct WaitUntilCompletionTests : public ::testing::Test {
|
||||
std::unique_ptr<MockContext> context;
|
||||
};
|
||||
|
||||
HWTEST_F(WaitUntilCompletionTests, givenCommandQueueAndCleanTemporaryAllocationListWhenWaitUntilCompleteThenWaitForTaskCountIsCalled) {
|
||||
HWTEST_F(WaitUntilCompletionTests, givenCleanTemporaryAllocationListEqualsFalseWhenWaitingUntilCompleteThenWaitForTaskCountIsCalledAndItsReturnValueIsPropagated) {
|
||||
std::unique_ptr<CommandStreamReceiverHwMock<FamilyType>> cmdStream(new CommandStreamReceiverHwMock<FamilyType>(*device->getExecutionEnvironment(), device->getRootDeviceIndex(), device->getDeviceBitfield()));
|
||||
cmdStream->initializeTagAllocation();
|
||||
cmdStream->waitForTaskCountReturnValue = WaitStatus::Ready;
|
||||
|
||||
std::unique_ptr<MyCmdQueue<FamilyType>> cmdQ(new MyCmdQueue<FamilyType>(context.get(), device.get()));
|
||||
CommandStreamReceiver *oldCommandStreamReceiver = cmdQ->gpgpuEngine->commandStreamReceiver;
|
||||
|
||||
cmdQ->gpgpuEngine->commandStreamReceiver = cmdStream.get();
|
||||
uint32_t taskCount = 0u;
|
||||
|
||||
constexpr uint32_t taskCount = 0u;
|
||||
constexpr bool cleanTemporaryAllocationList = false;
|
||||
StackVec<CopyEngineState, bcsInfoMaskSize> activeBcsStates{};
|
||||
cmdQ->waitUntilComplete(taskCount, activeBcsStates, cmdQ->flushStamp->peekStamp(), false, false, false);
|
||||
|
||||
auto cmdStreamPtr = &device->getGpgpuCommandStreamReceiver();
|
||||
const auto waitStatus = cmdQ->waitUntilComplete(taskCount, activeBcsStates, cmdQ->flushStamp->peekStamp(), false, cleanTemporaryAllocationList, false);
|
||||
EXPECT_EQ(WaitStatus::Ready, waitStatus);
|
||||
EXPECT_EQ(1, cmdStream->waitForTaskCountCalledCounter);
|
||||
|
||||
EXPECT_TRUE(static_cast<CommandStreamReceiverHwMock<FamilyType> *>(cmdStreamPtr)->wiatForTaskCountCalled);
|
||||
cmdQ->gpgpuEngine->commandStreamReceiver = oldCommandStreamReceiver;
|
||||
}
|
||||
|
||||
HWTEST_F(WaitUntilCompletionTests, givenGpuHangAndCleanTemporaryAllocationListEqualsTrueWhenWaitingUntilCompleteThenWaitForTaskCountAndCleanAllocationIsCalledAndGpuHangIsReturned) {
|
||||
std::unique_ptr<CommandStreamReceiverHwMock<FamilyType>> cmdStream(new CommandStreamReceiverHwMock<FamilyType>(*device->getExecutionEnvironment(), device->getRootDeviceIndex(), device->getDeviceBitfield()));
|
||||
cmdStream->initializeTagAllocation();
|
||||
cmdStream->waitForTaskCountAndCleanTemporaryAllocationListReturnValue = WaitStatus::GpuHang;
|
||||
|
||||
std::unique_ptr<MyCmdQueue<FamilyType>> cmdQ(new MyCmdQueue<FamilyType>(context.get(), device.get()));
|
||||
CommandStreamReceiver *oldCommandStreamReceiver = cmdQ->gpgpuEngine->commandStreamReceiver;
|
||||
cmdQ->gpgpuEngine->commandStreamReceiver = cmdStream.get();
|
||||
|
||||
constexpr uint32_t taskCount = 0u;
|
||||
constexpr bool cleanTemporaryAllocationList = true;
|
||||
StackVec<CopyEngineState, bcsInfoMaskSize> activeBcsStates{};
|
||||
|
||||
const auto waitStatus = cmdQ->waitUntilComplete(taskCount, activeBcsStates, cmdQ->flushStamp->peekStamp(), false, cleanTemporaryAllocationList, false);
|
||||
EXPECT_EQ(WaitStatus::GpuHang, waitStatus);
|
||||
EXPECT_EQ(1, cmdStream->waitForTaskCountAndCleanTemporaryAllocationListCalledCounter);
|
||||
|
||||
cmdQ->gpgpuEngine->commandStreamReceiver = oldCommandStreamReceiver;
|
||||
}
|
||||
|
||||
HWTEST_F(WaitUntilCompletionTests, givenEmptyBcsStatesAndSkipWaitEqualsTrueWhenWaitingUntilCompleteThenWaitForTaskCountWithKmdNotifyFallbackIsNotCalled) {
|
||||
std::unique_ptr<CommandStreamReceiverHwMock<FamilyType>> cmdStream(new CommandStreamReceiverHwMock<FamilyType>(*device->getExecutionEnvironment(), device->getRootDeviceIndex(), device->getDeviceBitfield()));
|
||||
cmdStream->initializeTagAllocation();
|
||||
|
||||
std::unique_ptr<MyCmdQueue<FamilyType>> cmdQ(new MyCmdQueue<FamilyType>(context.get(), device.get()));
|
||||
CommandStreamReceiver *oldCommandStreamReceiver = cmdQ->gpgpuEngine->commandStreamReceiver;
|
||||
cmdQ->gpgpuEngine->commandStreamReceiver = cmdStream.get();
|
||||
|
||||
constexpr uint32_t taskCount = 0u;
|
||||
constexpr bool skipWait = true;
|
||||
StackVec<CopyEngineState, bcsInfoMaskSize> activeBcsStates{};
|
||||
|
||||
cmdQ->waitUntilComplete(taskCount, activeBcsStates, cmdQ->flushStamp->peekStamp(), false, false, skipWait);
|
||||
EXPECT_EQ(0, cmdStream->waitForTaskCountWithKmdNotifyFallbackCounter);
|
||||
|
||||
cmdQ->gpgpuEngine->commandStreamReceiver = oldCommandStreamReceiver;
|
||||
}
|
||||
|
||||
HWTEST_F(WaitUntilCompletionTests, givenGpuHangAndSkipWaitEqualsFalseWhenWaitingUntilCompleteThenOnlyWaitForTaskCountWithKmdNotifyFallbackIsCalledAndGpuHangIsReturned) {
|
||||
std::unique_ptr<CommandStreamReceiverHwMock<FamilyType>> cmdStream(new CommandStreamReceiverHwMock<FamilyType>(*device->getExecutionEnvironment(), device->getRootDeviceIndex(), device->getDeviceBitfield()));
|
||||
cmdStream->initializeTagAllocation();
|
||||
cmdStream->waitForTaskCountWithKmdNotifyFallbackReturnValue = WaitStatus::GpuHang;
|
||||
|
||||
std::unique_ptr<MyCmdQueue<FamilyType>> cmdQ(new MyCmdQueue<FamilyType>(context.get(), device.get()));
|
||||
CommandStreamReceiver *oldCommandStreamReceiver = cmdQ->gpgpuEngine->commandStreamReceiver;
|
||||
cmdQ->gpgpuEngine->commandStreamReceiver = cmdStream.get();
|
||||
|
||||
constexpr uint32_t taskCount = 0u;
|
||||
constexpr bool skipWait = false;
|
||||
StackVec<CopyEngineState, bcsInfoMaskSize> activeBcsStates{};
|
||||
|
||||
const auto waitStatus = cmdQ->waitUntilComplete(taskCount, activeBcsStates, cmdQ->flushStamp->peekStamp(), false, false, skipWait);
|
||||
EXPECT_EQ(WaitStatus::GpuHang, waitStatus);
|
||||
|
||||
EXPECT_EQ(0, cmdStream->waitForTaskCountCalledCounter);
|
||||
EXPECT_EQ(1, cmdStream->waitForTaskCountWithKmdNotifyFallbackCounter);
|
||||
EXPECT_EQ(0, cmdStream->waitForTaskCountAndCleanTemporaryAllocationListCalledCounter);
|
||||
|
||||
cmdQ->gpgpuEngine->commandStreamReceiver = oldCommandStreamReceiver;
|
||||
}
|
||||
|
||||
HWTEST_F(WaitUntilCompletionTests, givenGpuHangOnBcsCsrWhenWaitingUntilCompleteThenOnlyWaitForTaskCountWithKmdNotifyFallbackIsCalledOnBcsCsrAndGpuHangIsReturned) {
|
||||
std::unique_ptr<CommandStreamReceiverHwMock<FamilyType>> gpgpuCmdStream(new CommandStreamReceiverHwMock<FamilyType>(*device->getExecutionEnvironment(), device->getRootDeviceIndex(), device->getDeviceBitfield()));
|
||||
gpgpuCmdStream->initializeTagAllocation();
|
||||
gpgpuCmdStream->waitForTaskCountWithKmdNotifyFallbackReturnValue = WaitStatus::Ready;
|
||||
|
||||
std::unique_ptr<CommandStreamReceiverHwMock<FamilyType>> bcsCmdStream(new CommandStreamReceiverHwMock<FamilyType>(*device->getExecutionEnvironment(), device->getRootDeviceIndex(), device->getDeviceBitfield()));
|
||||
bcsCmdStream->initializeTagAllocation();
|
||||
bcsCmdStream->waitForTaskCountWithKmdNotifyFallbackReturnValue = WaitStatus::GpuHang;
|
||||
|
||||
std::unique_ptr<MyCmdQueue<FamilyType>> cmdQ(new MyCmdQueue<FamilyType>(context.get(), device.get()));
|
||||
CommandStreamReceiver *oldCommandStreamReceiver = cmdQ->gpgpuEngine->commandStreamReceiver;
|
||||
cmdQ->gpgpuEngine->commandStreamReceiver = gpgpuCmdStream.get();
|
||||
cmdQ->bcsCsrToReturn = bcsCmdStream.get();
|
||||
|
||||
constexpr uint32_t taskCount = 0u;
|
||||
constexpr bool skipWait = false;
|
||||
StackVec<CopyEngineState, bcsInfoMaskSize> activeBcsStates{CopyEngineState{}};
|
||||
|
||||
const auto waitStatus = cmdQ->waitUntilComplete(taskCount, activeBcsStates, cmdQ->flushStamp->peekStamp(), false, false, skipWait);
|
||||
EXPECT_EQ(WaitStatus::GpuHang, waitStatus);
|
||||
|
||||
EXPECT_EQ(0, gpgpuCmdStream->waitForTaskCountCalledCounter);
|
||||
EXPECT_EQ(1, gpgpuCmdStream->waitForTaskCountWithKmdNotifyFallbackCounter);
|
||||
EXPECT_EQ(0, gpgpuCmdStream->waitForTaskCountAndCleanTemporaryAllocationListCalledCounter);
|
||||
|
||||
EXPECT_EQ(0, bcsCmdStream->waitForTaskCountCalledCounter);
|
||||
EXPECT_EQ(1, bcsCmdStream->waitForTaskCountWithKmdNotifyFallbackCounter);
|
||||
EXPECT_EQ(0, bcsCmdStream->waitForTaskCountAndCleanTemporaryAllocationListCalledCounter);
|
||||
|
||||
cmdQ->gpgpuEngine->commandStreamReceiver = oldCommandStreamReceiver;
|
||||
}
|
||||
|
||||
HWTEST_F(WaitUntilCompletionTests, givenGpuHangOnBcsCsrWhenWaitingUntilCompleteThenWaitForTaskCountAndCleanTemporaryAllocationListIsCalledOnBcsCsrAndGpuHangIsReturned) {
|
||||
std::unique_ptr<CommandStreamReceiverHwMock<FamilyType>> gpgpuCmdStream(new CommandStreamReceiverHwMock<FamilyType>(*device->getExecutionEnvironment(), device->getRootDeviceIndex(), device->getDeviceBitfield()));
|
||||
gpgpuCmdStream->initializeTagAllocation();
|
||||
gpgpuCmdStream->waitForTaskCountWithKmdNotifyFallbackReturnValue = WaitStatus::Ready;
|
||||
|
||||
std::unique_ptr<CommandStreamReceiverHwMock<FamilyType>> bcsCmdStream(new CommandStreamReceiverHwMock<FamilyType>(*device->getExecutionEnvironment(), device->getRootDeviceIndex(), device->getDeviceBitfield()));
|
||||
bcsCmdStream->initializeTagAllocation();
|
||||
bcsCmdStream->waitForTaskCountWithKmdNotifyFallbackReturnValue = WaitStatus::Ready;
|
||||
bcsCmdStream->waitForTaskCountAndCleanTemporaryAllocationListReturnValue = WaitStatus::GpuHang;
|
||||
|
||||
std::unique_ptr<MyCmdQueue<FamilyType>> cmdQ(new MyCmdQueue<FamilyType>(context.get(), device.get()));
|
||||
CommandStreamReceiver *oldCommandStreamReceiver = cmdQ->gpgpuEngine->commandStreamReceiver;
|
||||
cmdQ->gpgpuEngine->commandStreamReceiver = gpgpuCmdStream.get();
|
||||
cmdQ->bcsCsrToReturn = bcsCmdStream.get();
|
||||
|
||||
constexpr uint32_t taskCount = 0u;
|
||||
constexpr bool skipWait = false;
|
||||
StackVec<CopyEngineState, bcsInfoMaskSize> activeBcsStates{CopyEngineState{}};
|
||||
|
||||
const auto waitStatus = cmdQ->waitUntilComplete(taskCount, activeBcsStates, cmdQ->flushStamp->peekStamp(), false, false, skipWait);
|
||||
EXPECT_EQ(WaitStatus::GpuHang, waitStatus);
|
||||
|
||||
EXPECT_EQ(0, gpgpuCmdStream->waitForTaskCountCalledCounter);
|
||||
EXPECT_EQ(1, gpgpuCmdStream->waitForTaskCountWithKmdNotifyFallbackCounter);
|
||||
EXPECT_EQ(0, gpgpuCmdStream->waitForTaskCountAndCleanTemporaryAllocationListCalledCounter);
|
||||
|
||||
EXPECT_EQ(0, bcsCmdStream->waitForTaskCountCalledCounter);
|
||||
EXPECT_EQ(1, bcsCmdStream->waitForTaskCountWithKmdNotifyFallbackCounter);
|
||||
EXPECT_EQ(1, bcsCmdStream->waitForTaskCountAndCleanTemporaryAllocationListCalledCounter);
|
||||
|
||||
cmdQ->gpgpuEngine->commandStreamReceiver = oldCommandStreamReceiver;
|
||||
}
|
||||
|
||||
HWTEST_F(WaitUntilCompletionTests, givenSuccessOnBcsCsrWhenWaitingUntilCompleteThenGpgpuCsrWaitStatusIsReturned) {
|
||||
std::unique_ptr<CommandStreamReceiverHwMock<FamilyType>> gpgpuCmdStream(new CommandStreamReceiverHwMock<FamilyType>(*device->getExecutionEnvironment(), device->getRootDeviceIndex(), device->getDeviceBitfield()));
|
||||
gpgpuCmdStream->initializeTagAllocation();
|
||||
gpgpuCmdStream->waitForTaskCountWithKmdNotifyFallbackReturnValue = WaitStatus::Ready;
|
||||
gpgpuCmdStream->waitForTaskCountReturnValue = WaitStatus::Ready;
|
||||
|
||||
std::unique_ptr<CommandStreamReceiverHwMock<FamilyType>> bcsCmdStream(new CommandStreamReceiverHwMock<FamilyType>(*device->getExecutionEnvironment(), device->getRootDeviceIndex(), device->getDeviceBitfield()));
|
||||
bcsCmdStream->initializeTagAllocation();
|
||||
bcsCmdStream->waitForTaskCountWithKmdNotifyFallbackReturnValue = WaitStatus::Ready;
|
||||
bcsCmdStream->waitForTaskCountAndCleanTemporaryAllocationListReturnValue = WaitStatus::Ready;
|
||||
|
||||
std::unique_ptr<MyCmdQueue<FamilyType>> cmdQ(new MyCmdQueue<FamilyType>(context.get(), device.get()));
|
||||
CommandStreamReceiver *oldCommandStreamReceiver = cmdQ->gpgpuEngine->commandStreamReceiver;
|
||||
cmdQ->gpgpuEngine->commandStreamReceiver = gpgpuCmdStream.get();
|
||||
cmdQ->bcsCsrToReturn = bcsCmdStream.get();
|
||||
|
||||
constexpr uint32_t taskCount = 0u;
|
||||
constexpr bool skipWait = false;
|
||||
StackVec<CopyEngineState, bcsInfoMaskSize> activeBcsStates{CopyEngineState{}};
|
||||
|
||||
const auto waitStatus = cmdQ->waitUntilComplete(taskCount, activeBcsStates, cmdQ->flushStamp->peekStamp(), false, false, skipWait);
|
||||
EXPECT_EQ(WaitStatus::Ready, waitStatus);
|
||||
|
||||
EXPECT_EQ(1, gpgpuCmdStream->waitForTaskCountCalledCounter);
|
||||
EXPECT_EQ(1, gpgpuCmdStream->waitForTaskCountWithKmdNotifyFallbackCounter);
|
||||
EXPECT_EQ(0, gpgpuCmdStream->waitForTaskCountAndCleanTemporaryAllocationListCalledCounter);
|
||||
|
||||
EXPECT_EQ(0, bcsCmdStream->waitForTaskCountCalledCounter);
|
||||
EXPECT_EQ(1, bcsCmdStream->waitForTaskCountWithKmdNotifyFallbackCounter);
|
||||
EXPECT_EQ(1, bcsCmdStream->waitForTaskCountAndCleanTemporaryAllocationListCalledCounter);
|
||||
|
||||
cmdQ->gpgpuEngine->commandStreamReceiver = oldCommandStreamReceiver;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "shared/source/aub/aub_subcapture.h"
|
||||
#include "shared/source/command_stream/wait_status.h"
|
||||
#include "shared/source/program/sync_buffer_handler.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/helpers/engine_descriptor_helper.h"
|
||||
@@ -111,9 +112,9 @@ struct EnqueueHandlerWithAubSubCaptureTests : public EnqueueHandlerTest {
|
||||
public:
|
||||
MockCmdQWithAubSubCapture(Context *context, ClDevice *device) : CommandQueueHw<FamilyType>(context, device, nullptr, false) {}
|
||||
|
||||
void waitUntilComplete(uint32_t gpgpuTaskCountToWait, Range<CopyEngineState> copyEnginesToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep, bool cleanTemporaryAllocationList, bool skipWait) override {
|
||||
WaitStatus waitUntilComplete(uint32_t gpgpuTaskCountToWait, Range<CopyEngineState> copyEnginesToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep, bool cleanTemporaryAllocationList, bool skipWait) override {
|
||||
waitUntilCompleteCalled = true;
|
||||
CommandQueueHw<FamilyType>::waitUntilComplete(gpgpuTaskCountToWait, copyEnginesToWait, flushStampToWait, useQuickKmdSleep, cleanTemporaryAllocationList, skipWait);
|
||||
return CommandQueueHw<FamilyType>::waitUntilComplete(gpgpuTaskCountToWait, copyEnginesToWait, flushStampToWait, useQuickKmdSleep, cleanTemporaryAllocationList, skipWait);
|
||||
}
|
||||
|
||||
void obtainNewTimestampPacketNodes(size_t numberOfNodes, TimestampPacketContainer &previousNodes, bool clearAllDependencies, CommandStreamReceiver &csr) override {
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "shared/source/command_container/implicit_scaling.h"
|
||||
#include "shared/source/command_stream/scratch_space_controller.h"
|
||||
#include "shared/source/command_stream/wait_status.h"
|
||||
#include "shared/source/helpers/hw_helper.h"
|
||||
#include "shared/source/memory_manager/allocations_list.h"
|
||||
#include "shared/test/common/cmd_parse/gen_cmd_parse.h"
|
||||
@@ -809,9 +810,9 @@ class MyCmdQ : public MockCommandQueueHw<FamilyType> {
|
||||
auxTranslationDirection);
|
||||
}
|
||||
|
||||
void waitUntilComplete(uint32_t gpgpuTaskCountToWait, Range<CopyEngineState> copyEnginesToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep, bool cleanTemporaryAllocationList, bool skipWait) override {
|
||||
WaitStatus waitUntilComplete(uint32_t gpgpuTaskCountToWait, Range<CopyEngineState> copyEnginesToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep, bool cleanTemporaryAllocationList, bool skipWait) override {
|
||||
waitCalled++;
|
||||
MockCommandQueueHw<FamilyType>::waitUntilComplete(gpgpuTaskCountToWait, copyEnginesToWait, flushStampToWait, useQuickKmdSleep, cleanTemporaryAllocationList, skipWait);
|
||||
return MockCommandQueueHw<FamilyType>::waitUntilComplete(gpgpuTaskCountToWait, copyEnginesToWait, flushStampToWait, useQuickKmdSleep, cleanTemporaryAllocationList, skipWait);
|
||||
}
|
||||
|
||||
std::vector<AuxTranslationDirection> auxTranslationDirections;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/command_stream/wait_status.h"
|
||||
#include "shared/source/memory_manager/internal_allocation_storage.h"
|
||||
#include "shared/source/memory_manager/memory_manager.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/command_stream/wait_status.h"
|
||||
#include "shared/test/common/mocks/mock_command_stream_receiver.h"
|
||||
#include "shared/test/common/mocks/ult_device_factory.h"
|
||||
#include "shared/test/common/test_macros/test.h"
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "shared/source/command_container/command_encoder.h"
|
||||
#include "shared/source/command_stream/scratch_space_controller.h"
|
||||
#include "shared/source/command_stream/scratch_space_controller_base.h"
|
||||
#include "shared/source/command_stream/wait_status.h"
|
||||
#include "shared/source/helpers/constants.h"
|
||||
#include "shared/source/os_interface/hw_info_config.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "shared/source/command_stream/scratch_space_controller_base.h"
|
||||
#include "shared/source/command_stream/wait_status.h"
|
||||
#include "shared/source/direct_submission/dispatchers/blitter_dispatcher.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/helpers/engine_descriptor_helper.h"
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/command_stream/wait_status.h"
|
||||
#include "shared/source/helpers/timestamp_packet.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/test_macros/mock_method_macros.h"
|
||||
@@ -38,14 +39,14 @@ class AsyncEventsHandlerTests : public ::testing::Test {
|
||||
this->updateTaskCount(taskCount, 0);
|
||||
}
|
||||
|
||||
bool wait(bool blocking, bool quickKmdSleep) override {
|
||||
WaitStatus wait(bool blocking, bool quickKmdSleep) override {
|
||||
waitCalled++;
|
||||
handler->allowAsyncProcess.store(false);
|
||||
return waitResult;
|
||||
}
|
||||
|
||||
uint32_t waitCalled = 0u;
|
||||
bool waitResult = true;
|
||||
WaitStatus waitResult = WaitStatus::Ready;
|
||||
std::unique_ptr<MockHandler> handler;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shared/source/command_stream/wait_status.h"
|
||||
#include "shared/source/helpers/aligned_memory.h"
|
||||
#include "shared/source/helpers/ptr_math.h"
|
||||
#include "shared/test/unit_test/utilities/base_object_utils.h"
|
||||
@@ -67,7 +68,7 @@ struct InternalsEventTest
|
||||
};
|
||||
|
||||
struct MyUserEvent : public VirtualEvent {
|
||||
bool wait(bool blocking, bool quickKmdSleep) override {
|
||||
WaitStatus wait(bool blocking, bool quickKmdSleep) override {
|
||||
return VirtualEvent::wait(blocking, quickKmdSleep);
|
||||
};
|
||||
uint32_t getTaskLevel() override {
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "shared/source/command_stream/command_stream_receiver.h"
|
||||
#include "shared/source/command_stream/wait_status.h"
|
||||
#include "shared/source/helpers/hw_info.h"
|
||||
#include "shared/source/memory_manager/internal_allocation_storage.h"
|
||||
#include "shared/source/os_interface/os_interface.h"
|
||||
@@ -409,7 +410,7 @@ TEST_F(EventTest, GivenInvalidEventWhenGettingEventInfoThenInvalidValueErrorIsRe
|
||||
TEST_F(EventTest, GivenNonBlockingEventWhenWaitingThenFalseIsReturned) {
|
||||
Event event(pCmdQ, CL_COMMAND_NDRANGE_KERNEL, 3, CompletionStamp::notReady);
|
||||
auto result = event.wait(false, false);
|
||||
EXPECT_FALSE(result);
|
||||
EXPECT_EQ(WaitStatus::NotReady, result);
|
||||
}
|
||||
|
||||
struct UpdateEventTest : public ::testing::Test {
|
||||
@@ -805,6 +806,38 @@ TEST_F(InternalsEventTest, givenDeviceTimestampBaseEnabledAndGlobalStartTSSmalle
|
||||
event.timeStampNode = nullptr;
|
||||
}
|
||||
|
||||
TEST_F(InternalsEventTest, givenGpuHangWhenEventWaitReportsHangThenWaititingIsAbortedAndUnfinishedEventsHaveExecutionStatusEqualsToAbortedDueToGpuHang) {
|
||||
MockCommandQueue cmdQ(mockContext, pClDevice, nullptr, false);
|
||||
|
||||
MockEvent<Event> passingEvent(&cmdQ, CL_COMMAND_NDRANGE_KERNEL, 0, 0);
|
||||
passingEvent.waitReturnValue = WaitStatus::Ready;
|
||||
|
||||
MockEvent<Event> hangingEvent(&cmdQ, CL_COMMAND_NDRANGE_KERNEL, 0, 0);
|
||||
hangingEvent.waitReturnValue = WaitStatus::GpuHang;
|
||||
|
||||
cl_event eventWaitlist[] = {&passingEvent, &hangingEvent};
|
||||
|
||||
const auto result = Event::waitForEvents(2, eventWaitlist);
|
||||
EXPECT_EQ(CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST, result);
|
||||
|
||||
EXPECT_NE(Event::executionAbortedDueToGpuHang, passingEvent.peekExecutionStatus());
|
||||
EXPECT_EQ(Event::executionAbortedDueToGpuHang, hangingEvent.peekExecutionStatus());
|
||||
}
|
||||
|
||||
TEST_F(InternalsEventTest, givenPassingEventWhenWaitingForEventsThenWaititingIsSuccessfulAndEventIsNotAborted) {
|
||||
MockCommandQueue cmdQ(mockContext, pClDevice, nullptr, false);
|
||||
|
||||
MockEvent<Event> passingEvent(&cmdQ, CL_COMMAND_NDRANGE_KERNEL, 0, 0);
|
||||
passingEvent.waitReturnValue = WaitStatus::Ready;
|
||||
|
||||
cl_event eventWaitlist[] = {&passingEvent};
|
||||
|
||||
const auto result = Event::waitForEvents(1, eventWaitlist);
|
||||
EXPECT_EQ(CL_SUCCESS, result);
|
||||
|
||||
EXPECT_NE(Event::executionAbortedDueToGpuHang, passingEvent.peekExecutionStatus());
|
||||
}
|
||||
|
||||
TEST_F(InternalsEventTest, GivenProfilingWHENMapOperationTHENTimesSet) {
|
||||
const cl_queue_properties props[3] = {CL_QUEUE_PROPERTIES, CL_QUEUE_PROFILING_ENABLE, 0};
|
||||
MockCommandQueue *pCmdQ = new MockCommandQueue(mockContext, pClDevice, props, false);
|
||||
@@ -1520,7 +1553,9 @@ HWTEST_F(EventTest, givenQuickKmdSleepRequestWhenWaitIsCalledThenPassRequestToWa
|
||||
Event event(pCmdQ, CL_COMMAND_NDRANGE_KERNEL, 0, 0);
|
||||
event.updateCompletionStamp(1u, 0, 1u, 1u);
|
||||
|
||||
event.wait(true, true);
|
||||
const auto result = event.wait(true, true);
|
||||
EXPECT_EQ(WaitStatus::Ready, result);
|
||||
|
||||
EXPECT_EQ(1u, csr->waitForCompletionWithTimeoutCalled);
|
||||
EXPECT_EQ(localHwInfo.capabilityTable.kmdNotifyProperties.delayQuickKmdSleepMicroseconds, csr->waitForCompletionWithTimeoutParamsPassed[0].timeoutMs);
|
||||
}
|
||||
@@ -1541,11 +1576,25 @@ HWTEST_F(EventTest, givenNonQuickKmdSleepRequestWhenWaitIsCalledThenPassRequestT
|
||||
Event event(pCmdQ, CL_COMMAND_NDRANGE_KERNEL, 0, 0);
|
||||
event.updateCompletionStamp(1u, 0, 1u, 1u);
|
||||
|
||||
event.wait(true, false);
|
||||
const auto result = event.wait(true, false);
|
||||
EXPECT_EQ(WaitStatus::Ready, result);
|
||||
|
||||
EXPECT_EQ(1u, csr->waitForCompletionWithTimeoutCalled);
|
||||
EXPECT_EQ(localHwInfo.capabilityTable.kmdNotifyProperties.delayKmdNotifyMicroseconds, csr->waitForCompletionWithTimeoutParamsPassed[0].timeoutMs);
|
||||
}
|
||||
|
||||
HWTEST_F(EventTest, givenGpuHangWhenWaitIsCalledThenPassRequestToWaitingFunctionAndReturnGpuHang) {
|
||||
auto csr = new TestEventCsr<FamilyType>(*pDevice->executionEnvironment, pDevice->getDeviceBitfield());
|
||||
csr->waitForCompletionWithTimeoutResult = WaitStatus::GpuHang;
|
||||
pDevice->resetCommandStreamReceiver(csr);
|
||||
|
||||
Event event(pCmdQ, CL_COMMAND_NDRANGE_KERNEL, 0, 0);
|
||||
|
||||
const auto waitStatus = event.wait(true, false);
|
||||
EXPECT_EQ(WaitStatus::GpuHang, waitStatus);
|
||||
EXPECT_EQ(1u, csr->waitForCompletionWithTimeoutCalled);
|
||||
}
|
||||
|
||||
HWTEST_F(InternalsEventTest, givenCommandWhenSubmitCalledThenUpdateFlushStamp) {
|
||||
auto pCmdQ = std::unique_ptr<MockCommandQueue>(new MockCommandQueue(mockContext, pClDevice, 0, false));
|
||||
MockEvent<Event> *event = new MockEvent<Event>(pCmdQ.get(), CL_COMMAND_MARKER, 0, 0);
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/command_stream/wait_status.h"
|
||||
#include "shared/source/memory_manager/internal_allocation_storage.h"
|
||||
#include "shared/source/memory_manager/memory_manager.h"
|
||||
#include "shared/source/os_interface/os_context.h"
|
||||
@@ -131,7 +132,7 @@ TEST(UserEvent, GivenInitialUserEventStateWhenCheckingReadyForSubmissionThenFals
|
||||
TEST(UserEvent, GivenUserEventWhenGettingTaskLevelThenZeroIsReturned) {
|
||||
MyUserEvent uEvent;
|
||||
EXPECT_EQ(0U, uEvent.getTaskLevel());
|
||||
EXPECT_FALSE(uEvent.wait(false, false));
|
||||
EXPECT_EQ(WaitStatus::NotReady, uEvent.wait(false, false));
|
||||
}
|
||||
|
||||
TEST(UserEvent, WhenSettingStatusThenReadyForSubmissionisTrue) {
|
||||
@@ -952,7 +953,7 @@ TEST_F(EventTests, WhenWaitingForEventsThenTemporaryAllocationsAreDestroyed) {
|
||||
TEST_F(EventTest, WhenUserEventIsCreatedThenWaitIsNonBlocking) {
|
||||
UserEvent event;
|
||||
auto result = event.wait(false, false);
|
||||
EXPECT_FALSE(result);
|
||||
EXPECT_EQ(WaitStatus::NotReady, result);
|
||||
}
|
||||
|
||||
TEST_F(EventTest, GivenSingleUserEventWhenWaitingForEventsThenSuccessIsReturned) {
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/command_stream/wait_status.h"
|
||||
#include "shared/source/os_interface/os_context.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/mocks/mock_device.h"
|
||||
@@ -127,6 +128,7 @@ struct KmdNotifyTests : public ::testing::Test {
|
||||
|
||||
HWTEST_F(KmdNotifyTests, givenTaskCountWhenWaitUntilCompletionCalledThenAlwaysTryCpuPolling) {
|
||||
auto csr = createMockCsr<FamilyType>();
|
||||
|
||||
cmdQ->waitUntilComplete(taskCountToWait, {}, flushStampToWait, false);
|
||||
EXPECT_EQ(1u, csr->waitForCompletionWithTimeoutCalled);
|
||||
EXPECT_EQ(true, csr->waitForCompletionWithTimeoutParamsPassed[0].enableTimeout);
|
||||
@@ -137,6 +139,7 @@ HWTEST_F(KmdNotifyTests, givenTaskCountWhenWaitUntilCompletionCalledThenAlwaysTr
|
||||
HWTEST_F(KmdNotifyTests, givenTaskCountAndKmdNotifyDisabledWhenWaitUntilCompletionCalledThenTryCpuPollingWithoutTimeout) {
|
||||
overrideKmdNotifyParams(false, 0, false, 0, false, 0, false, 0);
|
||||
auto csr = createMockCsr<FamilyType>();
|
||||
|
||||
cmdQ->waitUntilComplete(taskCountToWait, {}, flushStampToWait, false);
|
||||
EXPECT_EQ(0u, csr->waitForFlushStampCalled);
|
||||
EXPECT_EQ(1u, csr->waitForCompletionWithTimeoutCalled);
|
||||
@@ -274,6 +277,7 @@ HWTEST_F(KmdNotifyTests, givenKmdNotifyDisabledWhenQueueHasPowerSavingModeAndCal
|
||||
auto csr = createMockCsr<FamilyType>();
|
||||
|
||||
cmdQ->throttle = QueueThrottle::LOW;
|
||||
|
||||
cmdQ->waitUntilComplete(1, {}, 1, false);
|
||||
EXPECT_EQ(1u, csr->waitForCompletionWithTimeoutCalled);
|
||||
EXPECT_EQ(true, csr->waitForCompletionWithTimeoutParamsPassed[0].enableTimeout);
|
||||
@@ -285,6 +289,7 @@ HWTEST_F(KmdNotifyTests, givenKmdNotifyDisabledWhenQueueHasPowerSavingModButTher
|
||||
auto csr = createMockCsr<FamilyType>();
|
||||
|
||||
cmdQ->throttle = QueueThrottle::LOW;
|
||||
|
||||
cmdQ->waitUntilComplete(1, {}, 0, false);
|
||||
EXPECT_EQ(1u, csr->waitForCompletionWithTimeoutCalled);
|
||||
EXPECT_EQ(false, csr->waitForCompletionWithTimeoutParamsPassed[0].enableTimeout);
|
||||
@@ -528,4 +533,4 @@ TEST_F(KmdNotifyTests, givenDisabledKmdDirectSubmissionNotifyMechanismWhenDirect
|
||||
bool timeoutEnabled = helper.obtainTimeoutParams(timeout, false, 1, 2, flushStampToWait, false, true, directSubmission);
|
||||
EXPECT_TRUE(timeoutEnabled);
|
||||
EXPECT_EQ(expectedTimeout, timeout);
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "shared/source/command_stream/command_stream_receiver_hw.h"
|
||||
#include "shared/source/command_stream/wait_status.h"
|
||||
#include "shared/source/debug_settings/debug_settings_manager.h"
|
||||
#include "shared/source/gmm_helper/gmm_helper.h"
|
||||
#include "shared/source/helpers/flush_stamp.h"
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/command_stream/wait_status.h"
|
||||
#include "shared/source/memory_manager/allocations_list.h"
|
||||
#include "shared/source/memory_manager/unified_memory_manager.h"
|
||||
#include "shared/test/common/cmd_parse/hw_parse.h"
|
||||
@@ -47,10 +48,12 @@ struct BcsBufferTests : public ::testing::Test {
|
||||
return WaitStatus::Ready;
|
||||
}
|
||||
|
||||
void waitForTaskCountAndCleanTemporaryAllocationList(uint32_t requiredTaskCount) override {
|
||||
WaitStatus waitForTaskCountAndCleanTemporaryAllocationList(uint32_t requiredTaskCount) override {
|
||||
EXPECT_EQ(1u, waitForTaskCountWithKmdNotifyFallbackCalled);
|
||||
EXPECT_EQ(this->latestFlushedTaskCount, requiredTaskCount);
|
||||
waitForTaskCountAndCleanAllocationListCalled++;
|
||||
|
||||
return WaitStatus::Ready;
|
||||
}
|
||||
|
||||
uint32_t waitForTaskCountAndCleanAllocationListCalled = 0;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/command_stream/wait_status.h"
|
||||
#include "shared/source/memory_manager/allocations_list.h"
|
||||
#include "shared/source/memory_manager/unified_memory_manager.h"
|
||||
#include "shared/source/os_interface/os_context.h"
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shared/source/command_stream/wait_status.h"
|
||||
#include "shared/source/memory_manager/graphics_allocation.h"
|
||||
#include "shared/test/common/libult/ult_command_stream_receiver.h"
|
||||
|
||||
@@ -90,12 +92,12 @@ class MockCommandQueue : public CommandQueue {
|
||||
return writeBufferRetValue;
|
||||
}
|
||||
|
||||
void waitUntilComplete(uint32_t gpgpuTaskCountToWait, Range<CopyEngineState> copyEnginesToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep, bool cleanTemporaryAllocationList, bool skipWait) override {
|
||||
WaitStatus waitUntilComplete(uint32_t gpgpuTaskCountToWait, Range<CopyEngineState> copyEnginesToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep, bool cleanTemporaryAllocationList, bool skipWait) override {
|
||||
latestTaskCountWaited = gpgpuTaskCountToWait;
|
||||
return CommandQueue::waitUntilComplete(gpgpuTaskCountToWait, copyEnginesToWait, flushStampToWait, useQuickKmdSleep, cleanTemporaryAllocationList, skipWait);
|
||||
}
|
||||
|
||||
void waitUntilComplete(uint32_t gpgpuTaskCountToWait, Range<CopyEngineState> copyEnginesToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep) override {
|
||||
WaitStatus waitUntilComplete(uint32_t gpgpuTaskCountToWait, Range<CopyEngineState> copyEnginesToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep) override {
|
||||
latestTaskCountWaited = gpgpuTaskCountToWait;
|
||||
return CommandQueue::waitUntilComplete(gpgpuTaskCountToWait, copyEnginesToWait, flushStampToWait, useQuickKmdSleep);
|
||||
}
|
||||
@@ -333,7 +335,7 @@ class MockCommandQueueHw : public CommandQueueHw<GfxFamily> {
|
||||
useBcsCsrOnNotifyEnabled = notifyBcsCsr;
|
||||
}
|
||||
|
||||
void waitUntilComplete(uint32_t gpgpuTaskCountToWait, Range<CopyEngineState> copyEnginesToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep, bool cleanTemporaryAllocationList, bool skipWait) override {
|
||||
WaitStatus waitUntilComplete(uint32_t gpgpuTaskCountToWait, Range<CopyEngineState> copyEnginesToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep, bool cleanTemporaryAllocationList, bool skipWait) override {
|
||||
latestTaskCountWaited = gpgpuTaskCountToWait;
|
||||
return BaseClass::waitUntilComplete(gpgpuTaskCountToWait, copyEnginesToWait, flushStampToWait, useQuickKmdSleep, cleanTemporaryAllocationList, skipWait);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -7,9 +7,13 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shared/source/command_stream/wait_status.h"
|
||||
|
||||
#include "opencl/source/event/event_builder.h"
|
||||
#include "opencl/source/event/user_event.h"
|
||||
|
||||
#include <optional>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
#define FORWARD_CONSTRUCTOR(THIS_CLASS, BASE_CLASS) \
|
||||
@@ -37,6 +41,16 @@ struct MockEvent : public BaseEventType {
|
||||
using Event::queueTimeStamp;
|
||||
using Event::submitTimeStamp;
|
||||
using Event::timestampPacketContainer;
|
||||
|
||||
WaitStatus wait(bool blocking, bool useQuickKmdSleep) override {
|
||||
if (waitReturnValue.has_value()) {
|
||||
return *waitReturnValue;
|
||||
}
|
||||
|
||||
return BaseEventType::wait(blocking, useQuickKmdSleep);
|
||||
}
|
||||
|
||||
std::optional<WaitStatus> waitReturnValue{};
|
||||
};
|
||||
|
||||
#undef FORWARD_CONSTRUCTOR
|
||||
|
||||
@@ -781,7 +781,8 @@ TEST_F(WddmCommandStreamTest, givenTwoTemporaryAllocationsWhenCleanTemporaryAllo
|
||||
graphicsAllocation->updateTaskCount(1, csr->getOsContext().getContextId());
|
||||
graphicsAllocation2->updateTaskCount(100, csr->getOsContext().getContextId());
|
||||
|
||||
csr->waitForTaskCountAndCleanAllocationList(1, TEMPORARY_ALLOCATION);
|
||||
const auto firstWaitResult = csr->waitForTaskCountAndCleanAllocationList(1, TEMPORARY_ALLOCATION);
|
||||
EXPECT_EQ(WaitStatus::Ready, firstWaitResult);
|
||||
// graphicsAllocation2 still lives
|
||||
EXPECT_EQ(host_ptr2, graphicsAllocation2->getUnderlyingBuffer());
|
||||
|
||||
@@ -797,8 +798,10 @@ TEST_F(WddmCommandStreamTest, givenTwoTemporaryAllocationsWhenCleanTemporaryAllo
|
||||
|
||||
auto fragment2 = hostPtrManager->getFragment({alignedPtr, csr->getRootDeviceIndex()});
|
||||
EXPECT_EQ(nullptr, fragment2);
|
||||
|
||||
// destroy remaining allocation
|
||||
csr->waitForTaskCountAndCleanAllocationList(100, TEMPORARY_ALLOCATION);
|
||||
const auto secondWaitResult = csr->waitForTaskCountAndCleanAllocationList(100, TEMPORARY_ALLOCATION);
|
||||
EXPECT_EQ(WaitStatus::Ready, secondWaitResult);
|
||||
}
|
||||
|
||||
TEST_F(WddmCommandStreamMockGdiTest, WhenFlushingThenWddmMakeResidentIsCalledForResidencyAllocations) {
|
||||
|
||||
Reference in New Issue
Block a user