2018-12-19 20:15:14 +08:00
|
|
|
/*
|
2023-01-02 19:14:39 +08:00
|
|
|
* Copyright (C) 2018-2023 Intel Corporation
|
2018-12-19 20:15:14 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/command_stream/preemption.h"
|
2023-01-02 19:14:39 +08:00
|
|
|
#include "shared/source/command_stream/submission_status.h"
|
2021-05-31 17:28:07 +08:00
|
|
|
#include "shared/source/command_stream/tbx_command_stream_receiver_hw.h"
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/execution_environment/execution_environment.h"
|
2018-12-19 20:15:14 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2018-12-19 20:15:14 +08:00
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
class MockTbxCsr : public TbxCommandStreamReceiverHw<GfxFamily> {
|
|
|
|
public:
|
2019-02-06 20:32:49 +08:00
|
|
|
using TbxCommandStreamReceiverHw<GfxFamily>::writeMemory;
|
2019-04-18 18:37:57 +08:00
|
|
|
using TbxCommandStreamReceiverHw<GfxFamily>::allocationsForDownload;
|
2020-10-29 22:33:35 +08:00
|
|
|
MockTbxCsr(ExecutionEnvironment &executionEnvironment, const DeviceBitfield deviceBitfield)
|
2022-03-29 23:31:51 +08:00
|
|
|
: TbxCommandStreamReceiverHw<GfxFamily>(executionEnvironment, 0, deviceBitfield) {
|
|
|
|
this->downloadAllocationImpl = [this](GraphicsAllocation &gfxAllocation) {
|
|
|
|
this->downloadAllocationTbxMock(gfxAllocation);
|
|
|
|
};
|
|
|
|
}
|
2022-05-10 01:40:30 +08:00
|
|
|
~MockTbxCsr() override {
|
2022-03-29 23:31:51 +08:00
|
|
|
this->downloadAllocationImpl = nullptr;
|
|
|
|
}
|
2018-12-19 20:15:14 +08:00
|
|
|
|
2021-10-14 20:49:06 +08:00
|
|
|
void initializeEngine() override {
|
2019-01-29 18:48:54 +08:00
|
|
|
TbxCommandStreamReceiverHw<GfxFamily>::initializeEngine();
|
2018-12-19 20:15:14 +08:00
|
|
|
initializeEngineCalled = true;
|
|
|
|
}
|
2019-02-06 20:32:49 +08:00
|
|
|
|
|
|
|
void writeMemoryWithAubManager(GraphicsAllocation &graphicsAllocation) override {
|
|
|
|
CommandStreamReceiverSimulatedHw<GfxFamily>::writeMemoryWithAubManager(graphicsAllocation);
|
|
|
|
writeMemoryWithAubManagerCalled = true;
|
|
|
|
}
|
|
|
|
|
2019-02-15 18:31:47 +08:00
|
|
|
void writeMemory(uint64_t gpuAddress, void *cpuAddress, size_t size, uint32_t memoryBank, uint64_t entryBits) override {
|
|
|
|
TbxCommandStreamReceiverHw<GfxFamily>::writeMemory(gpuAddress, cpuAddress, size, memoryBank, entryBits);
|
2018-12-19 20:15:14 +08:00
|
|
|
writeMemoryCalled = true;
|
|
|
|
}
|
2021-06-21 23:24:14 +08:00
|
|
|
void submitBatchBufferTbx(uint64_t batchBufferGpuAddress, const void *batchBuffer, size_t batchBufferSize, uint32_t memoryBank, uint64_t entryBits, bool overrideRingHead) override {
|
|
|
|
TbxCommandStreamReceiverHw<GfxFamily>::submitBatchBufferTbx(batchBufferGpuAddress, batchBuffer, batchBufferSize, memoryBank, entryBits, overrideRingHead);
|
2019-10-17 17:32:55 +08:00
|
|
|
overrideRingHeadPassed = overrideRingHead;
|
2018-12-19 20:15:14 +08:00
|
|
|
submitBatchBufferCalled = true;
|
|
|
|
}
|
2019-01-28 21:20:58 +08:00
|
|
|
void pollForCompletion() override {
|
|
|
|
TbxCommandStreamReceiverHw<GfxFamily>::pollForCompletion();
|
2018-12-19 20:15:14 +08:00
|
|
|
pollForCompletionCalled = true;
|
|
|
|
}
|
2022-03-29 23:31:51 +08:00
|
|
|
void downloadAllocationTbxMock(GraphicsAllocation &gfxAllocation) {
|
|
|
|
TbxCommandStreamReceiverHw<GfxFamily>::downloadAllocationTbx(gfxAllocation);
|
2018-12-19 20:15:14 +08:00
|
|
|
makeCoherentCalled = true;
|
|
|
|
}
|
2020-04-15 21:30:29 +08:00
|
|
|
void dumpAllocation(GraphicsAllocation &gfxAllocation) override {
|
|
|
|
TbxCommandStreamReceiverHw<GfxFamily>::dumpAllocation(gfxAllocation);
|
|
|
|
dumpAllocationCalled = true;
|
|
|
|
}
|
2018-12-19 20:15:14 +08:00
|
|
|
bool initializeEngineCalled = false;
|
2019-02-06 20:32:49 +08:00
|
|
|
bool writeMemoryWithAubManagerCalled = false;
|
2018-12-19 20:15:14 +08:00
|
|
|
bool writeMemoryCalled = false;
|
|
|
|
bool submitBatchBufferCalled = false;
|
2019-10-17 17:32:55 +08:00
|
|
|
bool overrideRingHeadPassed = false;
|
2018-12-19 20:15:14 +08:00
|
|
|
bool pollForCompletionCalled = false;
|
|
|
|
bool expectMemoryEqualCalled = false;
|
|
|
|
bool expectMemoryNotEqualCalled = false;
|
|
|
|
bool makeCoherentCalled = false;
|
2020-04-15 21:30:29 +08:00
|
|
|
bool dumpAllocationCalled = false;
|
2018-12-19 20:15:14 +08:00
|
|
|
};
|
2020-05-06 17:52:48 +08:00
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
struct MockTbxCsrRegisterDownloadedAllocations : TbxCommandStreamReceiverHw<GfxFamily> {
|
|
|
|
using CommandStreamReceiver::latestFlushedTaskCount;
|
2021-02-25 16:38:48 +08:00
|
|
|
using CommandStreamReceiver::tagsMultiAllocation;
|
2021-11-24 19:27:50 +08:00
|
|
|
using TbxCommandStreamReceiverHw<GfxFamily>::flushSubmissionsAndDownloadAllocations;
|
2022-03-29 23:31:51 +08:00
|
|
|
|
|
|
|
MockTbxCsrRegisterDownloadedAllocations(ExecutionEnvironment &executionEnvironment, uint32_t rootDeviceIndex, const DeviceBitfield deviceBitfield)
|
|
|
|
: TbxCommandStreamReceiverHw<GfxFamily>(executionEnvironment, rootDeviceIndex, deviceBitfield) {
|
|
|
|
this->downloadAllocationImpl = [this](GraphicsAllocation &gfxAllocation) {
|
|
|
|
this->downloadAllocationTbxMock(gfxAllocation);
|
|
|
|
};
|
|
|
|
}
|
2022-05-10 01:40:30 +08:00
|
|
|
~MockTbxCsrRegisterDownloadedAllocations() override {
|
2022-03-29 23:31:51 +08:00
|
|
|
this->downloadAllocationImpl = nullptr;
|
|
|
|
}
|
|
|
|
void downloadAllocationTbxMock(GraphicsAllocation &gfxAllocation) {
|
2022-11-22 21:53:59 +08:00
|
|
|
*reinterpret_cast<TaskCountType *>(CommandStreamReceiver::getTagAllocation()->getUnderlyingBuffer()) = this->latestFlushedTaskCount;
|
2020-05-06 17:52:48 +08:00
|
|
|
downloadedAllocations.insert(&gfxAllocation);
|
|
|
|
}
|
|
|
|
bool flushBatchedSubmissions() override {
|
|
|
|
flushBatchedSubmissionsCalled = true;
|
|
|
|
return true;
|
|
|
|
}
|
2022-11-09 19:18:06 +08:00
|
|
|
SubmissionStatus flushTagUpdate() override {
|
2021-11-24 19:27:50 +08:00
|
|
|
flushTagCalled = true;
|
2022-11-09 19:18:06 +08:00
|
|
|
return SubmissionStatus::SUCCESS;
|
2021-11-24 19:27:50 +08:00
|
|
|
}
|
2022-02-15 22:57:50 +08:00
|
|
|
|
|
|
|
std::unique_lock<CommandStreamReceiver::MutexType> obtainUniqueOwnership() override {
|
|
|
|
obtainUniqueOwnershipCalled++;
|
|
|
|
return TbxCommandStreamReceiverHw<GfxFamily>::obtainUniqueOwnership();
|
|
|
|
}
|
2020-05-06 17:52:48 +08:00
|
|
|
std::set<GraphicsAllocation *> downloadedAllocations;
|
|
|
|
bool flushBatchedSubmissionsCalled = false;
|
2021-11-24 19:27:50 +08:00
|
|
|
bool flushTagCalled = false;
|
2022-02-15 22:57:50 +08:00
|
|
|
size_t obtainUniqueOwnershipCalled = 0;
|
2020-05-06 17:52:48 +08:00
|
|
|
};
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|