2020-01-16 00:02:47 +08:00
|
|
|
/*
|
2024-03-22 19:18:35 +08:00
|
|
|
* Copyright (C) 2020-2024 Intel Corporation
|
2020-01-16 00:02:47 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/direct_submission/direct_submission_hw.h"
|
2020-03-27 23:32:07 +08:00
|
|
|
#include "shared/source/direct_submission/direct_submission_hw_diagnostic_mode.h"
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/memory_manager/graphics_allocation.h"
|
2021-09-03 19:40:34 +08:00
|
|
|
#include "shared/test/common/mocks/mock_memory_operations_handler.h"
|
2020-01-16 00:02:47 +08:00
|
|
|
namespace NEO {
|
|
|
|
|
2020-03-27 03:13:10 +08:00
|
|
|
template <typename GfxFamily, typename Dispatcher>
|
|
|
|
struct MockDirectSubmissionHw : public DirectSubmissionHw<GfxFamily, Dispatcher> {
|
|
|
|
using BaseClass = DirectSubmissionHw<GfxFamily, Dispatcher>;
|
2021-09-28 07:27:46 +08:00
|
|
|
using BaseClass::activeTiles;
|
2020-01-16 00:02:47 +08:00
|
|
|
using BaseClass::allocateResources;
|
2022-04-21 01:32:39 +08:00
|
|
|
using BaseClass::completionFenceAllocation;
|
2023-02-22 15:29:42 +08:00
|
|
|
using BaseClass::copyCommandBufferIntoRing;
|
2020-01-16 00:02:47 +08:00
|
|
|
using BaseClass::cpuCachelineFlush;
|
|
|
|
using BaseClass::currentQueueWorkCount;
|
2023-02-02 01:06:21 +08:00
|
|
|
using BaseClass::currentRelaxedOrderingQueueSize;
|
2020-01-16 00:02:47 +08:00
|
|
|
using BaseClass::currentRingBuffer;
|
2022-10-12 02:47:13 +08:00
|
|
|
using BaseClass::dcFlushRequired;
|
2020-01-16 00:02:47 +08:00
|
|
|
using BaseClass::deallocateResources;
|
2022-11-17 01:24:04 +08:00
|
|
|
using BaseClass::deferredTasksListAllocation;
|
2023-11-03 00:30:57 +08:00
|
|
|
using BaseClass::detectGpuHang;
|
2020-03-27 23:32:07 +08:00
|
|
|
using BaseClass::diagnostic;
|
2020-03-27 03:13:10 +08:00
|
|
|
using BaseClass::DirectSubmissionHw;
|
2020-03-27 23:32:07 +08:00
|
|
|
using BaseClass::disableCacheFlush;
|
2020-01-16 00:02:47 +08:00
|
|
|
using BaseClass::disableCpuCacheFlush;
|
2020-03-27 23:32:07 +08:00
|
|
|
using BaseClass::disableMonitorFence;
|
2020-08-18 19:54:23 +08:00
|
|
|
using BaseClass::dispatchDisablePrefetcher;
|
2023-09-20 19:32:46 +08:00
|
|
|
using BaseClass::dispatchMonitorFenceRequired;
|
2021-11-18 03:51:43 +08:00
|
|
|
using BaseClass::dispatchPartitionRegisterConfiguration;
|
2020-08-18 19:54:23 +08:00
|
|
|
using BaseClass::dispatchPrefetchMitigation;
|
2022-11-27 04:10:32 +08:00
|
|
|
using BaseClass::dispatchRelaxedOrderingReturnPtrRegs;
|
2020-01-16 00:02:47 +08:00
|
|
|
using BaseClass::dispatchSemaphoreSection;
|
|
|
|
using BaseClass::dispatchStartSection;
|
|
|
|
using BaseClass::dispatchSwitchRingBufferSection;
|
2023-12-29 19:58:09 +08:00
|
|
|
using BaseClass::dispatchUllsState;
|
2020-03-18 21:14:04 +08:00
|
|
|
using BaseClass::dispatchWorkloadSection;
|
2020-05-19 00:48:43 +08:00
|
|
|
using BaseClass::getDiagnosticModeSection;
|
2020-08-18 19:54:23 +08:00
|
|
|
using BaseClass::getSizeDisablePrefetcher;
|
2020-01-16 00:02:47 +08:00
|
|
|
using BaseClass::getSizeDispatch;
|
2022-11-27 04:10:32 +08:00
|
|
|
using BaseClass::getSizeDispatchRelaxedOrderingQueueStall;
|
2020-01-16 00:02:47 +08:00
|
|
|
using BaseClass::getSizeEnd;
|
2023-06-29 20:53:36 +08:00
|
|
|
using BaseClass::getSizeNewResourceHandler;
|
2021-11-18 03:51:43 +08:00
|
|
|
using BaseClass::getSizePartitionRegisterConfigurationSection;
|
2020-08-18 19:54:23 +08:00
|
|
|
using BaseClass::getSizePrefetchMitigation;
|
2020-01-16 00:02:47 +08:00
|
|
|
using BaseClass::getSizeSemaphoreSection;
|
|
|
|
using BaseClass::getSizeStartSection;
|
|
|
|
using BaseClass::getSizeSwitchRingBufferSection;
|
2022-04-06 22:41:45 +08:00
|
|
|
using BaseClass::getSizeSystemMemoryFenceAddress;
|
2020-03-18 21:14:04 +08:00
|
|
|
using BaseClass::hwInfo;
|
2023-06-06 23:11:09 +08:00
|
|
|
using BaseClass::immWritePostSyncOffset;
|
2023-11-03 00:18:37 +08:00
|
|
|
using BaseClass::inputMonitorFenceDispatchRequirement;
|
2022-11-27 04:10:32 +08:00
|
|
|
using BaseClass::isDisablePrefetcherRequired;
|
2024-03-22 19:18:35 +08:00
|
|
|
using BaseClass::lastSubmittedThrottle;
|
2022-04-06 22:41:45 +08:00
|
|
|
using BaseClass::miMemFenceRequired;
|
2020-01-16 00:02:47 +08:00
|
|
|
using BaseClass::osContext;
|
2021-10-26 19:53:01 +08:00
|
|
|
using BaseClass::partitionConfigSet;
|
2021-09-28 07:27:46 +08:00
|
|
|
using BaseClass::partitionedMode;
|
2023-04-24 17:02:15 +08:00
|
|
|
using BaseClass::pciBarrierPtr;
|
2020-03-27 23:32:07 +08:00
|
|
|
using BaseClass::performDiagnosticMode;
|
2022-11-25 00:57:18 +08:00
|
|
|
using BaseClass::preinitializedRelaxedOrderingScheduler;
|
2022-11-17 01:24:04 +08:00
|
|
|
using BaseClass::preinitializedTaskStoreSection;
|
2023-03-10 02:29:45 +08:00
|
|
|
using BaseClass::relaxedOrderingEnabled;
|
2022-11-17 01:24:04 +08:00
|
|
|
using BaseClass::relaxedOrderingInitialized;
|
2022-11-25 00:57:18 +08:00
|
|
|
using BaseClass::relaxedOrderingSchedulerAllocation;
|
2022-11-27 04:10:32 +08:00
|
|
|
using BaseClass::relaxedOrderingSchedulerRequired;
|
2022-03-26 02:13:00 +08:00
|
|
|
using BaseClass::reserved;
|
2022-06-01 18:05:07 +08:00
|
|
|
using BaseClass::ringBuffers;
|
2020-01-16 00:02:47 +08:00
|
|
|
using BaseClass::ringCommandStream;
|
|
|
|
using BaseClass::ringStart;
|
2023-01-26 03:28:09 +08:00
|
|
|
using BaseClass::rootDeviceEnvironment;
|
2020-01-16 00:02:47 +08:00
|
|
|
using BaseClass::semaphoreData;
|
|
|
|
using BaseClass::semaphoreGpuVa;
|
|
|
|
using BaseClass::semaphorePtr;
|
|
|
|
using BaseClass::semaphores;
|
|
|
|
using BaseClass::setReturnAddress;
|
|
|
|
using BaseClass::stopRingBuffer;
|
|
|
|
using BaseClass::switchRingBuffersAllocations;
|
2023-11-17 21:14:41 +08:00
|
|
|
using BaseClass::switchRingBuffersNeeded;
|
2022-04-06 22:41:45 +08:00
|
|
|
using BaseClass::systemMemoryFenceAddressSet;
|
2023-04-24 17:02:15 +08:00
|
|
|
using BaseClass::unblockGpu;
|
2021-12-23 03:28:02 +08:00
|
|
|
using BaseClass::useNotifyForPostSync;
|
2020-03-27 23:32:07 +08:00
|
|
|
using BaseClass::workloadMode;
|
|
|
|
using BaseClass::workloadModeOneExpectedValue;
|
|
|
|
using BaseClass::workloadModeOneStoreAddress;
|
2021-10-13 05:28:34 +08:00
|
|
|
using BaseClass::workPartitionAllocation;
|
2020-01-16 00:02:47 +08:00
|
|
|
using typename BaseClass::RingBufferUse;
|
|
|
|
|
2020-02-20 21:43:22 +08:00
|
|
|
~MockDirectSubmissionHw() override {
|
2020-01-16 00:02:47 +08:00
|
|
|
if (ringStart) {
|
2023-07-05 16:55:12 +08:00
|
|
|
stopRingBuffer(false);
|
2020-01-16 00:02:47 +08:00
|
|
|
}
|
|
|
|
deallocateResources();
|
|
|
|
}
|
|
|
|
|
2020-07-17 17:28:59 +08:00
|
|
|
bool allocateOsResources() override {
|
2020-01-16 00:02:47 +08:00
|
|
|
return allocateOsResourcesReturn;
|
|
|
|
}
|
|
|
|
|
2022-11-25 00:57:18 +08:00
|
|
|
void preinitializeRelaxedOrderingSections() override {
|
|
|
|
preinitializeRelaxedOrderingSectionsCalled++;
|
|
|
|
BaseClass::preinitializeRelaxedOrderingSections();
|
|
|
|
}
|
|
|
|
|
|
|
|
void dispatchStaticRelaxedOrderingScheduler() override {
|
|
|
|
dispatchStaticRelaxedOrderingSchedulerCalled++;
|
|
|
|
BaseClass::dispatchStaticRelaxedOrderingScheduler();
|
2022-11-17 01:24:04 +08:00
|
|
|
}
|
|
|
|
|
2022-11-27 04:10:32 +08:00
|
|
|
void dispatchRelaxedOrderingSchedulerSection(uint32_t value) override {
|
|
|
|
dispatchRelaxedOrderingSchedulerSectionCalled++;
|
|
|
|
BaseClass::dispatchRelaxedOrderingSchedulerSection(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
void dispatchRelaxedOrderingQueueStall() override {
|
|
|
|
dispatchRelaxedOrderingQueueStallCalled++;
|
|
|
|
BaseClass::dispatchRelaxedOrderingQueueStall();
|
|
|
|
}
|
|
|
|
|
|
|
|
void dispatchTaskStoreSection(uint64_t taskStartSectionVa) override {
|
|
|
|
dispatchTaskStoreSectionCalled++;
|
|
|
|
BaseClass::dispatchTaskStoreSection(taskStartSectionVa);
|
|
|
|
}
|
|
|
|
|
2023-10-06 19:47:33 +08:00
|
|
|
void ensureRingCompletion() override {
|
|
|
|
ensureRingCompletionCalled++;
|
|
|
|
BaseClass::ensureRingCompletion();
|
|
|
|
}
|
|
|
|
|
2020-07-17 17:28:59 +08:00
|
|
|
bool makeResourcesResident(DirectSubmissionAllocations &allocations) override {
|
2021-10-13 05:28:34 +08:00
|
|
|
makeResourcesResidentVectorSize = static_cast<uint32_t>(allocations.size());
|
2021-09-03 19:40:34 +08:00
|
|
|
if (callBaseResident) {
|
|
|
|
return BaseClass::makeResourcesResident(allocations);
|
|
|
|
}
|
2020-07-17 17:28:59 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-01-16 00:02:47 +08:00
|
|
|
bool submit(uint64_t gpuAddress, size_t size) override {
|
|
|
|
submitGpuAddress = gpuAddress;
|
|
|
|
submitSize = size;
|
|
|
|
submitCount++;
|
|
|
|
return submitReturn;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool handleResidency() override {
|
|
|
|
handleResidencyCount++;
|
|
|
|
return handleResidencyReturn;
|
|
|
|
}
|
|
|
|
|
2023-11-17 21:14:41 +08:00
|
|
|
void handleSwitchRingBuffers(ResidencyContainer *allocationsForResidency) override {}
|
2020-01-16 00:02:47 +08:00
|
|
|
|
2023-09-20 20:54:50 +08:00
|
|
|
uint64_t updateTagValue(bool requireMonitorFence) override {
|
2020-01-16 00:02:47 +08:00
|
|
|
return updateTagValueReturn;
|
|
|
|
}
|
|
|
|
|
|
|
|
void getTagAddressValue(TagData &tagData) override {
|
|
|
|
tagData.tagAddress = tagAddressSetValue;
|
|
|
|
tagData.tagValue = tagValueSetValue;
|
|
|
|
}
|
|
|
|
|
2020-03-27 23:32:07 +08:00
|
|
|
void performDiagnosticMode() override {
|
|
|
|
if (!NEO::directSubmissionDiagnosticAvailable) {
|
|
|
|
disabledDiagnosticCalled++;
|
|
|
|
}
|
|
|
|
uint32_t add = 1;
|
|
|
|
if (diagnostic.get()) {
|
|
|
|
add += diagnostic->getExecutionsCount();
|
|
|
|
}
|
|
|
|
*static_cast<volatile uint32_t *>(workloadModeOneStoreAddress) = workloadModeOneExpectedValue + add;
|
|
|
|
BaseClass::performDiagnosticMode();
|
|
|
|
}
|
|
|
|
|
2022-06-01 18:05:07 +08:00
|
|
|
bool isCompleted(uint32_t ringBufferIndex) override {
|
|
|
|
return this->isCompletedReturn;
|
|
|
|
}
|
|
|
|
|
2024-08-07 00:13:06 +08:00
|
|
|
void unblockPagingFenceSemaphore(uint64_t pagingFenceValue) override {
|
|
|
|
this->pagingFenceValueToWait = pagingFenceValue;
|
|
|
|
}
|
|
|
|
|
2020-01-16 00:02:47 +08:00
|
|
|
uint64_t updateTagValueReturn = 1ull;
|
|
|
|
uint64_t tagAddressSetValue = MemoryConstants::pageSize;
|
|
|
|
uint64_t tagValueSetValue = 1ull;
|
|
|
|
uint64_t submitGpuAddress = 0ull;
|
2024-08-07 00:13:06 +08:00
|
|
|
uint64_t pagingFenceValueToWait = 0ull;
|
2020-03-27 23:32:07 +08:00
|
|
|
size_t submitSize = 0u;
|
|
|
|
uint32_t submitCount = 0u;
|
|
|
|
uint32_t handleResidencyCount = 0u;
|
|
|
|
uint32_t disabledDiagnosticCalled = 0u;
|
2022-11-25 00:57:18 +08:00
|
|
|
uint32_t preinitializeRelaxedOrderingSectionsCalled = 0;
|
|
|
|
uint32_t dispatchStaticRelaxedOrderingSchedulerCalled = 0;
|
2022-11-27 04:10:32 +08:00
|
|
|
uint32_t dispatchRelaxedOrderingSchedulerSectionCalled = 0;
|
|
|
|
uint32_t dispatchRelaxedOrderingQueueStallCalled = 0;
|
|
|
|
uint32_t dispatchTaskStoreSectionCalled = 0;
|
2023-10-06 19:47:33 +08:00
|
|
|
uint32_t ensureRingCompletionCalled = 0;
|
2021-10-13 05:28:34 +08:00
|
|
|
uint32_t makeResourcesResidentVectorSize = 0u;
|
2020-03-27 23:32:07 +08:00
|
|
|
bool allocateOsResourcesReturn = true;
|
|
|
|
bool submitReturn = true;
|
|
|
|
bool handleResidencyReturn = true;
|
2021-09-03 19:40:34 +08:00
|
|
|
bool callBaseResident = false;
|
2022-06-01 18:05:07 +08:00
|
|
|
bool isCompletedReturn = true;
|
2020-01-16 00:02:47 +08:00
|
|
|
};
|
|
|
|
} // namespace NEO
|