mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Add missing download allocation calls
Signed-off-by: Jobczyk, Lukasz <lukasz.jobczyk@intel.com> Signed-off-by: Lukasz Jobczyk <lukasz.jobczyk@intel.com>
This commit is contained in:

committed by
Compute-Runtime-Automation

parent
01e76998d4
commit
a285712cc4
@ -169,6 +169,7 @@ void CommandStreamReceiver::makeResidentHostPtrAllocation(GraphicsAllocation *gf
|
||||
WaitStatus CommandStreamReceiver::waitForTaskCount(uint32_t requiredTaskCount) {
|
||||
auto address = getTagAddress();
|
||||
if (address) {
|
||||
this->downloadTagAllocation();
|
||||
return baseWaitFunction(address, WaitParams{false, false, 0}, requiredTaskCount);
|
||||
}
|
||||
|
||||
@ -277,7 +278,7 @@ void CommandStreamReceiver::cleanupResources() {
|
||||
}
|
||||
|
||||
if (tagsMultiAllocation) {
|
||||
//Null tag address to prevent waiting for tag update when freeing it
|
||||
// Null tag address to prevent waiting for tag update when freeing it
|
||||
tagAllocation = nullptr;
|
||||
tagAddress = nullptr;
|
||||
DEBUG_BREAK_IF(tagAllocation != nullptr);
|
||||
@ -461,6 +462,12 @@ AubSubCaptureStatus CommandStreamReceiver::checkAndActivateAubSubCapture(const s
|
||||
|
||||
void CommandStreamReceiver::addAubComment(const char *comment) {}
|
||||
|
||||
void CommandStreamReceiver::downloadAllocation(GraphicsAllocation &gfxAllocation) {
|
||||
if (this->downloadAllocationImpl) {
|
||||
this->downloadAllocationImpl(gfxAllocation);
|
||||
}
|
||||
}
|
||||
|
||||
void CommandStreamReceiver::startControllingDirectSubmissions() {
|
||||
auto controller = this->executionEnvironment.directSubmissionController.get();
|
||||
if (controller) {
|
||||
@ -805,7 +812,14 @@ bool CommandStreamReceiver::checkImplicitFlushForGpuIdle() {
|
||||
return false;
|
||||
}
|
||||
|
||||
void CommandStreamReceiver::downloadTagAllocation() {
|
||||
if (this->getTagAllocation()) {
|
||||
this->downloadAllocation(*this->getTagAllocation());
|
||||
}
|
||||
}
|
||||
|
||||
bool CommandStreamReceiver::testTaskCountReady(volatile uint32_t *pollAddress, uint32_t taskCountToWait) {
|
||||
this->downloadTagAllocation();
|
||||
for (uint32_t i = 0; i < activePartitions; i++) {
|
||||
if (!WaitUtils::waitFunction(pollAddress, taskCountToWait)) {
|
||||
return false;
|
||||
|
@ -235,7 +235,7 @@ class CommandStreamReceiver {
|
||||
return scratchSpaceController.get();
|
||||
}
|
||||
|
||||
virtual void downloadAllocation(GraphicsAllocation &gfxAllocation){};
|
||||
void downloadAllocation(GraphicsAllocation &gfxAllocation);
|
||||
|
||||
void registerInstructionCacheFlush() {
|
||||
auto mutex = obtainUniqueOwnership();
|
||||
@ -324,6 +324,7 @@ class CommandStreamReceiver {
|
||||
void printDeviceIndex();
|
||||
void checkForNewResources(uint32_t submittedTaskCount, uint32_t allocationTaskCount, GraphicsAllocation &gfxAllocation);
|
||||
bool checkImplicitFlushForGpuIdle();
|
||||
void downloadTagAllocation();
|
||||
MOCKABLE_VIRTUAL std::unique_lock<MutexType> obtainHostPtrSurfaceCreationLock();
|
||||
|
||||
std::unique_ptr<FlushStampTracker> flushStamp;
|
||||
@ -356,6 +357,7 @@ class CommandStreamReceiver {
|
||||
SpinLock debugPauseStateLock;
|
||||
static void *asyncDebugBreakConfirmation(void *arg);
|
||||
std::function<void()> debugConfirmationFunction = []() { std::cin.get(); };
|
||||
std::function<void(GraphicsAllocation &)> downloadAllocationImpl;
|
||||
|
||||
GraphicsAllocation *tagAllocation = nullptr;
|
||||
GraphicsAllocation *globalFenceAllocation = nullptr;
|
||||
|
@ -46,7 +46,7 @@ class TbxCommandStreamReceiverHw : public CommandStreamReceiverSimulatedHw<GfxFa
|
||||
WaitStatus waitForTaskCountWithKmdNotifyFallback(uint32_t taskCountToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep, QueueThrottle throttle) override;
|
||||
WaitStatus waitForCompletionWithTimeout(const WaitParams ¶ms, uint32_t taskCountToWait) override;
|
||||
void downloadAllocations() override;
|
||||
void downloadAllocation(GraphicsAllocation &gfxAllocation) override;
|
||||
void downloadAllocationTbx(GraphicsAllocation &gfxAllocation);
|
||||
|
||||
void processEviction() override;
|
||||
void processResidency(const ResidencyContainer &allocationsForResidency, uint32_t handleId) override;
|
||||
|
@ -55,10 +55,15 @@ TbxCommandStreamReceiverHw<GfxFamily>::TbxCommandStreamReceiverHw(ExecutionEnvir
|
||||
? this->peekHwInfo().capabilityTable.aubDeviceId
|
||||
: static_cast<uint32_t>(debugDeviceId);
|
||||
this->stream = &tbxStream;
|
||||
this->downloadAllocationImpl = [this](GraphicsAllocation &graphicsAllocation) {
|
||||
this->downloadAllocationTbx(graphicsAllocation);
|
||||
};
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
TbxCommandStreamReceiverHw<GfxFamily>::~TbxCommandStreamReceiverHw() {
|
||||
this->downloadAllocationImpl = nullptr;
|
||||
|
||||
if (streamInitialized) {
|
||||
tbxStream.close();
|
||||
}
|
||||
@ -480,14 +485,14 @@ void TbxCommandStreamReceiverHw<GfxFamily>::flushSubmissionsAndDownloadAllocatio
|
||||
volatile uint32_t *pollAddress = this->getTagAddress();
|
||||
for (uint32_t i = 0; i < this->activePartitions; i++) {
|
||||
while (*pollAddress < this->latestFlushedTaskCount) {
|
||||
downloadAllocation(*this->getTagAllocation());
|
||||
this->downloadAllocation(*this->getTagAllocation());
|
||||
}
|
||||
pollAddress = ptrOffset(pollAddress, this->postSyncWriteOffset);
|
||||
}
|
||||
|
||||
auto lockCSR = this->obtainUniqueOwnership();
|
||||
for (GraphicsAllocation *graphicsAllocation : this->allocationsForDownload) {
|
||||
downloadAllocation(*graphicsAllocation);
|
||||
this->downloadAllocation(*graphicsAllocation);
|
||||
}
|
||||
this->allocationsForDownload.clear();
|
||||
}
|
||||
@ -527,7 +532,7 @@ void TbxCommandStreamReceiverHw<GfxFamily>::processResidency(const ResidencyCont
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
void TbxCommandStreamReceiverHw<GfxFamily>::downloadAllocation(GraphicsAllocation &gfxAllocation) {
|
||||
void TbxCommandStreamReceiverHw<GfxFamily>::downloadAllocationTbx(GraphicsAllocation &gfxAllocation) {
|
||||
if (hardwareContextController) {
|
||||
hardwareContextController->readMemory(gfxAllocation.getGpuAddress(), gfxAllocation.getUnderlyingBuffer(), gfxAllocation.getUnderlyingBufferSize(),
|
||||
this->getMemoryBank(&gfxAllocation), MemoryConstants::pageSize64k);
|
||||
@ -552,13 +557,13 @@ void TbxCommandStreamReceiverHw<GfxFamily>::downloadAllocations() {
|
||||
volatile uint32_t *pollAddress = this->getTagAddress();
|
||||
for (uint32_t i = 0; i < this->activePartitions; i++) {
|
||||
while (*pollAddress < this->latestFlushedTaskCount) {
|
||||
downloadAllocation(*this->getTagAllocation());
|
||||
this->downloadAllocation(*this->getTagAllocation());
|
||||
}
|
||||
pollAddress = ptrOffset(pollAddress, this->postSyncWriteOffset);
|
||||
}
|
||||
auto lockCSR = this->obtainUniqueOwnership();
|
||||
for (GraphicsAllocation *graphicsAllocation : this->allocationsForDownload) {
|
||||
downloadAllocation(*graphicsAllocation);
|
||||
this->downloadAllocation(*graphicsAllocation);
|
||||
}
|
||||
this->allocationsForDownload.clear();
|
||||
}
|
||||
|
@ -128,6 +128,12 @@ class UltCommandStreamReceiver : public CommandStreamReceiverHw<GfxFamily>, publ
|
||||
const DeviceBitfield deviceBitfield)
|
||||
: BaseClass(executionEnvironment, rootDeviceIndex, deviceBitfield), recursiveLockCounter(0),
|
||||
recordedDispatchFlags(DispatchFlagsHelper::createDefaultDispatchFlags()) {
|
||||
this->downloadAllocationImpl = [this](GraphicsAllocation &graphicsAllocation) {
|
||||
this->downloadAllocationUlt(graphicsAllocation);
|
||||
};
|
||||
}
|
||||
~UltCommandStreamReceiver() {
|
||||
this->downloadAllocationImpl = nullptr;
|
||||
}
|
||||
static CommandStreamReceiver *create(bool withAubDump,
|
||||
ExecutionEnvironment &executionEnvironment,
|
||||
@ -171,7 +177,7 @@ class UltCommandStreamReceiver : public CommandStreamReceiverHw<GfxFamily>, publ
|
||||
downloadAllocationCalled = true;
|
||||
}
|
||||
|
||||
void downloadAllocation(GraphicsAllocation &gfxAllocation) override {
|
||||
void downloadAllocationUlt(GraphicsAllocation &gfxAllocation) {
|
||||
downloadAllocationCalled = true;
|
||||
}
|
||||
|
||||
@ -339,7 +345,7 @@ class UltCommandStreamReceiver : public CommandStreamReceiverHw<GfxFamily>, publ
|
||||
bool recordFlusheBatchBuffer = false;
|
||||
bool checkAndActivateAubSubCaptureCalled = false;
|
||||
bool addAubCommentCalled = false;
|
||||
bool downloadAllocationCalled = false;
|
||||
std::atomic_bool downloadAllocationCalled = false;
|
||||
bool flushBatchedSubmissionsCalled = false;
|
||||
bool initProgrammingFlagsCalled = false;
|
||||
bool multiOsContextCapable = false;
|
||||
|
@ -25,7 +25,14 @@ class MockTbxCsr : public TbxCommandStreamReceiverHw<GfxFamily> {
|
||||
using TbxCommandStreamReceiverHw<GfxFamily>::writeMemory;
|
||||
using TbxCommandStreamReceiverHw<GfxFamily>::allocationsForDownload;
|
||||
MockTbxCsr(ExecutionEnvironment &executionEnvironment, const DeviceBitfield deviceBitfield)
|
||||
: TbxCommandStreamReceiverHw<GfxFamily>(executionEnvironment, 0, deviceBitfield) {}
|
||||
: TbxCommandStreamReceiverHw<GfxFamily>(executionEnvironment, 0, deviceBitfield) {
|
||||
this->downloadAllocationImpl = [this](GraphicsAllocation &gfxAllocation) {
|
||||
this->downloadAllocationTbxMock(gfxAllocation);
|
||||
};
|
||||
}
|
||||
~MockTbxCsr() {
|
||||
this->downloadAllocationImpl = nullptr;
|
||||
}
|
||||
|
||||
void initializeEngine() override {
|
||||
TbxCommandStreamReceiverHw<GfxFamily>::initializeEngine();
|
||||
@ -50,8 +57,8 @@ class MockTbxCsr : public TbxCommandStreamReceiverHw<GfxFamily> {
|
||||
TbxCommandStreamReceiverHw<GfxFamily>::pollForCompletion();
|
||||
pollForCompletionCalled = true;
|
||||
}
|
||||
void downloadAllocation(GraphicsAllocation &gfxAllocation) override {
|
||||
TbxCommandStreamReceiverHw<GfxFamily>::downloadAllocation(gfxAllocation);
|
||||
void downloadAllocationTbxMock(GraphicsAllocation &gfxAllocation) {
|
||||
TbxCommandStreamReceiverHw<GfxFamily>::downloadAllocationTbx(gfxAllocation);
|
||||
makeCoherentCalled = true;
|
||||
}
|
||||
void dumpAllocation(GraphicsAllocation &gfxAllocation) override {
|
||||
@ -74,9 +81,18 @@ template <typename GfxFamily>
|
||||
struct MockTbxCsrRegisterDownloadedAllocations : TbxCommandStreamReceiverHw<GfxFamily> {
|
||||
using CommandStreamReceiver::latestFlushedTaskCount;
|
||||
using CommandStreamReceiver::tagsMultiAllocation;
|
||||
using TbxCommandStreamReceiverHw<GfxFamily>::TbxCommandStreamReceiverHw;
|
||||
using TbxCommandStreamReceiverHw<GfxFamily>::flushSubmissionsAndDownloadAllocations;
|
||||
void downloadAllocation(GraphicsAllocation &gfxAllocation) override {
|
||||
|
||||
MockTbxCsrRegisterDownloadedAllocations(ExecutionEnvironment &executionEnvironment, uint32_t rootDeviceIndex, const DeviceBitfield deviceBitfield)
|
||||
: TbxCommandStreamReceiverHw<GfxFamily>(executionEnvironment, rootDeviceIndex, deviceBitfield) {
|
||||
this->downloadAllocationImpl = [this](GraphicsAllocation &gfxAllocation) {
|
||||
this->downloadAllocationTbxMock(gfxAllocation);
|
||||
};
|
||||
}
|
||||
~MockTbxCsrRegisterDownloadedAllocations() {
|
||||
this->downloadAllocationImpl = nullptr;
|
||||
}
|
||||
void downloadAllocationTbxMock(GraphicsAllocation &gfxAllocation) {
|
||||
*reinterpret_cast<uint32_t *>(CommandStreamReceiver::getTagAllocation()->getUnderlyingBuffer()) = this->latestFlushedTaskCount;
|
||||
downloadedAllocations.insert(&gfxAllocation);
|
||||
}
|
||||
|
@ -301,6 +301,7 @@ HWTEST_F(CommandStreamReceiverTest, givenGpuHangWhenWaititingForTaskCountThenGpu
|
||||
constexpr auto taskCountToWait = 1;
|
||||
const auto waitStatus = csr.waitForTaskCount(taskCountToWait);
|
||||
EXPECT_EQ(WaitStatus::GpuHang, waitStatus);
|
||||
EXPECT_TRUE(csr.downloadAllocationCalled);
|
||||
}
|
||||
|
||||
HWTEST_F(CommandStreamReceiverTest, givenGpuHangAndNonEmptyAllocationsListWhenCallingWaitForTaskCountAndCleanAllocationListThenWaitIsCalledAndGpuHangIsReturned) {
|
||||
|
Reference in New Issue
Block a user