2018-12-19 20:15:14 +08:00
|
|
|
/*
|
2024-12-24 05:42:43 +08:00
|
|
|
* Copyright (C) 2018-2025 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"
|
2024-12-24 05:42:43 +08:00
|
|
|
#include "shared/source/page_fault_manager/cpu_page_fault_manager.h"
|
|
|
|
#include "shared/source/page_fault_manager/tbx_page_fault_manager.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;
|
2024-12-24 05:42:43 +08:00
|
|
|
using TbxCommandStreamReceiverHw<GfxFamily>::getParametersForMemory;
|
|
|
|
using TbxCommandStreamReceiverHw<GfxFamily>::getTbxPageFaultManager;
|
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
|
|
|
|
2023-10-18 21:54:46 +08:00
|
|
|
void writeMemoryWithAubManager(GraphicsAllocation &graphicsAllocation, bool isChunkCopy, uint64_t gpuVaChunkOffset, size_t chunkSize) override {
|
|
|
|
CommandStreamReceiverSimulatedHw<GfxFamily>::writeMemoryWithAubManager(graphicsAllocation, isChunkCopy, gpuVaChunkOffset, chunkSize);
|
2019-02-06 20:32:49 +08:00
|
|
|
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;
|
|
|
|
}
|
2024-06-14 22:15:14 +08:00
|
|
|
bool writeMemory(GraphicsAllocation &graphicsAllocation) override {
|
|
|
|
writeMemoryGfxAllocCalled = true;
|
|
|
|
return TbxCommandStreamReceiverHw<GfxFamily>::writeMemory(graphicsAllocation);
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
2024-11-20 20:36:45 +08:00
|
|
|
void pollForCompletion(bool skipTaskCountCheck) override {
|
|
|
|
TbxCommandStreamReceiverHw<GfxFamily>::pollForCompletion(skipTaskCountCheck);
|
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;
|
|
|
|
}
|
2024-12-24 05:42:43 +08:00
|
|
|
|
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;
|
2024-06-14 22:15:14 +08:00
|
|
|
bool writeMemoryGfxAllocCalled = false;
|
2018-12-19 20:15:14 +08:00
|
|
|
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> {
|
2024-08-28 21:59:25 +08:00
|
|
|
using CommandStreamReceiver::downloadAllocationImpl;
|
|
|
|
using CommandStreamReceiver::downloadAllocations;
|
2020-05-06 17:52:48 +08:00
|
|
|
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;
|
2023-12-13 17:17:24 +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();
|
|
|
|
}
|
2024-09-09 23:31:32 +08:00
|
|
|
|
|
|
|
uint64_t getNonBlockingDownloadTimeoutMs() const override {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
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
|