Allow Device creating multiple CSRs [5/n]

- Move Engine type to OsContext
- Move OsContext to CSR
- Improve EngineMapper logic
- CompletionStamp cleanup

Change-Id: I935cb7169c8c48cd09837e20e3da06f6dd3437b9
Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com>
This commit is contained in:
Dunajski, Bartosz
2018-11-26 14:04:52 +01:00
committed by sys_ocldev
parent 9a89426ec1
commit 2d77b86e70
98 changed files with 467 additions and 751 deletions

View File

@@ -144,7 +144,7 @@ void CommandQueue::waitUntilComplete(uint32_t taskCountToWait, FlushStamp flushS
bool forcePowerSavingMode = this->throttle == QueueThrottle::LOW; bool forcePowerSavingMode = this->throttle == QueueThrottle::LOW;
getCommandStreamReceiver().waitForTaskCountWithKmdNotifyFallback(taskCountToWait, flushStampToWait, useQuickKmdSleep, *device->getOsContext(), forcePowerSavingMode); getCommandStreamReceiver().waitForTaskCountWithKmdNotifyFallback(taskCountToWait, flushStampToWait, useQuickKmdSleep, forcePowerSavingMode);
DEBUG_BREAK_IF(getHwTag() < taskCountToWait); DEBUG_BREAK_IF(getHwTag() < taskCountToWait);
latestTaskCountWaited = taskCountToWait; latestTaskCountWaited = taskCountToWait;

View File

@@ -27,6 +27,7 @@
#include "runtime/memory_manager/internal_allocation_storage.h" #include "runtime/memory_manager/internal_allocation_storage.h"
#include "runtime/memory_manager/memory_manager.h" #include "runtime/memory_manager/memory_manager.h"
#include "runtime/memory_manager/surface.h" #include "runtime/memory_manager/surface.h"
#include "runtime/os_interface/os_context.h"
#include "runtime/program/printf_handler.h" #include "runtime/program/printf_handler.h"
#include "runtime/program/block_kernel_manager.h" #include "runtime/program/block_kernel_manager.h"
#include "runtime/utilities/range.h" #include "runtime/utilities/range.h"
@@ -170,7 +171,6 @@ void CommandQueueHw<GfxFamily>::enqueueHandler(Surface **surfacesForResidency,
KernelOperation *blockedCommandsData = nullptr; KernelOperation *blockedCommandsData = nullptr;
std::unique_ptr<PrintfHandler> printfHandler; std::unique_ptr<PrintfHandler> printfHandler;
bool slmUsed = false; bool slmUsed = false;
EngineType engineType = device->getEngineType();
auto preemption = PreemptionHelper::taskPreemptionMode(*device, multiDispatchInfo); auto preemption = PreemptionHelper::taskPreemptionMode(*device, multiDispatchInfo);
TakeOwnershipWrapper<CommandQueueHw<GfxFamily>> queueOwnership(*this); TakeOwnershipWrapper<CommandQueueHw<GfxFamily>> queueOwnership(*this);
@@ -394,11 +394,7 @@ void CommandQueueHw<GfxFamily>::enqueueHandler(Surface **surfacesForResidency,
} }
} }
} else { } else {
CompletionStamp cmplStamp = { CompletionStamp cmplStamp = {Event::eventNotReady, taskLevel, 0};
Event::eventNotReady,
taskLevel,
0,
engineType};
completionStamp = cmplStamp; completionStamp = cmplStamp;
} }
updateFromCompletionStamp(completionStamp); updateFromCompletionStamp(completionStamp);

View File

@@ -26,15 +26,16 @@ class AUBCommandStreamReceiverHw : public CommandStreamReceiverSimulatedHw<GfxFa
typedef typename AUBFamilyMapper<GfxFamily>::AUB AUB; typedef typename AUBFamilyMapper<GfxFamily>::AUB AUB;
typedef typename AUB::MiContextDescriptorReg MiContextDescriptorReg; typedef typename AUB::MiContextDescriptorReg MiContextDescriptorReg;
using ExternalAllocationsContainer = std::vector<AllocationView>; using ExternalAllocationsContainer = std::vector<AllocationView>;
using BaseClass::osContext;
public: public:
using CommandStreamReceiverSimulatedCommonHw<GfxFamily>::initAdditionalMMIO; using CommandStreamReceiverSimulatedCommonHw<GfxFamily>::initAdditionalMMIO;
using CommandStreamReceiverSimulatedCommonHw<GfxFamily>::stream; using CommandStreamReceiverSimulatedCommonHw<GfxFamily>::stream;
FlushStamp flush(BatchBuffer &batchBuffer, EngineType engineType, ResidencyContainer &allocationsForResidency, OsContext &osContext) override; FlushStamp flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) override;
void makeNonResident(GraphicsAllocation &gfxAllocation) override; void makeNonResident(GraphicsAllocation &gfxAllocation) override;
void processResidency(ResidencyContainer &allocationsForResidency, OsContext &osContext) override; void processResidency(ResidencyContainer &allocationsForResidency) override;
void makeResidentExternal(AllocationView &allocationView); void makeResidentExternal(AllocationView &allocationView);
void makeNonResidentExternal(uint64_t gpuAddress); void makeNonResidentExternal(uint64_t gpuAddress);

View File

@@ -23,6 +23,7 @@
#include "runtime/memory_manager/memory_banks.h" #include "runtime/memory_manager/memory_banks.h"
#include "runtime/memory_manager/os_agnostic_memory_manager.h" #include "runtime/memory_manager/os_agnostic_memory_manager.h"
#include "runtime/os_interface/debug_settings_manager.h" #include "runtime/os_interface/debug_settings_manager.h"
#include "runtime/os_interface/os_context.h"
#include "driver_version.h" #include "driver_version.h"
#include <algorithm> #include <algorithm>
@@ -313,8 +314,7 @@ CommandStreamReceiver *AUBCommandStreamReceiverHw<GfxFamily>::create(const Hardw
} }
template <typename GfxFamily> template <typename GfxFamily>
FlushStamp AUBCommandStreamReceiverHw<GfxFamily>::flush(BatchBuffer &batchBuffer, FlushStamp AUBCommandStreamReceiverHw<GfxFamily>::flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) {
EngineType engineType, ResidencyContainer &allocationsForResidency, OsContext &osContext) {
if (subCaptureManager->isSubCaptureMode()) { if (subCaptureManager->isSubCaptureMode()) {
if (!subCaptureManager->isSubCaptureEnabled()) { if (!subCaptureManager->isSubCaptureEnabled()) {
if (this->standalone) { if (this->standalone) {
@@ -325,7 +325,7 @@ FlushStamp AUBCommandStreamReceiverHw<GfxFamily>::flush(BatchBuffer &batchBuffer
} }
auto streamLocked = getAubStream()->lockStream(); auto streamLocked = getAubStream()->lockStream();
auto engineIndex = getEngineIndex(engineType); auto engineIndex = getEngineIndex(osContext->getEngineType().type);
auto engineInstance = allEngineInstances[engineIndex]; auto engineInstance = allEngineInstances[engineIndex];
initializeEngine(engineIndex); initializeEngine(engineIndex);
@@ -358,7 +358,7 @@ FlushStamp AUBCommandStreamReceiverHw<GfxFamily>::flush(BatchBuffer &batchBuffer
batchBuffer.commandBufferAllocation->updateResidencyTaskCount(this->taskCount, this->deviceIndex); batchBuffer.commandBufferAllocation->updateResidencyTaskCount(this->taskCount, this->deviceIndex);
} }
} }
processResidency(allocationsForResidency, osContext); processResidency(allocationsForResidency);
submitBatchBuffer(engineIndex, batchBufferGpuAddress, pBatchBuffer, sizeBatchBuffer, this->getMemoryBank(batchBuffer.commandBufferAllocation), getPPGTTAdditionalBits(batchBuffer.commandBufferAllocation)); submitBatchBuffer(engineIndex, batchBufferGpuAddress, pBatchBuffer, sizeBatchBuffer, this->getMemoryBank(batchBuffer.commandBufferAllocation), getPPGTTAdditionalBits(batchBuffer.commandBufferAllocation));
@@ -711,7 +711,7 @@ void AUBCommandStreamReceiverHw<GfxFamily>::expectMemory(void *gfxAddress, const
} }
template <typename GfxFamily> template <typename GfxFamily>
void AUBCommandStreamReceiverHw<GfxFamily>::processResidency(ResidencyContainer &allocationsForResidency, OsContext &osContext) { void AUBCommandStreamReceiverHw<GfxFamily>::processResidency(ResidencyContainer &allocationsForResidency) {
if (subCaptureManager->isSubCaptureMode()) { if (subCaptureManager->isSubCaptureMode()) {
if (!subCaptureManager->isSubCaptureEnabled()) { if (!subCaptureManager->isSubCaptureEnabled()) {
return; return;

View File

@@ -70,7 +70,7 @@ void CommandStreamReceiver::makeResident(GraphicsAllocation &gfxAllocation) {
gfxAllocation.updateResidencyTaskCount(submissionTaskCount, deviceIndex); gfxAllocation.updateResidencyTaskCount(submissionTaskCount, deviceIndex);
} }
void CommandStreamReceiver::processEviction(OsContext &osContext) { void CommandStreamReceiver::processEviction() {
this->getEvictionAllocations().clear(); this->getEvictionAllocations().clear();
} }
@@ -87,14 +87,14 @@ void CommandStreamReceiver::makeNonResident(GraphicsAllocation &gfxAllocation) {
gfxAllocation.resetResidencyTaskCount(this->deviceIndex); gfxAllocation.resetResidencyTaskCount(this->deviceIndex);
} }
void CommandStreamReceiver::makeSurfacePackNonResident(ResidencyContainer &allocationsForResidency, OsContext &osContext) { void CommandStreamReceiver::makeSurfacePackNonResident(ResidencyContainer &allocationsForResidency) {
this->waitBeforeMakingNonResidentWhenRequired(); this->waitBeforeMakingNonResidentWhenRequired();
for (auto &surface : allocationsForResidency) { for (auto &surface : allocationsForResidency) {
this->makeNonResident(*surface); this->makeNonResident(*surface);
} }
allocationsForResidency.clear(); allocationsForResidency.clear();
this->processEviction(osContext); this->processEviction();
} }
void CommandStreamReceiver::makeResidentHostPtrAllocation(GraphicsAllocation *gfxAllocation) { void CommandStreamReceiver::makeResidentHostPtrAllocation(GraphicsAllocation *gfxAllocation) {

View File

@@ -55,7 +55,7 @@ class CommandStreamReceiver {
CommandStreamReceiver(ExecutionEnvironment &executionEnvironment); CommandStreamReceiver(ExecutionEnvironment &executionEnvironment);
virtual ~CommandStreamReceiver(); virtual ~CommandStreamReceiver();
virtual FlushStamp flush(BatchBuffer &batchBuffer, EngineType engineType, ResidencyContainer &allocationsForResidency, OsContext &osContext) = 0; virtual FlushStamp flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) = 0;
virtual CompletionStamp flushTask(LinearStream &commandStream, size_t commandStreamStart, virtual CompletionStamp flushTask(LinearStream &commandStream, size_t commandStreamStart,
const IndirectHeap &dsh, const IndirectHeap &ioh, const IndirectHeap &ssh, const IndirectHeap &dsh, const IndirectHeap &ioh, const IndirectHeap &ssh,
@@ -66,9 +66,9 @@ class CommandStreamReceiver {
virtual void makeCoherent(GraphicsAllocation &gfxAllocation){}; virtual void makeCoherent(GraphicsAllocation &gfxAllocation){};
virtual void makeResident(GraphicsAllocation &gfxAllocation); virtual void makeResident(GraphicsAllocation &gfxAllocation);
virtual void makeNonResident(GraphicsAllocation &gfxAllocation); virtual void makeNonResident(GraphicsAllocation &gfxAllocation);
void makeSurfacePackNonResident(ResidencyContainer &allocationsForResidency, OsContext &osContext); void makeSurfacePackNonResident(ResidencyContainer &allocationsForResidency);
virtual void processResidency(ResidencyContainer &allocationsForResidency, OsContext &osContext) {} virtual void processResidency(ResidencyContainer &allocationsForResidency) {}
virtual void processEviction(OsContext &osContext); virtual void processEviction();
void makeResidentHostPtrAllocation(GraphicsAllocation *gfxAllocation); void makeResidentHostPtrAllocation(GraphicsAllocation *gfxAllocation);
virtual void waitBeforeMakingNonResidentWhenRequired() {} virtual void waitBeforeMakingNonResidentWhenRequired() {}
@@ -93,7 +93,7 @@ class CommandStreamReceiver {
} }
volatile uint32_t *getTagAddress() const { return tagAddress; } volatile uint32_t *getTagAddress() const { return tagAddress; }
virtual bool waitForFlushStamp(FlushStamp &flushStampToWait, OsContext &osContext) { return true; }; virtual bool waitForFlushStamp(FlushStamp &flushStampToWait) { return true; };
uint32_t peekTaskCount() const { return taskCount; } uint32_t peekTaskCount() const { return taskCount; }
@@ -119,7 +119,7 @@ class CommandStreamReceiver {
void requestThreadArbitrationPolicy(uint32_t requiredPolicy) { this->requiredThreadArbitrationPolicy = requiredPolicy; } void requestThreadArbitrationPolicy(uint32_t requiredPolicy) { this->requiredThreadArbitrationPolicy = requiredPolicy; }
void requestStallingPipeControlOnNextFlush() { stallingPipeControlOnNextFlushRequired = true; } void requestStallingPipeControlOnNextFlush() { stallingPipeControlOnNextFlushRequired = true; }
virtual void waitForTaskCountWithKmdNotifyFallback(uint32_t taskCountToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep, OsContext &osContext, bool forcePowerSavingMode) = 0; virtual void waitForTaskCountWithKmdNotifyFallback(uint32_t taskCountToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep, bool forcePowerSavingMode) = 0;
MOCKABLE_VIRTUAL bool waitForCompletionWithTimeout(bool enableTimeout, int64_t timeoutMicroseconds, uint32_t taskCountToWait); MOCKABLE_VIRTUAL bool waitForCompletionWithTimeout(bool enableTimeout, int64_t timeoutMicroseconds, uint32_t taskCountToWait);
void setSamplerCacheFlushRequired(SamplerCacheFlushState value) { this->samplerCacheFlushRequired = value; } void setSamplerCacheFlushRequired(SamplerCacheFlushState value) { this->samplerCacheFlushRequired = value; }
@@ -155,6 +155,8 @@ class CommandStreamReceiver {
InternalAllocationStorage *getInternalAllocationStorage() const { return internalAllocationStorage.get(); } InternalAllocationStorage *getInternalAllocationStorage() const { return internalAllocationStorage.get(); }
bool createAllocationForHostSurface(HostPtrSurface &surface, Device &device, bool requiresL3Flush); bool createAllocationForHostSurface(HostPtrSurface &surface, Device &device, bool requiresL3Flush);
virtual size_t getPreferredTagPoolSize() const { return 512; } virtual size_t getPreferredTagPoolSize() const { return 512; }
void setOsContext(OsContext *osContext) { this->osContext = osContext; }
OsContext &getOsContext() const { return *osContext; }
protected: protected:
void cleanupResources(); void cleanupResources();
@@ -191,6 +193,7 @@ class CommandStreamReceiver {
std::atomic<uint32_t> latestSentTaskCount{0}; std::atomic<uint32_t> latestSentTaskCount{0};
std::atomic<uint32_t> latestFlushedTaskCount{0}; std::atomic<uint32_t> latestFlushedTaskCount{0};
OsContext *osContext = nullptr;
DispatchMode dispatchMode = DispatchMode::ImmediateDispatch; DispatchMode dispatchMode = DispatchMode::ImmediateDispatch;
SamplerCacheFlushState samplerCacheFlushRequired = SamplerCacheFlushState::samplerCacheFlushNotRequired; SamplerCacheFlushState samplerCacheFlushRequired = SamplerCacheFlushState::samplerCacheFlushNotRequired;
PreemptionMode lastPreemptionMode = PreemptionMode::Initial; PreemptionMode lastPreemptionMode = PreemptionMode::Initial;

View File

@@ -28,7 +28,7 @@ class CommandStreamReceiverHw : public CommandStreamReceiver {
CommandStreamReceiverHw(const HardwareInfo &hwInfoIn, ExecutionEnvironment &executionEnvironment); CommandStreamReceiverHw(const HardwareInfo &hwInfoIn, ExecutionEnvironment &executionEnvironment);
FlushStamp flush(BatchBuffer &batchBuffer, EngineType engineType, ResidencyContainer &allocationsForResidency, OsContext &osContext) override; FlushStamp flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) override;
CompletionStamp flushTask(LinearStream &commandStream, size_t commandStreamStart, CompletionStamp flushTask(LinearStream &commandStream, size_t commandStreamStart,
const IndirectHeap &dsh, const IndirectHeap &ioh, const IndirectHeap &ssh, const IndirectHeap &dsh, const IndirectHeap &ioh, const IndirectHeap &ssh,
@@ -54,7 +54,7 @@ class CommandStreamReceiverHw : public CommandStreamReceiver {
size_t getCmdSizeForMediaSampler(bool mediaSamplerRequired) const; size_t getCmdSizeForMediaSampler(bool mediaSamplerRequired) const;
void programComputeMode(LinearStream &csr, DispatchFlags &dispatchFlags); void programComputeMode(LinearStream &csr, DispatchFlags &dispatchFlags);
void waitForTaskCountWithKmdNotifyFallback(uint32_t taskCountToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep, OsContext &osContext, bool forcePowerSavingMode) override; void waitForTaskCountWithKmdNotifyFallback(uint32_t taskCountToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep, bool forcePowerSavingMode) override;
const HardwareInfo &peekHwInfo() const { return hwInfo; } const HardwareInfo &peekHwInfo() const { return hwInfo; }
void collectStateBaseAddresPatchInfo( void collectStateBaseAddresPatchInfo(

View File

@@ -23,6 +23,7 @@
#include "runtime/memory_manager/internal_allocation_storage.h" #include "runtime/memory_manager/internal_allocation_storage.h"
#include "runtime/memory_manager/memory_manager.h" #include "runtime/memory_manager/memory_manager.h"
#include "runtime/os_interface/debug_settings_manager.h" #include "runtime/os_interface/debug_settings_manager.h"
#include "runtime/os_interface/os_context.h"
#include "runtime/command_stream/preemption.h" #include "runtime/command_stream/preemption.h"
#include "runtime/command_queue/gpgpu_walker.h" #include "runtime/command_queue/gpgpu_walker.h"
#include "runtime/utilities/tag_allocator.h" #include "runtime/utilities/tag_allocator.h"
@@ -53,7 +54,7 @@ CommandStreamReceiverHw<GfxFamily>::CommandStreamReceiverHw(const HardwareInfo &
} }
template <typename GfxFamily> template <typename GfxFamily>
FlushStamp CommandStreamReceiverHw<GfxFamily>::flush(BatchBuffer &batchBuffer, EngineType engineType, ResidencyContainer &allocationsForResidency, OsContext &osContext) { FlushStamp CommandStreamReceiverHw<GfxFamily>::flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) {
return flushStamp->peekStamp(); return flushStamp->peekStamp();
} }
@@ -445,13 +446,12 @@ CompletionStamp CommandStreamReceiverHw<GfxFamily>::flushTask(
size_t startOffset = submitCommandStreamFromCsr ? commandStreamStartCSR : commandStreamStartTask; size_t startOffset = submitCommandStreamFromCsr ? commandStreamStartCSR : commandStreamStartTask;
auto &streamToSubmit = submitCommandStreamFromCsr ? commandStreamCSR : commandStreamTask; auto &streamToSubmit = submitCommandStreamFromCsr ? commandStreamCSR : commandStreamTask;
BatchBuffer batchBuffer{streamToSubmit.getGraphicsAllocation(), startOffset, chainedBatchBufferStartOffset, chainedBatchBuffer, dispatchFlags.requiresCoherency, dispatchFlags.lowPriority, dispatchFlags.throttle, streamToSubmit.getUsed(), &streamToSubmit}; BatchBuffer batchBuffer{streamToSubmit.getGraphicsAllocation(), startOffset, chainedBatchBufferStartOffset, chainedBatchBuffer, dispatchFlags.requiresCoherency, dispatchFlags.lowPriority, dispatchFlags.throttle, streamToSubmit.getUsed(), &streamToSubmit};
EngineType engineType = device.getEngineType();
if (submitCSR | submitTask) { if (submitCSR | submitTask) {
if (this->dispatchMode == DispatchMode::ImmediateDispatch) { if (this->dispatchMode == DispatchMode::ImmediateDispatch) {
flushStamp->setStamp(this->flush(batchBuffer, engineType, this->getResidencyAllocations(), *device.getOsContext())); flushStamp->setStamp(this->flush(batchBuffer, this->getResidencyAllocations()));
this->latestFlushedTaskCount = this->taskCount + 1; this->latestFlushedTaskCount = this->taskCount + 1;
this->makeSurfacePackNonResident(this->getResidencyAllocations(), *device.getOsContext()); this->makeSurfacePackNonResident(this->getResidencyAllocations());
} else { } else {
auto commandBuffer = new CommandBuffer(device); auto commandBuffer = new CommandBuffer(device);
commandBuffer->batchBuffer = batchBuffer; commandBuffer->batchBuffer = batchBuffer;
@@ -464,7 +464,7 @@ CompletionStamp CommandStreamReceiverHw<GfxFamily>::flushTask(
this->submissionAggregator->recordCommandBuffer(commandBuffer); this->submissionAggregator->recordCommandBuffer(commandBuffer);
} }
} else { } else {
this->makeSurfacePackNonResident(this->getResidencyAllocations(), *device.getOsContext()); this->makeSurfacePackNonResident(this->getResidencyAllocations());
} }
//check if we are not over the budget, if we are do implicit flush //check if we are not over the budget, if we are do implicit flush
@@ -485,9 +485,7 @@ CompletionStamp CommandStreamReceiverHw<GfxFamily>::flushTask(
CompletionStamp completionStamp = { CompletionStamp completionStamp = {
taskCount, taskCount,
this->taskLevel, this->taskLevel,
flushStamp->peekStamp(), flushStamp->peekStamp()};
0,
engineType};
this->taskLevel += levelClosed ? 1 : 0; this->taskLevel += levelClosed ? 1 : 0;
@@ -510,7 +508,6 @@ inline void CommandStreamReceiverHw<GfxFamily>::flushBatchedSubmissions() {
auto &commandBufferList = this->submissionAggregator->peekCmdBufferList(); auto &commandBufferList = this->submissionAggregator->peekCmdBufferList();
if (!commandBufferList.peekIsEmpty()) { if (!commandBufferList.peekIsEmpty()) {
auto &device = commandBufferList.peekHead()->device; auto &device = commandBufferList.peekHead()->device;
EngineType engineType = device.getEngineType();
ResidencyContainer surfacesForSubmit; ResidencyContainer surfacesForSubmit;
ResourcePackage resourcePackage; ResourcePackage resourcePackage;
@@ -570,7 +567,7 @@ inline void CommandStreamReceiverHw<GfxFamily>::flushBatchedSubmissions() {
if (epiloguePipeControlLocation) { if (epiloguePipeControlLocation) {
((PIPE_CONTROL *)epiloguePipeControlLocation)->setDcFlushEnable(true); ((PIPE_CONTROL *)epiloguePipeControlLocation)->setDcFlushEnable(true);
} }
auto flushStamp = this->flush(primaryCmdBuffer->batchBuffer, engineType, surfacesForSubmit, *device.getOsContext()); auto flushStamp = this->flush(primaryCmdBuffer->batchBuffer, surfacesForSubmit);
//after flush task level is closed //after flush task level is closed
this->taskLevel++; this->taskLevel++;
@@ -579,7 +576,7 @@ inline void CommandStreamReceiverHw<GfxFamily>::flushBatchedSubmissions() {
this->latestFlushedTaskCount = lastTaskCount; this->latestFlushedTaskCount = lastTaskCount;
this->flushStamp->setStamp(flushStamp); this->flushStamp->setStamp(flushStamp);
this->makeSurfacePackNonResident(surfacesForSubmit, *device.getOsContext()); this->makeSurfacePackNonResident(surfacesForSubmit);
resourcePackage.clear(); resourcePackage.clear();
} }
this->totalMemoryUsed = 0; this->totalMemoryUsed = 0;
@@ -680,13 +677,13 @@ inline void CommandStreamReceiverHw<GfxFamily>::emitNoop(LinearStream &commandSt
} }
template <typename GfxFamily> template <typename GfxFamily>
inline void CommandStreamReceiverHw<GfxFamily>::waitForTaskCountWithKmdNotifyFallback(uint32_t taskCountToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep, OsContext &osContext, bool forcePowerSavingMode) { inline void CommandStreamReceiverHw<GfxFamily>::waitForTaskCountWithKmdNotifyFallback(uint32_t taskCountToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep, bool forcePowerSavingMode) {
int64_t waitTimeout = 0; int64_t waitTimeout = 0;
bool enableTimeout = kmdNotifyHelper->obtainTimeoutParams(waitTimeout, useQuickKmdSleep, *getTagAddress(), taskCountToWait, flushStampToWait, forcePowerSavingMode); bool enableTimeout = kmdNotifyHelper->obtainTimeoutParams(waitTimeout, useQuickKmdSleep, *getTagAddress(), taskCountToWait, flushStampToWait, forcePowerSavingMode);
auto status = waitForCompletionWithTimeout(enableTimeout, waitTimeout, taskCountToWait); auto status = waitForCompletionWithTimeout(enableTimeout, waitTimeout, taskCountToWait);
if (!status) { if (!status) {
waitForFlushStamp(flushStampToWait, osContext); waitForFlushStamp(flushStampToWait);
//now call blocking wait, this is to ensure that task count is reached //now call blocking wait, this is to ensure that task count is reached
waitForCompletionWithTimeout(false, 0, taskCountToWait); waitForCompletionWithTimeout(false, 0, taskCountToWait);
} }

View File

@@ -20,7 +20,7 @@ class CommandStreamReceiverWithAUBDump : public BaseCSR {
CommandStreamReceiverWithAUBDump(const CommandStreamReceiverWithAUBDump &) = delete; CommandStreamReceiverWithAUBDump(const CommandStreamReceiverWithAUBDump &) = delete;
CommandStreamReceiverWithAUBDump &operator=(const CommandStreamReceiverWithAUBDump &) = delete; CommandStreamReceiverWithAUBDump &operator=(const CommandStreamReceiverWithAUBDump &) = delete;
FlushStamp flush(BatchBuffer &batchBuffer, EngineType engineOrdinal, ResidencyContainer &allocationsForResidency, OsContext &osContext) override; FlushStamp flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) override;
void makeNonResident(GraphicsAllocation &gfxAllocation) override; void makeNonResident(GraphicsAllocation &gfxAllocation) override;
void activateAubSubCapture(const MultiDispatchInfo &dispatchInfo) override; void activateAubSubCapture(const MultiDispatchInfo &dispatchInfo) override;

View File

@@ -24,11 +24,11 @@ CommandStreamReceiverWithAUBDump<BaseCSR>::~CommandStreamReceiverWithAUBDump() {
} }
template <typename BaseCSR> template <typename BaseCSR>
FlushStamp CommandStreamReceiverWithAUBDump<BaseCSR>::flush(BatchBuffer &batchBuffer, EngineType engineOrdinal, ResidencyContainer &allocationsForResidency, OsContext &osContext) { FlushStamp CommandStreamReceiverWithAUBDump<BaseCSR>::flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) {
if (aubCSR) { if (aubCSR) {
aubCSR->flush(batchBuffer, engineOrdinal, allocationsForResidency, osContext); aubCSR->flush(batchBuffer, allocationsForResidency);
} }
FlushStamp flushStamp = BaseCSR::flush(batchBuffer, engineOrdinal, allocationsForResidency, osContext); FlushStamp flushStamp = BaseCSR::flush(batchBuffer, allocationsForResidency);
return flushStamp; return flushStamp;
} }

View File

@@ -30,15 +30,16 @@ class TbxCommandStreamReceiverHw : public CommandStreamReceiverSimulatedHw<GfxFa
typedef CommandStreamReceiverSimulatedHw<GfxFamily> BaseClass; typedef CommandStreamReceiverSimulatedHw<GfxFamily> BaseClass;
typedef typename OCLRT::AUBFamilyMapper<GfxFamily>::AUB AUB; typedef typename OCLRT::AUBFamilyMapper<GfxFamily>::AUB AUB;
typedef typename AUB::MiContextDescriptorReg MiContextDescriptorReg; typedef typename AUB::MiContextDescriptorReg MiContextDescriptorReg;
using BaseClass::osContext;
public: public:
using CommandStreamReceiverSimulatedCommonHw<GfxFamily>::initAdditionalMMIO; using CommandStreamReceiverSimulatedCommonHw<GfxFamily>::initAdditionalMMIO;
using CommandStreamReceiverSimulatedCommonHw<GfxFamily>::stream; using CommandStreamReceiverSimulatedCommonHw<GfxFamily>::stream;
FlushStamp flush(BatchBuffer &batchBuffer, EngineType engineType, ResidencyContainer &allocationsForResidency, OsContext &osContext) override; FlushStamp flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) override;
void makeCoherent(GraphicsAllocation &gfxAllocation) override; void makeCoherent(GraphicsAllocation &gfxAllocation) override;
void processResidency(ResidencyContainer &allocationsForResidency, OsContext &osContext) override; void processResidency(ResidencyContainer &allocationsForResidency) override;
void waitBeforeMakingNonResidentWhenRequired() override; void waitBeforeMakingNonResidentWhenRequired() override;
bool writeMemory(GraphicsAllocation &gfxAllocation); bool writeMemory(GraphicsAllocation &gfxAllocation);

View File

@@ -17,6 +17,7 @@
#include "runtime/memory_manager/physical_address_allocator.h" #include "runtime/memory_manager/physical_address_allocator.h"
#include "runtime/command_stream/command_stream_receiver_with_aub_dump.h" #include "runtime/command_stream/command_stream_receiver_with_aub_dump.h"
#include "runtime/os_interface/debug_settings_manager.h" #include "runtime/os_interface/debug_settings_manager.h"
#include "runtime/os_interface/os_context.h"
#include <cstring> #include <cstring>
namespace OCLRT { namespace OCLRT {
@@ -181,7 +182,8 @@ CommandStreamReceiver *TbxCommandStreamReceiverHw<GfxFamily>::create(const Hardw
} }
template <typename GfxFamily> template <typename GfxFamily>
FlushStamp TbxCommandStreamReceiverHw<GfxFamily>::flush(BatchBuffer &batchBuffer, EngineType engineType, ResidencyContainer &allocationsForResidency, OsContext &osContext) { FlushStamp TbxCommandStreamReceiverHw<GfxFamily>::flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) {
auto engineType = osContext->getEngineType().type;
uint32_t mmioBase = getCsTraits(engineType).mmioBase; uint32_t mmioBase = getCsTraits(engineType).mmioBase;
auto &engineInfo = engineInfoTable[engineType]; auto &engineInfo = engineInfoTable[engineType];
@@ -215,7 +217,7 @@ FlushStamp TbxCommandStreamReceiverHw<GfxFamily>::flush(BatchBuffer &batchBuffer
} }
// Write allocations for residency // Write allocations for residency
processResidency(allocationsForResidency, osContext); processResidency(allocationsForResidency);
// Add a batch buffer start to the RCS // Add a batch buffer start to the RCS
auto previousTail = engineInfo.tailRCS; auto previousTail = engineInfo.tailRCS;
@@ -364,7 +366,7 @@ bool TbxCommandStreamReceiverHw<GfxFamily>::writeMemory(GraphicsAllocation &gfxA
} }
template <typename GfxFamily> template <typename GfxFamily>
void TbxCommandStreamReceiverHw<GfxFamily>::processResidency(ResidencyContainer &allocationsForResidency, OsContext &osContext) { void TbxCommandStreamReceiverHw<GfxFamily>::processResidency(ResidencyContainer &allocationsForResidency) {
for (auto &gfxAllocation : allocationsForResidency) { for (auto &gfxAllocation : allocationsForResidency) {
if (!writeMemory(*gfxAllocation)) { if (!writeMemory(*gfxAllocation)) {
DEBUG_BREAK_IF(!(gfxAllocation->getUnderlyingBufferSize() == 0)); DEBUG_BREAK_IF(!(gfxAllocation->getUnderlyingBufferSize() == 0));

View File

@@ -70,7 +70,6 @@ Device::Device(const HardwareInfo &hwInfo, ExecutionEnvironment *executionEnviro
deviceExtensions.reserve(1000); deviceExtensions.reserve(1000);
name.reserve(100); name.reserve(100);
preemptionMode = PreemptionHelper::getDefaultPreemptionMode(hwInfo); preemptionMode = PreemptionHelper::getDefaultPreemptionMode(hwInfo);
engineType = getChosenEngineType(hwInfo);
if (!getSourceLevelDebugger()) { if (!getSourceLevelDebugger()) {
this->executionEnvironment->initSourceLevelDebugger(hwInfo); this->executionEnvironment->initSourceLevelDebugger(hwInfo);
@@ -118,8 +117,9 @@ bool Device::createDeviceImpl(const HardwareInfo *pHwInfo, Device &outDevice) {
executionEnvironment->initializeMemoryManager(outDevice.getEnabled64kbPages(), outDevice.getEnableLocalMemory(), executionEnvironment->initializeMemoryManager(outDevice.getEnabled64kbPages(), outDevice.getEnableLocalMemory(),
outDevice.getDeviceIndex(), deviceCsrIndex); outDevice.getDeviceIndex(), deviceCsrIndex);
auto osContext = executionEnvironment->memoryManager->createAndRegisterOsContext(); auto osContext = executionEnvironment->memoryManager->createAndRegisterOsContext({getChosenEngineType(*pHwInfo), 0});
auto commandStreamReceiver = executionEnvironment->commandStreamReceivers[outDevice.getDeviceIndex()][deviceCsrIndex].get(); auto commandStreamReceiver = executionEnvironment->commandStreamReceivers[outDevice.getDeviceIndex()][deviceCsrIndex].get();
commandStreamReceiver->setOsContext(osContext);
if (!commandStreamReceiver->initializeTagAllocation()) { if (!commandStreamReceiver->initializeTagAllocation()) {
return false; return false;
} }

View File

@@ -63,9 +63,6 @@ class Device : public BaseObject<_cl_device_id> {
const DeviceInfo &getDeviceInfo() const; const DeviceInfo &getDeviceInfo() const;
DeviceInfo *getMutableDeviceInfo(); DeviceInfo *getMutableDeviceInfo();
MOCKABLE_VIRTUAL const WorkaroundTable *getWaTable() const; MOCKABLE_VIRTUAL const WorkaroundTable *getWaTable() const;
EngineType getEngineType() const {
return engineType;
}
void initMaxPowerSavingMode(); void initMaxPowerSavingMode();
void *getSLMWindowStartAddress(); void *getSLMWindowStartAddress();
@@ -120,7 +117,6 @@ class Device : public BaseObject<_cl_device_id> {
SourceLevelDebugger *getSourceLevelDebugger() { return executionEnvironment->sourceLevelDebugger.get(); } SourceLevelDebugger *getSourceLevelDebugger() { return executionEnvironment->sourceLevelDebugger.get(); }
ExecutionEnvironment *getExecutionEnvironment() const { return executionEnvironment; } ExecutionEnvironment *getExecutionEnvironment() const { return executionEnvironment; }
const HardwareCapabilities &getHardwareCapabilities() const { return hardwareCapabilities; } const HardwareCapabilities &getHardwareCapabilities() const { return hardwareCapabilities; }
OsContext *getOsContext() const { return engines[0].osContext; }
uint32_t getDeviceIndex() { return deviceIndex; } uint32_t getDeviceIndex() { return deviceIndex; }
bool isFullRangeSvm() { bool isFullRangeSvm() {
return getHardwareInfo().capabilityTable.gpuAddressSpace == MemoryConstants::max48BitAddress; return getHardwareInfo().capabilityTable.gpuAddressSpace == MemoryConstants::max48BitAddress;
@@ -164,7 +160,6 @@ class Device : public BaseObject<_cl_device_id> {
std::string exposedBuiltinKernels = ""; std::string exposedBuiltinKernels = "";
PreemptionMode preemptionMode; PreemptionMode preemptionMode;
EngineType engineType;
ExecutionEnvironment *executionEnvironment = nullptr; ExecutionEnvironment *executionEnvironment = nullptr;
uint32_t deviceIndex = 0u; uint32_t deviceIndex = 0u;
}; };

View File

@@ -7,12 +7,10 @@
set(RUNTIME_SRCS_GENX_CPP_WINDOWS set(RUNTIME_SRCS_GENX_CPP_WINDOWS
windows/command_stream_receiver windows/command_stream_receiver
windows/gmm_callbacks windows/gmm_callbacks
windows/wddm
) )
set(RUNTIME_SRCS_GENX_CPP_LINUX set(RUNTIME_SRCS_GENX_CPP_LINUX
linux/command_stream_receiver linux/command_stream_receiver
linux/drm_engine_mapper
) )
set(RUNTIME_SRCS_GENX_H_BASE set(RUNTIME_SRCS_GENX_H_BASE

View File

@@ -1,15 +0,0 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "hw_cmds.h"
#include "runtime/os_interface/linux/drm_engine_mapper.h"
#include "runtime/os_interface/linux/drm_engine_mapper.inl"
namespace OCLRT {
template class DrmEngineMapper<CNLFamily>;
} // namespace OCLRT

View File

@@ -1,17 +0,0 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "hw_cmds.h"
#include "runtime/os_interface/windows/wddm_engine_mapper.h"
#include "runtime/os_interface/windows/wddm_engine_mapper.inl"
namespace OCLRT {
typedef CNLFamily Family;
template class WddmEngineMapper<CNLFamily>;
} // namespace OCLRT

View File

@@ -1,15 +0,0 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "hw_cmds.h"
#include "runtime/os_interface/linux/drm_engine_mapper.h"
#include "runtime/os_interface/linux/drm_engine_mapper.inl"
namespace OCLRT {
template class DrmEngineMapper<BDWFamily>;
} // namespace OCLRT

View File

@@ -1,17 +0,0 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "hw_cmds.h"
#include "runtime/os_interface/windows/wddm_engine_mapper.h"
#include "runtime/os_interface/windows/wddm_engine_mapper.inl"
namespace OCLRT {
typedef BDWFamily Family;
template class WddmEngineMapper<BDWFamily>;
} // namespace OCLRT

View File

@@ -1,15 +0,0 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "hw_cmds.h"
#include "runtime/os_interface/linux/drm_engine_mapper.h"
#include "runtime/os_interface/linux/drm_engine_mapper.inl"
namespace OCLRT {
template class DrmEngineMapper<SKLFamily>;
} // namespace OCLRT

View File

@@ -1,17 +0,0 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "hw_cmds.h"
#include "runtime/os_interface/windows/wddm_engine_mapper.h"
#include "runtime/os_interface/windows/wddm_engine_mapper.inl"
namespace OCLRT {
typedef SKLFamily Family;
template class WddmEngineMapper<SKLFamily>;
} // namespace OCLRT

View File

@@ -15,7 +15,5 @@ struct CompletionStamp {
uint32_t taskCount; uint32_t taskCount;
uint32_t taskLevel; uint32_t taskLevel;
FlushStamp flushStamp; FlushStamp flushStamp;
uint32_t deviceOrdinal;
EngineType engineType;
}; };
} // namespace OCLRT } // namespace OCLRT

View File

@@ -201,12 +201,12 @@ bool MemoryManager::isMemoryBudgetExhausted() const {
return false; return false;
} }
OsContext *MemoryManager::createAndRegisterOsContext() { OsContext *MemoryManager::createAndRegisterOsContext(EngineInstanceT engineType) {
auto contextId = ++latestContextId; auto contextId = ++latestContextId;
if (contextId + 1 > registeredOsContexts.size()) { if (contextId + 1 > registeredOsContexts.size()) {
registeredOsContexts.resize(contextId + 1); registeredOsContexts.resize(contextId + 1);
} }
auto osContext = new OsContext(executionEnvironment.osInterface.get(), contextId); auto osContext = new OsContext(executionEnvironment.osInterface.get(), contextId, engineType);
osContext->incRefInternal(); osContext->incRefInternal();
registeredOsContexts[contextId] = osContext; registeredOsContexts[contextId] = osContext;

View File

@@ -10,6 +10,7 @@
#include "runtime/memory_manager/graphics_allocation.h" #include "runtime/memory_manager/graphics_allocation.h"
#include "runtime/memory_manager/host_ptr_defines.h" #include "runtime/memory_manager/host_ptr_defines.h"
#include "runtime/os_interface/32bit_memory.h" #include "runtime/os_interface/32bit_memory.h"
#include "engine_node.h"
#include <cstdint> #include <cstdint>
#include <mutex> #include <mutex>
@@ -247,7 +248,7 @@ class MemoryManager {
::alignedFree(ptr); ::alignedFree(ptr);
} }
OsContext *createAndRegisterOsContext(); OsContext *createAndRegisterOsContext(EngineInstanceT engineType);
uint32_t getOsContextCount() { return static_cast<uint32_t>(registeredOsContexts.size()); } uint32_t getOsContextCount() { return static_cast<uint32_t>(registeredOsContexts.size()); }
CommandStreamReceiver *getCommandStreamReceiver(uint32_t contextId); CommandStreamReceiver *getCommandStreamReceiver(uint32_t contextId);
HostPtrManager *getHostPtrManager() const { return hostPtrManager.get(); } HostPtrManager *getHostPtrManager() const { return hostPtrManager.get(); }

View File

@@ -19,8 +19,8 @@ set(RUNTIME_SRCS_OS_INTERFACE_LINUX
${CMAKE_CURRENT_SOURCE_DIR}/drm_buffer_object.h ${CMAKE_CURRENT_SOURCE_DIR}/drm_buffer_object.h
${CMAKE_CURRENT_SOURCE_DIR}/drm_command_stream.h ${CMAKE_CURRENT_SOURCE_DIR}/drm_command_stream.h
${CMAKE_CURRENT_SOURCE_DIR}/drm_command_stream.inl ${CMAKE_CURRENT_SOURCE_DIR}/drm_command_stream.inl
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/drm_engine_mapper.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_engine_mapper.h ${CMAKE_CURRENT_SOURCE_DIR}/drm_engine_mapper.h
${CMAKE_CURRENT_SOURCE_DIR}/drm_engine_mapper.inl
${CMAKE_CURRENT_SOURCE_DIR}/drm_gem_close_worker.cpp ${CMAKE_CURRENT_SOURCE_DIR}/drm_gem_close_worker.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_gem_close_worker.h ${CMAKE_CURRENT_SOURCE_DIR}/drm_gem_close_worker.h
${CMAKE_CURRENT_SOURCE_DIR}/drm_limited_range.cpp ${CMAKE_CURRENT_SOURCE_DIR}/drm_limited_range.cpp

View File

@@ -27,6 +27,7 @@ class DrmCommandStreamReceiver : public DeviceCommandStreamReceiver<GfxFamily> {
using BaseClass::makeNonResident; using BaseClass::makeNonResident;
using BaseClass::makeResident; using BaseClass::makeResident;
using BaseClass::mediaVfeStateDirty; using BaseClass::mediaVfeStateDirty;
using BaseClass::osContext;
using BaseClass::requiredScratchSize; using BaseClass::requiredScratchSize;
public: public:
@@ -35,11 +36,11 @@ class DrmCommandStreamReceiver : public DeviceCommandStreamReceiver<GfxFamily> {
DrmCommandStreamReceiver(const HardwareInfo &hwInfoIn, ExecutionEnvironment &executionEnvironment, DrmCommandStreamReceiver(const HardwareInfo &hwInfoIn, ExecutionEnvironment &executionEnvironment,
gemCloseWorkerMode mode = gemCloseWorkerMode::gemCloseWorkerActive); gemCloseWorkerMode mode = gemCloseWorkerMode::gemCloseWorkerActive);
FlushStamp flush(BatchBuffer &batchBuffer, EngineType engineType, ResidencyContainer &allocationsForResidency, OsContext &osContext) override; FlushStamp flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) override;
void makeResident(GraphicsAllocation &gfxAllocation) override; void makeResident(GraphicsAllocation &gfxAllocation) override;
void processResidency(ResidencyContainer &allocationsForResidency, OsContext &osContext) override; void processResidency(ResidencyContainer &allocationsForResidency) override;
void makeNonResident(GraphicsAllocation &gfxAllocation) override; void makeNonResident(GraphicsAllocation &gfxAllocation) override;
bool waitForFlushStamp(FlushStamp &flushStampToWait, OsContext &osContext) override; bool waitForFlushStamp(FlushStamp &flushStampToWait) override;
void overrideMediaVFEStateDirty(bool dirty) override; void overrideMediaVFEStateDirty(bool dirty) override;
DrmMemoryManager *getMemoryManager(); DrmMemoryManager *getMemoryManager();

View File

@@ -17,6 +17,7 @@
#include "runtime/os_interface/linux/drm_engine_mapper.h" #include "runtime/os_interface/linux/drm_engine_mapper.h"
#include "runtime/os_interface/linux/drm_memory_manager.h" #include "runtime/os_interface/linux/drm_memory_manager.h"
#include "runtime/os_interface/linux/drm_neo.h" #include "runtime/os_interface/linux/drm_neo.h"
#include "runtime/os_interface/linux/os_context_linux.h"
#include "runtime/os_interface/linux/os_interface.h" #include "runtime/os_interface/linux/os_interface.h"
#include "runtime/platform/platform.h" #include "runtime/platform/platform.h"
#include <cstdlib> #include <cstdlib>
@@ -41,10 +42,8 @@ DrmCommandStreamReceiver<GfxFamily>::DrmCommandStreamReceiver(const HardwareInfo
} }
template <typename GfxFamily> template <typename GfxFamily>
FlushStamp DrmCommandStreamReceiver<GfxFamily>::flush(BatchBuffer &batchBuffer, EngineType engineType, ResidencyContainer &allocationsForResidency, OsContext &osContext) { FlushStamp DrmCommandStreamReceiver<GfxFamily>::flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) {
unsigned int engineFlag = 0xFF; unsigned int engineFlag = osContext->get()->getEngineFlag();
bool ret = DrmEngineMapper<GfxFamily>::engineNodeMap(engineType, engineFlag);
UNRECOVERABLE_IF(!(ret));
DrmAllocation *alloc = static_cast<DrmAllocation *>(batchBuffer.commandBufferAllocation); DrmAllocation *alloc = static_cast<DrmAllocation *>(batchBuffer.commandBufferAllocation);
DEBUG_BREAK_IF(!alloc); DEBUG_BREAK_IF(!alloc);
@@ -55,7 +54,7 @@ FlushStamp DrmCommandStreamReceiver<GfxFamily>::flush(BatchBuffer &batchBuffer,
if (bb) { if (bb) {
flushStamp = bb->peekHandle(); flushStamp = bb->peekHandle();
this->processResidency(allocationsForResidency, osContext); this->processResidency(allocationsForResidency);
// Residency hold all allocation except command buffer, hence + 1 // Residency hold all allocation except command buffer, hence + 1
auto requiredSize = this->residency.size() + 1; auto requiredSize = this->residency.size() + 1;
if (requiredSize > this->execObjectsStorage.size()) { if (requiredSize > this->execObjectsStorage.size()) {
@@ -107,7 +106,7 @@ void DrmCommandStreamReceiver<GfxFamily>::makeResident(BufferObject *bo) {
} }
template <typename GfxFamily> template <typename GfxFamily>
void DrmCommandStreamReceiver<GfxFamily>::processResidency(ResidencyContainer &inputAllocationsForResidency, OsContext &osContext) { void DrmCommandStreamReceiver<GfxFamily>::processResidency(ResidencyContainer &inputAllocationsForResidency) {
for (auto &alloc : inputAllocationsForResidency) { for (auto &alloc : inputAllocationsForResidency) {
auto drmAlloc = static_cast<DrmAllocation *>(alloc); auto drmAlloc = static_cast<DrmAllocation *>(alloc);
if (drmAlloc->fragmentsStorage.fragmentCount) { if (drmAlloc->fragmentsStorage.fragmentCount) {
@@ -153,7 +152,7 @@ MemoryManager *DrmCommandStreamReceiver<GfxFamily>::createMemoryManager(bool ena
} }
template <typename GfxFamily> template <typename GfxFamily>
bool DrmCommandStreamReceiver<GfxFamily>::waitForFlushStamp(FlushStamp &flushStamp, OsContext &osContext) { bool DrmCommandStreamReceiver<GfxFamily>::waitForFlushStamp(FlushStamp &flushStamp) {
drm_i915_gem_wait wait = {}; drm_i915_gem_wait wait = {};
wait.bo_handle = static_cast<uint32_t>(flushStamp); wait.bo_handle = static_cast<uint32_t>(flushStamp);
wait.timeout_ns = -1; wait.timeout_ns = -1;

View File

@@ -0,0 +1,20 @@
/*
* Copyright (C) 2018 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "hw_cmds.h"
#include "runtime/os_interface/linux/drm_engine_mapper.h"
#include "drm/i915_drm.h"
namespace OCLRT {
unsigned int DrmEngineMapper::engineNodeMap(EngineType engineType) {
if (EngineType::ENGINE_RCS == engineType) {
return I915_EXEC_RENDER;
}
UNRECOVERABLE_IF(true);
}
} // namespace OCLRT

View File

@@ -13,10 +13,9 @@
namespace OCLRT { namespace OCLRT {
template <typename Family>
class DrmEngineMapper { class DrmEngineMapper {
public: public:
static bool engineNodeMap(EngineType engineType, unsigned int &flag); static unsigned int engineNodeMap(EngineType engineType);
}; };
} // namespace OCLRT } // namespace OCLRT

View File

@@ -1,27 +0,0 @@
/*
* Copyright (C) 2018 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "hw_cmds.h"
#include "runtime/os_interface/linux/drm_engine_mapper.h"
#include "drm/i915_drm.h"
namespace OCLRT {
template <typename Family>
bool DrmEngineMapper<Family>::engineNodeMap(EngineType engineType, unsigned int &flag) {
bool ret = false;
switch (engineType) {
case EngineType::ENGINE_RCS:
flag = I915_EXEC_RENDER;
ret = true;
break;
default:
break;
}
return ret;
}
} // namespace OCLRT

View File

@@ -6,19 +6,23 @@
*/ */
#include "runtime/os_interface/os_context.h" #include "runtime/os_interface/os_context.h"
#include "runtime/os_interface/linux/drm_engine_mapper.h"
#include "runtime/os_interface/linux/drm_neo.h" #include "runtime/os_interface/linux/drm_neo.h"
#include "runtime/os_interface/linux/os_context_linux.h" #include "runtime/os_interface/linux/os_context_linux.h"
#include "runtime/os_interface/linux/os_interface.h" #include "runtime/os_interface/linux/os_interface.h"
namespace OCLRT { namespace OCLRT {
OsContext::OsContext(OSInterface *osInterface, uint32_t contextId) : contextId(contextId) { OsContext::OsContext(OSInterface *osInterface, uint32_t contextId, EngineInstanceT engineType)
: contextId(contextId), engineType(engineType) {
if (osInterface) { if (osInterface) {
osContextImpl = std::make_unique<OsContextLinux>(*osInterface->get()->getDrm()); osContextImpl = std::make_unique<OsContextLinux>(*osInterface->get()->getDrm(), engineType);
} }
} }
OsContext::~OsContext() = default; OsContext::~OsContext() = default;
OsContextLinux::OsContextImpl(Drm &drm) : drm(drm) {} OsContextLinux::OsContextImpl(Drm &drm, EngineInstanceT engineType) : drm(drm) {
engineFlag = DrmEngineMapper::engineNodeMap(engineType.type);
}
} // namespace OCLRT } // namespace OCLRT

View File

@@ -13,9 +13,11 @@ using OsContextLinux = OsContext::OsContextImpl;
class OsContext::OsContextImpl { class OsContext::OsContextImpl {
public: public:
OsContextImpl(Drm &drm); OsContextImpl(Drm &drm, EngineInstanceT engineType);
unsigned int getEngineFlag() const { return engineFlag; }
protected: protected:
unsigned int engineFlag = 0;
Drm &drm; Drm &drm;
}; };
} // namespace OCLRT } // namespace OCLRT

View File

@@ -7,6 +7,7 @@
#pragma once #pragma once
#include "runtime/utilities/reference_tracked_object.h" #include "runtime/utilities/reference_tracked_object.h"
#include "engine_node.h"
#include <memory> #include <memory>
namespace OCLRT { namespace OCLRT {
@@ -14,16 +15,18 @@ class OSInterface;
class OsContext : public ReferenceTrackedObject<OsContext> { class OsContext : public ReferenceTrackedObject<OsContext> {
public: public:
class OsContextImpl; class OsContextImpl;
OsContext(OSInterface *osInterface, uint32_t contextId); OsContext(OSInterface *osInterface, uint32_t contextId, EngineInstanceT engineType);
~OsContext() override; ~OsContext() override;
OsContextImpl *get() const { OsContextImpl *get() const {
return osContextImpl.get(); return osContextImpl.get();
}; };
uint32_t getContextId() { return contextId; } uint32_t getContextId() { return contextId; }
EngineInstanceT &getEngineType() { return engineType; }
protected: protected:
std::unique_ptr<OsContextImpl> osContextImpl; std::unique_ptr<OsContextImpl> osContextImpl;
uint32_t contextId = 0; uint32_t contextId = 0;
EngineInstanceT engineType;
}; };
} // namespace OCLRT } // namespace OCLRT

View File

@@ -50,8 +50,8 @@ set(RUNTIME_SRCS_OS_INTERFACE_WINDOWS
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/wddm_additional_context_flags.cpp ${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/wddm_additional_context_flags.cpp
${CMAKE_CURRENT_SOURCE_DIR}/wddm_device_command_stream.h ${CMAKE_CURRENT_SOURCE_DIR}/wddm_device_command_stream.h
${CMAKE_CURRENT_SOURCE_DIR}/wddm_device_command_stream.inl ${CMAKE_CURRENT_SOURCE_DIR}/wddm_device_command_stream.inl
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/wddm_engine_mapper.cpp
${CMAKE_CURRENT_SOURCE_DIR}/wddm_engine_mapper.h ${CMAKE_CURRENT_SOURCE_DIR}/wddm_engine_mapper.h
${CMAKE_CURRENT_SOURCE_DIR}/wddm_engine_mapper.inl
${CMAKE_CURRENT_SOURCE_DIR}/wddm_memory_manager.cpp ${CMAKE_CURRENT_SOURCE_DIR}/wddm_memory_manager.cpp
${CMAKE_CURRENT_SOURCE_DIR}/wddm_memory_manager.h ${CMAKE_CURRENT_SOURCE_DIR}/wddm_memory_manager.h
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/wddm_memory_manager_allocate_in_device_pool.cpp ${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/wddm_memory_manager_allocate_in_device_pool.cpp

View File

@@ -12,10 +12,10 @@
namespace OCLRT { namespace OCLRT {
OsContextWin::OsContextImpl(Wddm &wddm, uint32_t osContextId) : wddm(wddm), residencyController(wddm, osContextId) { OsContextWin::OsContextImpl(Wddm &wddm, uint32_t osContextId, EngineInstanceT engineType) : wddm(wddm), residencyController(wddm, osContextId) {
UNRECOVERABLE_IF(!wddm.isInitialized()); UNRECOVERABLE_IF(!wddm.isInitialized());
auto wddmInterface = wddm.getWddmInterface(); auto wddmInterface = wddm.getWddmInterface();
if (!wddm.createContext(context)) { if (!wddm.createContext(context, engineType)) {
return; return;
} }
if (wddmInterface->hwQueuesSupported()) { if (wddmInterface->hwQueuesSupported()) {
@@ -31,9 +31,10 @@ OsContextWin::~OsContextImpl() {
wddm.destroyContext(context); wddm.destroyContext(context);
} }
OsContext::OsContext(OSInterface *osInterface, uint32_t contextId) : contextId(contextId) { OsContext::OsContext(OSInterface *osInterface, uint32_t contextId, EngineInstanceT engineType)
: contextId(contextId), engineType(engineType) {
if (osInterface) { if (osInterface) {
osContextImpl = std::make_unique<OsContextWin>(*osInterface->get()->getWddm(), contextId); osContextImpl = std::make_unique<OsContextWin>(*osInterface->get()->getWddm(), contextId, engineType);
} }
} }
OsContext::~OsContext() = default; OsContext::~OsContext() = default;

View File

@@ -17,7 +17,7 @@ using OsContextWin = OsContext::OsContextImpl;
class OsContext::OsContextImpl { class OsContext::OsContextImpl {
public: public:
OsContextImpl() = delete; OsContextImpl() = delete;
OsContextImpl(Wddm &wddm, uint32_t osContextId); OsContextImpl(Wddm &wddm, uint32_t osContextId, EngineInstanceT engineType);
~OsContextImpl(); ~OsContextImpl();
D3DKMT_HANDLE getContext() const { D3DKMT_HANDLE getContext() const {
return context; return context;

View File

@@ -18,6 +18,7 @@
#include "runtime/os_interface/windows/gdi_interface.h" #include "runtime/os_interface/windows/gdi_interface.h"
#include "runtime/os_interface/windows/os_context_win.h" #include "runtime/os_interface/windows/os_context_win.h"
#include "runtime/os_interface/windows/wddm_allocation.h" #include "runtime/os_interface/windows/wddm_allocation.h"
#include "runtime/os_interface/windows/wddm_engine_mapper.h"
#include "runtime/os_interface/windows/registry_reader.h" #include "runtime/os_interface/windows/registry_reader.h"
#include "runtime/helpers/debug_helpers.h" #include "runtime/helpers/debug_helpers.h"
#include "runtime/helpers/hw_info.h" #include "runtime/helpers/hw_info.h"
@@ -661,7 +662,7 @@ void Wddm::kmDafLock(WddmAllocation *wddmAllocation) {
kmDafListener->notifyLock(featureTable->ftrKmdDaf, adapter, device, wddmAllocation->handle, 0, gdi->escape); kmDafListener->notifyLock(featureTable->ftrKmdDaf, adapter, device, wddmAllocation->handle, 0, gdi->escape);
} }
bool Wddm::createContext(D3DKMT_HANDLE &context) { bool Wddm::createContext(D3DKMT_HANDLE &context, EngineInstanceT engineType) {
NTSTATUS status = STATUS_UNSUCCESSFUL; NTSTATUS status = STATUS_UNSUCCESSFUL;
D3DKMT_CREATECONTEXTVIRTUAL CreateContext = {0}; D3DKMT_CREATECONTEXTVIRTUAL CreateContext = {0};
CREATECONTEXT_PVTDATA PrivateData = {{0}}; CREATECONTEXT_PVTDATA PrivateData = {{0}};
@@ -684,7 +685,7 @@ bool Wddm::createContext(D3DKMT_HANDLE &context) {
} }
CreateContext.PrivateDriverDataSize = sizeof(PrivateData); CreateContext.PrivateDriverDataSize = sizeof(PrivateData);
CreateContext.NodeOrdinal = node; CreateContext.NodeOrdinal = WddmEngineMapper::engineNodeMap(engineType.type);
CreateContext.pPrivateDriverData = &PrivateData; CreateContext.pPrivateDriverData = &PrivateData;
CreateContext.ClientHint = D3DKMT_CLIENTHINT_OPENGL; CreateContext.ClientHint = D3DKMT_CLIENTHINT_OPENGL;
CreateContext.hDevice = device; CreateContext.hDevice = device;

View File

@@ -57,7 +57,7 @@ class Wddm {
MOCKABLE_VIRTUAL bool makeResident(D3DKMT_HANDLE *handles, uint32_t count, bool cantTrimFurther, uint64_t *numberOfBytesToTrim); MOCKABLE_VIRTUAL bool makeResident(D3DKMT_HANDLE *handles, uint32_t count, bool cantTrimFurther, uint64_t *numberOfBytesToTrim);
bool mapGpuVirtualAddress(WddmAllocation *allocation, void *cpuPtr, bool allocation32bit, bool use64kbPages, bool useHeap1); bool mapGpuVirtualAddress(WddmAllocation *allocation, void *cpuPtr, bool allocation32bit, bool use64kbPages, bool useHeap1);
bool mapGpuVirtualAddress(AllocationStorageData *allocationStorageData, bool allocation32bit, bool use64kbPages); bool mapGpuVirtualAddress(AllocationStorageData *allocationStorageData, bool allocation32bit, bool use64kbPages);
MOCKABLE_VIRTUAL bool createContext(D3DKMT_HANDLE &context); MOCKABLE_VIRTUAL bool createContext(D3DKMT_HANDLE &context, EngineInstanceT engineType);
MOCKABLE_VIRTUAL void applyAdditionalContextFlags(CREATECONTEXT_PVTDATA &privateData); MOCKABLE_VIRTUAL void applyAdditionalContextFlags(CREATECONTEXT_PVTDATA &privateData);
MOCKABLE_VIRTUAL bool freeGpuVirtualAddres(D3DGPU_VIRTUAL_ADDRESS &gpuPtr, uint64_t size); MOCKABLE_VIRTUAL bool freeGpuVirtualAddres(D3DGPU_VIRTUAL_ADDRESS &gpuPtr, uint64_t size);
MOCKABLE_VIRTUAL NTSTATUS createAllocation(WddmAllocation *alloc); MOCKABLE_VIRTUAL NTSTATUS createAllocation(WddmAllocation *alloc);
@@ -128,10 +128,6 @@ class Wddm {
std::unique_ptr<SettingsReader> registryReader; std::unique_ptr<SettingsReader> registryReader;
void setNode(GPUNODE_ORDINAL node) {
this->node = node;
}
void setPreemptionMode(PreemptionMode mode) { void setPreemptionMode(PreemptionMode mode) {
this->preemptionMode = mode; this->preemptionMode = mode;
} }
@@ -177,7 +173,6 @@ class Wddm {
unsigned long hwContextId = 0; unsigned long hwContextId = 0;
LUID adapterLuid; LUID adapterLuid;
uintptr_t maximumApplicationAddress = 0; uintptr_t maximumApplicationAddress = 0;
GPUNODE_ORDINAL node = GPUNODE_3D;
PreemptionMode preemptionMode = PreemptionMode::Disabled; PreemptionMode preemptionMode = PreemptionMode::Disabled;
std::unique_ptr<GmmMemory> gmmMemory; std::unique_ptr<GmmMemory> gmmMemory;
uintptr_t minAddress = 0; uintptr_t minAddress = 0;

View File

@@ -24,11 +24,11 @@ class WddmCommandStreamReceiver : public DeviceCommandStreamReceiver<GfxFamily>
WddmCommandStreamReceiver(const HardwareInfo &hwInfoIn, ExecutionEnvironment &executionEnvironment); WddmCommandStreamReceiver(const HardwareInfo &hwInfoIn, ExecutionEnvironment &executionEnvironment);
virtual ~WddmCommandStreamReceiver(); virtual ~WddmCommandStreamReceiver();
FlushStamp flush(BatchBuffer &batchBuffer, EngineType engineType, ResidencyContainer &allocationsForResidency, OsContext &osContext) override; FlushStamp flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) override;
void makeResident(GraphicsAllocation &gfxAllocation) override; void makeResident(GraphicsAllocation &gfxAllocation) override;
void processResidency(ResidencyContainer &allocationsForResidency, OsContext &osContext) override; void processResidency(ResidencyContainer &allocationsForResidency) override;
void processEviction(OsContext &osContext) override; void processEviction() override;
bool waitForFlushStamp(FlushStamp &flushStampToWait, OsContext &osContext) override; bool waitForFlushStamp(FlushStamp &flushStampToWait) override;
WddmMemoryManager *getMemoryManager(); WddmMemoryManager *getMemoryManager();
MemoryManager *createMemoryManager(bool enable64kbPages, bool enableLocalMemory); MemoryManager *createMemoryManager(bool enable64kbPages, bool enableLocalMemory);

View File

@@ -26,7 +26,6 @@
#include "runtime/os_interface/windows/gdi_interface.h" #include "runtime/os_interface/windows/gdi_interface.h"
#include "runtime/os_interface/windows/os_context_win.h" #include "runtime/os_interface/windows/os_context_win.h"
#include "runtime/os_interface/windows/os_interface.h" #include "runtime/os_interface/windows/os_interface.h"
#include "runtime/os_interface/windows/wddm_engine_mapper.h"
#include "runtime/os_interface/windows/wddm_memory_manager.h" #include "runtime/os_interface/windows/wddm_memory_manager.h"
namespace OCLRT { namespace OCLRT {
@@ -41,9 +40,6 @@ WddmCommandStreamReceiver<GfxFamily>::WddmCommandStreamReceiver(const HardwareIn
this->wddm = executionEnvironment.osInterface->get()->getWddm(); this->wddm = executionEnvironment.osInterface->get()->getWddm();
this->osInterface = executionEnvironment.osInterface.get(); this->osInterface = executionEnvironment.osInterface.get();
GPUNODE_ORDINAL nodeOrdinal = GPUNODE_3D;
UNRECOVERABLE_IF(!WddmEngineMapper<GfxFamily>::engineNodeMap(hwInfoIn.capabilityTable.defaultEngineType, nodeOrdinal));
this->wddm->setNode(nodeOrdinal);
PreemptionMode preemptionMode = PreemptionHelper::getDefaultPreemptionMode(hwInfoIn); PreemptionMode preemptionMode = PreemptionHelper::getDefaultPreemptionMode(hwInfoIn);
this->wddm->setPreemptionMode(preemptionMode); this->wddm->setPreemptionMode(preemptionMode);
@@ -68,8 +64,7 @@ WddmCommandStreamReceiver<GfxFamily>::~WddmCommandStreamReceiver() {
} }
template <typename GfxFamily> template <typename GfxFamily>
FlushStamp WddmCommandStreamReceiver<GfxFamily>::flush(BatchBuffer &batchBuffer, FlushStamp WddmCommandStreamReceiver<GfxFamily>::flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) {
EngineType engineType, ResidencyContainer &allocationsForResidency, OsContext &osContext) {
auto commandStreamAddress = ptrOffset(batchBuffer.commandBufferAllocation->getGpuAddress(), batchBuffer.startOffset); auto commandStreamAddress = ptrOffset(batchBuffer.commandBufferAllocation->getGpuAddress(), batchBuffer.startOffset);
if (this->dispatchMode == DispatchMode::ImmediateDispatch) { if (this->dispatchMode == DispatchMode::ImmediateDispatch) {
@@ -79,7 +74,7 @@ FlushStamp WddmCommandStreamReceiver<GfxFamily>::flush(BatchBuffer &batchBuffer,
batchBuffer.commandBufferAllocation->updateResidencyTaskCount(this->taskCount, this->deviceIndex); batchBuffer.commandBufferAllocation->updateResidencyTaskCount(this->taskCount, this->deviceIndex);
} }
this->processResidency(allocationsForResidency, osContext); this->processResidency(allocationsForResidency);
COMMAND_BUFFER_HEADER *pHeader = reinterpret_cast<COMMAND_BUFFER_HEADER *>(commandBufferHeader); COMMAND_BUFFER_HEADER *pHeader = reinterpret_cast<COMMAND_BUFFER_HEADER *>(commandBufferHeader);
pHeader->RequiresCoherency = batchBuffer.requiresCoherency; pHeader->RequiresCoherency = batchBuffer.requiresCoherency;
@@ -104,9 +99,9 @@ FlushStamp WddmCommandStreamReceiver<GfxFamily>::flush(BatchBuffer &batchBuffer,
this->kmDafLockAllocations(allocationsForResidency); this->kmDafLockAllocations(allocationsForResidency);
} }
wddm->submit(commandStreamAddress, batchBuffer.usedSize - batchBuffer.startOffset, commandBufferHeader, *osContext.get()); wddm->submit(commandStreamAddress, batchBuffer.usedSize - batchBuffer.startOffset, commandBufferHeader, *osContext->get());
return osContext.get()->getResidencyController().getMonitoredFence().lastSubmittedFence; return osContext->get()->getResidencyController().getMonitoredFence().lastSubmittedFence;
} }
template <typename GfxFamily> template <typename GfxFamily>
@@ -125,14 +120,14 @@ void WddmCommandStreamReceiver<GfxFamily>::makeResident(GraphicsAllocation &gfxA
} }
template <typename GfxFamily> template <typename GfxFamily>
void WddmCommandStreamReceiver<GfxFamily>::processResidency(ResidencyContainer &allocationsForResidency, OsContext &osContext) { void WddmCommandStreamReceiver<GfxFamily>::processResidency(ResidencyContainer &allocationsForResidency) {
bool success = osContext.get()->getResidencyController().makeResidentResidencyAllocations(allocationsForResidency); bool success = osContext->get()->getResidencyController().makeResidentResidencyAllocations(allocationsForResidency);
DEBUG_BREAK_IF(!success); DEBUG_BREAK_IF(!success);
} }
template <typename GfxFamily> template <typename GfxFamily>
void WddmCommandStreamReceiver<GfxFamily>::processEviction(OsContext &osContext) { void WddmCommandStreamReceiver<GfxFamily>::processEviction() {
osContext.get()->getResidencyController().makeNonResidentEvictionAllocations(this->getEvictionAllocations()); osContext->get()->getResidencyController().makeNonResidentEvictionAllocations(this->getEvictionAllocations());
this->getEvictionAllocations().clear(); this->getEvictionAllocations().clear();
} }
@@ -147,8 +142,8 @@ MemoryManager *WddmCommandStreamReceiver<GfxFamily>::createMemoryManager(bool en
} }
template <typename GfxFamily> template <typename GfxFamily>
bool WddmCommandStreamReceiver<GfxFamily>::waitForFlushStamp(FlushStamp &flushStampToWait, OsContext &osContext) { bool WddmCommandStreamReceiver<GfxFamily>::waitForFlushStamp(FlushStamp &flushStampToWait) {
return wddm->waitFromCpu(flushStampToWait, osContext.get()->getResidencyController().getMonitoredFence()); return wddm->waitFromCpu(flushStampToWait, osContext->get()->getResidencyController().getMonitoredFence());
} }
template <typename GfxFamily> template <typename GfxFamily>

View File

@@ -0,0 +1,20 @@
/*
* Copyright (C) 2018 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "hw_cmds.h"
#include "runtime/os_interface/windows/wddm_engine_mapper.h"
namespace OCLRT {
GPUNODE_ORDINAL WddmEngineMapper::engineNodeMap(EngineType engineType) {
if (EngineType::ENGINE_RCS == engineType) {
return GPUNODE_3D;
}
UNRECOVERABLE_IF(true);
}
} // namespace OCLRT

View File

@@ -15,10 +15,9 @@
namespace OCLRT { namespace OCLRT {
template <typename Family>
class WddmEngineMapper { class WddmEngineMapper {
public: public:
static bool engineNodeMap(EngineType engineType, GPUNODE_ORDINAL &gpuNode); static GPUNODE_ORDINAL engineNodeMap(EngineType engineType);
}; };
} // namespace OCLRT } // namespace OCLRT

View File

@@ -1,27 +0,0 @@
/*
* Copyright (C) 2018 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "hw_cmds.h"
#include "runtime/os_interface/windows/wddm_engine_mapper.h"
namespace OCLRT {
template <typename Family>
bool WddmEngineMapper<Family>::engineNodeMap(EngineType engineType, GPUNODE_ORDINAL &gpuNode) {
bool ret = false;
switch (engineType) {
case EngineType::ENGINE_RCS:
gpuNode = GPUNODE_3D;
ret = true;
break;
default:
break;
}
return ret;
}
} // namespace OCLRT

View File

@@ -70,7 +70,7 @@ void GlArbSyncEvent::unblockEventBy(Event &event, uint32_t taskLevel, int32_t tr
return; return;
} }
ctx->getSharing<OCLRT::GLSharingFunctions>()->glArbSyncObjectSignal(*event.getCommandQueue()->getDevice().getOsContext(), *glSyncInfo); ctx->getSharing<OCLRT::GLSharingFunctions>()->glArbSyncObjectSignal(event.getCommandQueue()->getCommandStreamReceiver().getOsContext(), *glSyncInfo);
ctx->getSharing<OCLRT::GLSharingFunctions>()->glArbSyncObjectWaitServer(*osInterface, *glSyncInfo); ctx->getSharing<OCLRT::GLSharingFunctions>()->glArbSyncObjectWaitServer(*osInterface, *glSyncInfo);
} }
} // namespace OCLRT } // namespace OCLRT

View File

@@ -10,6 +10,7 @@
#include "runtime/command_stream/tbx_command_stream_receiver.h" #include "runtime/command_stream/tbx_command_stream_receiver.h"
#include "runtime/device/device.h" #include "runtime/device/device.h"
#include "runtime/helpers/hw_helper.h" #include "runtime/helpers/hw_helper.h"
#include "runtime/os_interface/os_context.h"
#include "unit_tests/aub_tests/command_stream/aub_command_stream_fixture.h" #include "unit_tests/aub_tests/command_stream/aub_command_stream_fixture.h"
#include "unit_tests/gen_common/gen_cmd_parse.h" #include "unit_tests/gen_common/gen_cmd_parse.h"
#include "unit_tests/helpers/memory_management.h" #include "unit_tests/helpers/memory_management.h"
@@ -28,7 +29,8 @@ void AUBCommandStreamFixture::SetUp(CommandQueue *pCmdQ) {
const ::testing::TestInfo *const testInfo = ::testing::UnitTest::GetInstance()->current_test_info(); const ::testing::TestInfo *const testInfo = ::testing::UnitTest::GetInstance()->current_test_info();
std::stringstream strfilename; std::stringstream strfilename;
strfilename << testInfo->test_case_name() << "_" << testInfo->name() << "_" << hwHelper.getCsTraits(device.getEngineType()).name; auto engineType = pCmdQ->getCommandStreamReceiver().getOsContext().getEngineType();
strfilename << testInfo->test_case_name() << "_" << testInfo->name() << "_" << hwHelper.getCsTraits(engineType.type).name;
if (testMode == TestMode::AubTestsWithTbx) { if (testMode == TestMode::AubTestsWithTbx) {
pCommandStreamReceiver = TbxCommandStreamReceiver::create(hwInfo, true, *device.executionEnvironment); pCommandStreamReceiver = TbxCommandStreamReceiver::create(hwInfo, true, *device.executionEnvironment);

View File

@@ -9,6 +9,7 @@
#include "runtime/command_stream/aub_command_stream_receiver_hw.h" #include "runtime/command_stream/aub_command_stream_receiver_hw.h"
#include "runtime/command_stream/command_stream_receiver_hw.h" #include "runtime/command_stream/command_stream_receiver_hw.h"
#include "runtime/helpers/ptr_math.h" #include "runtime/helpers/ptr_math.h"
#include "runtime/os_interface/os_context.h"
#include "unit_tests/command_queue/command_queue_fixture.h" #include "unit_tests/command_queue/command_queue_fixture.h"
#include "unit_tests/fixtures/device_fixture.h" #include "unit_tests/fixtures/device_fixture.h"
#include "unit_tests/gen_common/gen_cmd_parse.h" #include "unit_tests/gen_common/gen_cmd_parse.h"
@@ -37,7 +38,7 @@ struct AUBFixture : public AUBCommandStreamFixture,
} }
template <typename FamilyType> template <typename FamilyType>
void testNoopIdXcs(EngineType engineType) { void testNoopIdXcs() {
typedef typename FamilyType::MI_NOOP MI_NOOP; typedef typename FamilyType::MI_NOOP MI_NOOP;
auto pCmd = (MI_NOOP *)pCS->getSpace(sizeof(MI_NOOP) * 4); auto pCmd = (MI_NOOP *)pCS->getSpace(sizeof(MI_NOOP) * 4);
@@ -55,9 +56,10 @@ struct AUBFixture : public AUBCommandStreamFixture,
CommandStreamReceiverHw<FamilyType>::alignToCacheLine(*pCS); CommandStreamReceiverHw<FamilyType>::alignToCacheLine(*pCS);
BatchBuffer batchBuffer{pCS->getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, pCS->getUsed(), pCS}; BatchBuffer batchBuffer{pCS->getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, pCS->getUsed(), pCS};
ResidencyContainer allocationsForResidency; ResidencyContainer allocationsForResidency;
pCommandStreamReceiver->flush(batchBuffer, engineType, allocationsForResidency, *pDevice->getOsContext()); pCommandStreamReceiver->flush(batchBuffer, allocationsForResidency);
auto mmioBase = AUBCommandStreamReceiverHw<FamilyType>::getCsTraits(engineType).mmioBase; auto engineType = pCommandStreamReceiver->getOsContext().getEngineType();
auto mmioBase = AUBCommandStreamReceiverHw<FamilyType>::getCsTraits(engineType.type).mmioBase;
AUBCommandStreamFixture::expectMMIO<FamilyType>(mmioBase + 0x2094, noopId); AUBCommandStreamFixture::expectMMIO<FamilyType>(mmioBase + 0x2094, noopId);
} }
}; };
@@ -69,26 +71,30 @@ HWTEST_F(AUBcommandstreamTests, testFlushTwice) {
CommandStreamReceiverHw<FamilyType>::alignToCacheLine(*pCS); CommandStreamReceiverHw<FamilyType>::alignToCacheLine(*pCS);
BatchBuffer batchBuffer{pCS->getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, pCS->getUsed(), pCS}; BatchBuffer batchBuffer{pCS->getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, pCS->getUsed(), pCS};
ResidencyContainer allocationsForResidency; ResidencyContainer allocationsForResidency;
pCommandStreamReceiver->flush(batchBuffer, EngineType::ENGINE_RCS, allocationsForResidency, *pDevice->getOsContext()); pCommandStreamReceiver->flush(batchBuffer, allocationsForResidency);
BatchBuffer batchBuffer2{pCS->getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, pCS->getUsed(), pCS}; BatchBuffer batchBuffer2{pCS->getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, pCS->getUsed(), pCS};
ResidencyContainer allocationsForResidency2; ResidencyContainer allocationsForResidency2;
pCommandStreamReceiver->flush(batchBuffer2, EngineType::ENGINE_RCS, allocationsForResidency, *pDevice->getOsContext()); pCommandStreamReceiver->flush(batchBuffer2, allocationsForResidency);
} }
HWTEST_F(AUBcommandstreamTests, testNoopIdRcs) { HWTEST_F(AUBcommandstreamTests, testNoopIdRcs) {
testNoopIdXcs<FamilyType>(EngineType::ENGINE_RCS); pCommandStreamReceiver->getOsContext().getEngineType().type = EngineType::ENGINE_RCS;
testNoopIdXcs<FamilyType>();
} }
HWTEST_F(AUBcommandstreamTests, testNoopIdBcs) { HWTEST_F(AUBcommandstreamTests, testNoopIdBcs) {
testNoopIdXcs<FamilyType>(EngineType::ENGINE_BCS); pCommandStreamReceiver->getOsContext().getEngineType().type = EngineType::ENGINE_BCS;
testNoopIdXcs<FamilyType>();
} }
HWTEST_F(AUBcommandstreamTests, testNoopIdVcs) { HWTEST_F(AUBcommandstreamTests, testNoopIdVcs) {
testNoopIdXcs<FamilyType>(EngineType::ENGINE_VCS); pCommandStreamReceiver->getOsContext().getEngineType().type = EngineType::ENGINE_VCS;
testNoopIdXcs<FamilyType>();
} }
HWTEST_F(AUBcommandstreamTests, testNoopIdVecs) { HWTEST_F(AUBcommandstreamTests, testNoopIdVecs) {
testNoopIdXcs<FamilyType>(EngineType::ENGINE_VECS); pCommandStreamReceiver->getOsContext().getEngineType().type = EngineType::ENGINE_VECS;
testNoopIdXcs<FamilyType>();
} }
TEST_F(AUBcommandstreamTests, makeResident) { TEST_F(AUBcommandstreamTests, makeResident) {
@@ -97,7 +103,7 @@ TEST_F(AUBcommandstreamTests, makeResident) {
auto &commandStreamReceiver = pDevice->getCommandStreamReceiver(); auto &commandStreamReceiver = pDevice->getCommandStreamReceiver();
auto graphicsAllocation = createResidentAllocationAndStoreItInCsr(buffer, size); auto graphicsAllocation = createResidentAllocationAndStoreItInCsr(buffer, size);
ResidencyContainer allocationsForResidency = {graphicsAllocation}; ResidencyContainer allocationsForResidency = {graphicsAllocation};
commandStreamReceiver.processResidency(allocationsForResidency, *pDevice->getOsContext()); commandStreamReceiver.processResidency(allocationsForResidency);
} }
HWTEST_F(AUBcommandstreamTests, expectMemorySingle) { HWTEST_F(AUBcommandstreamTests, expectMemorySingle) {
@@ -105,7 +111,7 @@ HWTEST_F(AUBcommandstreamTests, expectMemorySingle) {
size_t size = sizeof(buffer); size_t size = sizeof(buffer);
auto graphicsAllocation = createResidentAllocationAndStoreItInCsr(&buffer, size); auto graphicsAllocation = createResidentAllocationAndStoreItInCsr(&buffer, size);
ResidencyContainer allocationsForResidency = {graphicsAllocation}; ResidencyContainer allocationsForResidency = {graphicsAllocation};
pCommandStreamReceiver->processResidency(allocationsForResidency, *pDevice->getOsContext()); pCommandStreamReceiver->processResidency(allocationsForResidency);
AUBCommandStreamFixture::expectMemory<FamilyType>(&buffer, &buffer, size); AUBCommandStreamFixture::expectMemory<FamilyType>(&buffer, &buffer, size);
} }
@@ -120,7 +126,7 @@ HWTEST_F(AUBcommandstreamTests, expectMemoryLarge) {
auto graphicsAllocation = createResidentAllocationAndStoreItInCsr(buffer, sizeBuffer); auto graphicsAllocation = createResidentAllocationAndStoreItInCsr(buffer, sizeBuffer);
ResidencyContainer allocationsForResidency = {graphicsAllocation}; ResidencyContainer allocationsForResidency = {graphicsAllocation};
pCommandStreamReceiver->processResidency(allocationsForResidency, *pDevice->getOsContext()); pCommandStreamReceiver->processResidency(allocationsForResidency);
AUBCommandStreamFixture::expectMemory<FamilyType>(buffer, buffer, sizeBuffer); AUBCommandStreamFixture::expectMemory<FamilyType>(buffer, buffer, sizeBuffer);
delete[] buffer; delete[] buffer;

View File

@@ -153,9 +153,7 @@ TEST(CommandQueue, IOQ_taskLevelFromCompletionStamp) {
CompletionStamp cs = { CompletionStamp cs = {
cmdQ.taskCount + 100, cmdQ.taskCount + 100,
cmdQ.taskLevel + 50, cmdQ.taskLevel + 50,
5, 5};
0,
EngineType::ENGINE_RCS};
cmdQ.updateFromCompletionStamp(cs); cmdQ.updateFromCompletionStamp(cs);
EXPECT_EQ(cs.taskLevel, cmdQ.taskLevel); EXPECT_EQ(cs.taskLevel, cmdQ.taskLevel);
@@ -173,9 +171,7 @@ TEST(CommandQueue, givenTimeStampWithTaskCountNotReadyStatusWhenupdateFromComple
CompletionStamp cs = { CompletionStamp cs = {
Event::eventNotReady, Event::eventNotReady,
0, 0,
0, 0};
0,
EngineType::ENGINE_RCS};
cmdQ.updateFromCompletionStamp(cs); cmdQ.updateFromCompletionStamp(cs);
EXPECT_EQ(1u, cmdQ.taskCount); EXPECT_EQ(1u, cmdQ.taskCount);
} }
@@ -190,9 +186,7 @@ TEST(CommandQueue, GivenOOQwhenUpdateFromCompletionStampWithTrueIsCalledThenTask
CompletionStamp cs = { CompletionStamp cs = {
cmdQ.taskCount + 100, cmdQ.taskCount + 100,
cmdQ.taskLevel + 50, cmdQ.taskLevel + 50,
5, 5};
0,
EngineType::ENGINE_RCS};
cmdQ.updateFromCompletionStamp(cs); cmdQ.updateFromCompletionStamp(cs);
EXPECT_NE(oldTL, cmdQ.taskLevel); EXPECT_NE(oldTL, cmdQ.taskLevel);

View File

@@ -33,7 +33,7 @@ class CommandStreamReceiverMock : public UltCommandStreamReceiver<FamilyType> {
this->pDevice = pDevice; this->pDevice = pDevice;
} }
FlushStamp flush(BatchBuffer &batchBuffer, EngineType engineType, ResidencyContainer &allocationsForResidency, OsContext &osContext) override { FlushStamp flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) override {
EXPECT_NE(nullptr, batchBuffer.commandBufferAllocation->getUnderlyingBuffer()); EXPECT_NE(nullptr, batchBuffer.commandBufferAllocation->getUnderlyingBuffer());
toFree.push_back(batchBuffer.commandBufferAllocation); toFree.push_back(batchBuffer.commandBufferAllocation);

View File

@@ -6,6 +6,7 @@
*/ */
#include "runtime/aub_mem_dump/page_table_entry_bits.h" #include "runtime/aub_mem_dump/page_table_entry_bits.h"
#include "runtime/os_interface/os_context.h"
#include "test.h" #include "test.h"
#include "unit_tests/fixtures/device_fixture.h" #include "unit_tests/fixtures/device_fixture.h"
#include "unit_tests/helpers/debug_manager_state_restore.h" #include "unit_tests/helpers/debug_manager_state_restore.h"
@@ -251,13 +252,12 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenFlushIs
LinearStream cs(aubExecutionEnvironment->commandBuffer); LinearStream cs(aubExecutionEnvironment->commandBuffer);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
auto engineType = OCLRT::ENGINE_RCS;
ResidencyContainer allocationsForResidency = {}; ResidencyContainer allocationsForResidency = {};
auto engineIndex = aubCsr->getEngineIndexFromInstance(aubCsr->getOsContext().getEngineType());
aubCsr->flush(batchBuffer, engineType, allocationsForResidency, *pDevice->getOsContext()); aubCsr->flush(batchBuffer, allocationsForResidency);
EXPECT_NE(nullptr, aubCsr->engineInfoTable[engineType].pLRCA); EXPECT_NE(nullptr, aubCsr->engineInfoTable[engineIndex].pLRCA);
EXPECT_NE(nullptr, aubCsr->engineInfoTable[engineType].pGlobalHWStatusPage); EXPECT_NE(nullptr, aubCsr->engineInfoTable[engineIndex].pGlobalHWStatusPage);
EXPECT_NE(nullptr, aubCsr->engineInfoTable[engineType].pRingBuffer); EXPECT_NE(nullptr, aubCsr->engineInfoTable[engineIndex].pRingBuffer);
} }
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInSubCaptureModeWhenFlushIsCalledButSubCaptureIsDisabledThenItShouldntInitializeEngineInfoTable) { HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInSubCaptureModeWhenFlushIsCalledButSubCaptureIsDisabledThenItShouldntInitializeEngineInfoTable) {
@@ -272,10 +272,9 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInSubCaptur
ASSERT_FALSE(aubCsr->subCaptureManager->isSubCaptureEnabled()); ASSERT_FALSE(aubCsr->subCaptureManager->isSubCaptureEnabled());
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
auto engineType = OCLRT::ENGINE_RCS;
ResidencyContainer allocationsForResidency = {}; ResidencyContainer allocationsForResidency = {};
auto engineType = aubCsr->getOsContext().getEngineType().type;
aubCsr->flush(batchBuffer, engineType, allocationsForResidency, *pDevice->getOsContext()); aubCsr->flush(batchBuffer, allocationsForResidency);
EXPECT_EQ(nullptr, aubCsr->engineInfoTable[engineType].pLRCA); EXPECT_EQ(nullptr, aubCsr->engineInfoTable[engineType].pLRCA);
EXPECT_EQ(nullptr, aubCsr->engineInfoTable[engineType].pGlobalHWStatusPage); EXPECT_EQ(nullptr, aubCsr->engineInfoTable[engineType].pGlobalHWStatusPage);
EXPECT_EQ(nullptr, aubCsr->engineInfoTable[engineType].pRingBuffer); EXPECT_EQ(nullptr, aubCsr->engineInfoTable[engineType].pRingBuffer);
@@ -287,19 +286,18 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenFlushIs
auto allocationsForResidency = aubCsr->getResidencyAllocations(); auto allocationsForResidency = aubCsr->getResidencyAllocations();
LinearStream cs(aubExecutionEnvironment->commandBuffer); LinearStream cs(aubExecutionEnvironment->commandBuffer);
auto engineType = OCLRT::ENGINE_RCS;
auto ringTailAlignment = sizeof(uint64_t); auto ringTailAlignment = sizeof(uint64_t);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
auto engineType = aubCsr->getOsContext().getEngineType().type;
// First flush typically includes a preamble and chain to command buffer // First flush typically includes a preamble and chain to command buffer
aubCsr->overrideDispatchPolicy(DispatchMode::ImmediateDispatch); aubCsr->overrideDispatchPolicy(DispatchMode::ImmediateDispatch);
aubCsr->flush(batchBuffer, engineType, allocationsForResidency, *pDevice->getOsContext()); aubCsr->flush(batchBuffer, allocationsForResidency);
EXPECT_EQ(0ull, aubCsr->engineInfoTable[engineType].tailRingBuffer % ringTailAlignment); EXPECT_EQ(0ull, aubCsr->engineInfoTable[engineType].tailRingBuffer % ringTailAlignment);
// Second flush should just submit command buffer // Second flush should just submit command buffer
cs.getSpace(sizeof(uint64_t)); cs.getSpace(sizeof(uint64_t));
aubCsr->flush(batchBuffer, engineType, allocationsForResidency, *pDevice->getOsContext()); aubCsr->flush(batchBuffer, allocationsForResidency);
EXPECT_EQ(0ull, aubCsr->engineInfoTable[engineType].tailRingBuffer % ringTailAlignment); EXPECT_EQ(0ull, aubCsr->engineInfoTable[engineType].tailRingBuffer % ringTailAlignment);
} }
@@ -309,7 +307,6 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInNonStanda
LinearStream cs(aubExecutionEnvironment->commandBuffer); LinearStream cs(aubExecutionEnvironment->commandBuffer);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
auto engineType = OCLRT::ENGINE_RCS;
ResidencyContainer allocationsForResidency = {}; ResidencyContainer allocationsForResidency = {};
EXPECT_EQ(initialHardwareTag, *aubCsr->getTagAddress()); EXPECT_EQ(initialHardwareTag, *aubCsr->getTagAddress());
@@ -318,7 +315,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInNonStanda
EXPECT_NE(aubCsr->peekLatestSentTaskCount(), *aubCsr->getTagAddress()); EXPECT_NE(aubCsr->peekLatestSentTaskCount(), *aubCsr->getTagAddress());
aubCsr->flush(batchBuffer, engineType, allocationsForResidency, *pDevice->getOsContext()); aubCsr->flush(batchBuffer, allocationsForResidency);
EXPECT_NE(aubCsr->peekLatestSentTaskCount(), *aubCsr->getTagAddress()); EXPECT_NE(aubCsr->peekLatestSentTaskCount(), *aubCsr->getTagAddress());
EXPECT_EQ(initialHardwareTag, *aubCsr->getTagAddress()); EXPECT_EQ(initialHardwareTag, *aubCsr->getTagAddress());
@@ -330,7 +327,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandalon
LinearStream cs(aubExecutionEnvironment->commandBuffer); LinearStream cs(aubExecutionEnvironment->commandBuffer);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
auto engineType = OCLRT::ENGINE_RCS;
ResidencyContainer allocationsForResidency = {}; ResidencyContainer allocationsForResidency = {};
EXPECT_EQ(initialHardwareTag, *aubCsr->getTagAddress()); EXPECT_EQ(initialHardwareTag, *aubCsr->getTagAddress());
@@ -339,7 +336,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandalon
EXPECT_NE(aubCsr->peekLatestSentTaskCount(), *aubCsr->getTagAddress()); EXPECT_NE(aubCsr->peekLatestSentTaskCount(), *aubCsr->getTagAddress());
aubCsr->flush(batchBuffer, engineType, allocationsForResidency, *pDevice->getOsContext()); aubCsr->flush(batchBuffer, allocationsForResidency);
EXPECT_EQ(aubCsr->peekLatestSentTaskCount(), *aubCsr->getTagAddress()); EXPECT_EQ(aubCsr->peekLatestSentTaskCount(), *aubCsr->getTagAddress());
} }
@@ -357,14 +354,14 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandalon
ASSERT_FALSE(aubCsr->subCaptureManager->isSubCaptureEnabled()); ASSERT_FALSE(aubCsr->subCaptureManager->isSubCaptureEnabled());
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
auto engineType = OCLRT::ENGINE_RCS;
ResidencyContainer allocationsForResidency = {}; ResidencyContainer allocationsForResidency = {};
aubCsr->setLatestSentTaskCount(aubCsr->peekTaskCount() + 1); aubCsr->setLatestSentTaskCount(aubCsr->peekTaskCount() + 1);
EXPECT_NE(aubCsr->peekLatestSentTaskCount(), *aubCsr->getTagAddress()); EXPECT_NE(aubCsr->peekLatestSentTaskCount(), *aubCsr->getTagAddress());
aubCsr->flush(batchBuffer, engineType, allocationsForResidency, *pDevice->getOsContext()); aubCsr->flush(batchBuffer, allocationsForResidency);
EXPECT_EQ(aubCsr->peekLatestSentTaskCount(), *aubCsr->getTagAddress()); EXPECT_EQ(aubCsr->peekLatestSentTaskCount(), *aubCsr->getTagAddress());
} }
@@ -382,14 +379,14 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInNonStanda
ASSERT_FALSE(aubCsr->subCaptureManager->isSubCaptureEnabled()); ASSERT_FALSE(aubCsr->subCaptureManager->isSubCaptureEnabled());
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
auto engineType = OCLRT::ENGINE_RCS;
ResidencyContainer allocationsForResidency = {}; ResidencyContainer allocationsForResidency = {};
aubCsr->setLatestSentTaskCount(aubCsr->peekTaskCount() + 1); aubCsr->setLatestSentTaskCount(aubCsr->peekTaskCount() + 1);
EXPECT_NE(aubCsr->peekLatestSentTaskCount(), *aubCsr->getTagAddress()); EXPECT_NE(aubCsr->peekLatestSentTaskCount(), *aubCsr->getTagAddress());
aubCsr->flush(batchBuffer, engineType, allocationsForResidency, *pDevice->getOsContext()); aubCsr->flush(batchBuffer, allocationsForResidency);
EXPECT_NE(aubCsr->peekLatestSentTaskCount(), *aubCsr->getTagAddress()); EXPECT_NE(aubCsr->peekLatestSentTaskCount(), *aubCsr->getTagAddress());
EXPECT_EQ(initialHardwareTag, *aubCsr->getTagAddress()); EXPECT_EQ(initialHardwareTag, *aubCsr->getTagAddress());
@@ -413,10 +410,10 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInSubCaptur
ASSERT_TRUE(aubCsr->subCaptureManager->isSubCaptureEnabled()); ASSERT_TRUE(aubCsr->subCaptureManager->isSubCaptureEnabled());
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
auto engineType = OCLRT::ENGINE_RCS;
ResidencyContainer allocationsForResidency = {}; ResidencyContainer allocationsForResidency = {};
aubCsr->flush(batchBuffer, engineType, allocationsForResidency, *pDevice->getOsContext()); aubCsr->flush(batchBuffer, allocationsForResidency);
EXPECT_FALSE(aubCsr->subCaptureManager->isSubCaptureEnabled()); EXPECT_FALSE(aubCsr->subCaptureManager->isSubCaptureEnabled());
} }
@@ -429,17 +426,16 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandalon
LinearStream cs(commandBuffer); LinearStream cs(commandBuffer);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
auto engineType = OCLRT::ENGINE_RCS;
EXPECT_FALSE(commandBuffer->isResident(0u)); EXPECT_FALSE(commandBuffer->isResident(0u));
aubCsr->overrideDispatchPolicy(DispatchMode::ImmediateDispatch); aubCsr->overrideDispatchPolicy(DispatchMode::ImmediateDispatch);
aubCsr->flush(batchBuffer, engineType, allocationsForResidency, *pDevice->getOsContext()); aubCsr->flush(batchBuffer, allocationsForResidency);
EXPECT_TRUE(commandBuffer->isResident(0u)); EXPECT_TRUE(commandBuffer->isResident(0u));
EXPECT_EQ(aubCsr->peekTaskCount() + 1, commandBuffer->getResidencyTaskCount(0u)); EXPECT_EQ(aubCsr->peekTaskCount() + 1, commandBuffer->getResidencyTaskCount(0u));
aubCsr->makeSurfacePackNonResident(aubCsr->getResidencyAllocations(), *pDevice->getOsContext()); aubCsr->makeSurfacePackNonResident(aubCsr->getResidencyAllocations());
EXPECT_FALSE(commandBuffer->isResident(0u)); EXPECT_FALSE(commandBuffer->isResident(0u));
} }
@@ -451,11 +447,10 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInNonStanda
LinearStream cs(aubExecutionEnvironment->commandBuffer); LinearStream cs(aubExecutionEnvironment->commandBuffer);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
auto engineType = OCLRT::ENGINE_RCS;
EXPECT_FALSE(aubExecutionEnvironment->commandBuffer->isResident(0u)); EXPECT_FALSE(aubExecutionEnvironment->commandBuffer->isResident(0u));
aubCsr->flush(batchBuffer, engineType, allocationsForResidency, *pDevice->getOsContext()); aubCsr->flush(batchBuffer, allocationsForResidency);
EXPECT_FALSE(aubExecutionEnvironment->commandBuffer->isResident(0u)); EXPECT_FALSE(aubExecutionEnvironment->commandBuffer->isResident(0u));
} }
@@ -471,14 +466,14 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandalon
ASSERT_NE(nullptr, gfxAllocation); ASSERT_NE(nullptr, gfxAllocation);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
auto engineType = OCLRT::ENGINE_RCS;
ResidencyContainer allocationsForResidency = {gfxAllocation}; ResidencyContainer allocationsForResidency = {gfxAllocation};
EXPECT_FALSE(gfxAllocation->isResident(0u)); EXPECT_FALSE(gfxAllocation->isResident(0u));
EXPECT_FALSE(commandBuffer->isResident(0u)); EXPECT_FALSE(commandBuffer->isResident(0u));
aubCsr->overrideDispatchPolicy(DispatchMode::BatchedDispatch); aubCsr->overrideDispatchPolicy(DispatchMode::BatchedDispatch);
aubCsr->flush(batchBuffer, engineType, allocationsForResidency, *pDevice->getOsContext()); aubCsr->flush(batchBuffer, allocationsForResidency);
EXPECT_TRUE(gfxAllocation->isResident(0u)); EXPECT_TRUE(gfxAllocation->isResident(0u));
EXPECT_EQ(aubCsr->peekTaskCount() + 1, gfxAllocation->getResidencyTaskCount(0u)); EXPECT_EQ(aubCsr->peekTaskCount() + 1, gfxAllocation->getResidencyTaskCount(0u));
@@ -486,7 +481,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandalon
EXPECT_TRUE(commandBuffer->isResident(0u)); EXPECT_TRUE(commandBuffer->isResident(0u));
EXPECT_EQ(aubCsr->peekTaskCount() + 1, commandBuffer->getResidencyTaskCount(0u)); EXPECT_EQ(aubCsr->peekTaskCount() + 1, commandBuffer->getResidencyTaskCount(0u));
aubCsr->makeSurfacePackNonResident(allocationsForResidency, *pDevice->getOsContext()); aubCsr->makeSurfacePackNonResident(allocationsForResidency);
EXPECT_FALSE(gfxAllocation->isResident(0u)); EXPECT_FALSE(gfxAllocation->isResident(0u));
EXPECT_FALSE(commandBuffer->isResident(0u)); EXPECT_FALSE(commandBuffer->isResident(0u));
@@ -504,13 +499,13 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInNonStanda
auto gfxAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false); auto gfxAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
auto engineType = OCLRT::ENGINE_RCS;
ResidencyContainer allocationsForResidency = {gfxAllocation}; ResidencyContainer allocationsForResidency = {gfxAllocation};
EXPECT_FALSE(gfxAllocation->isResident(0u)); EXPECT_FALSE(gfxAllocation->isResident(0u));
EXPECT_FALSE(commandBuffer->isResident(0u)); EXPECT_FALSE(commandBuffer->isResident(0u));
aubCsr->flush(batchBuffer, engineType, allocationsForResidency, *pDevice->getOsContext()); aubCsr->flush(batchBuffer, allocationsForResidency);
EXPECT_TRUE(gfxAllocation->isResident(0u)); EXPECT_TRUE(gfxAllocation->isResident(0u));
EXPECT_EQ(aubCsr->peekTaskCount() + 1, gfxAllocation->getResidencyTaskCount(0u)); EXPECT_EQ(aubCsr->peekTaskCount() + 1, gfxAllocation->getResidencyTaskCount(0u));
@@ -542,14 +537,14 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandalon
ASSERT_NE(nullptr, gfxAllocation); ASSERT_NE(nullptr, gfxAllocation);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
auto engineType = OCLRT::ENGINE_RCS;
ResidencyContainer allocationsForResidency = {gfxAllocation}; ResidencyContainer allocationsForResidency = {gfxAllocation};
EXPECT_FALSE(gfxAllocation->isResident(0u)); EXPECT_FALSE(gfxAllocation->isResident(0u));
EXPECT_FALSE(commandBuffer->isResident(0u)); EXPECT_FALSE(commandBuffer->isResident(0u));
aubCsr->overrideDispatchPolicy(DispatchMode::BatchedDispatch); aubCsr->overrideDispatchPolicy(DispatchMode::BatchedDispatch);
aubCsr->flush(batchBuffer, engineType, allocationsForResidency, *pDevice->getOsContext()); aubCsr->flush(batchBuffer, allocationsForResidency);
EXPECT_TRUE(gfxAllocation->isResident(0u)); EXPECT_TRUE(gfxAllocation->isResident(0u));
EXPECT_EQ(aubCsr->peekTaskCount() + 1, gfxAllocation->getResidencyTaskCount(0u)); EXPECT_EQ(aubCsr->peekTaskCount() + 1, gfxAllocation->getResidencyTaskCount(0u));
@@ -557,7 +552,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandalon
EXPECT_TRUE(commandBuffer->isResident(0u)); EXPECT_TRUE(commandBuffer->isResident(0u));
EXPECT_EQ(aubCsr->peekTaskCount() + 1, commandBuffer->getResidencyTaskCount(0u)); EXPECT_EQ(aubCsr->peekTaskCount() + 1, commandBuffer->getResidencyTaskCount(0u));
aubCsr->makeSurfacePackNonResident(allocationsForResidency, *pDevice->getOsContext()); aubCsr->makeSurfacePackNonResident(allocationsForResidency);
EXPECT_FALSE(gfxAllocation->isResident(0u)); EXPECT_FALSE(gfxAllocation->isResident(0u));
EXPECT_FALSE(commandBuffer->isResident(0u)); EXPECT_FALSE(commandBuffer->isResident(0u));
@@ -584,7 +579,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenProcess
auto gfxDefaultAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false); auto gfxDefaultAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
ResidencyContainer allocationsForResidency = {gfxDefaultAllocation}; ResidencyContainer allocationsForResidency = {gfxDefaultAllocation};
aubCsr->processResidency(allocationsForResidency, *pDevice->getOsContext()); aubCsr->processResidency(allocationsForResidency);
EXPECT_TRUE(gfxDefaultAllocation->isAubWritable()); EXPECT_TRUE(gfxDefaultAllocation->isAubWritable());
@@ -627,7 +622,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenProcess
gfxImageAllocation->setAllocationType(GraphicsAllocation::AllocationType::IMAGE); gfxImageAllocation->setAllocationType(GraphicsAllocation::AllocationType::IMAGE);
ResidencyContainer allocationsForResidency = {gfxBufferAllocation, gfxImageAllocation}; ResidencyContainer allocationsForResidency = {gfxBufferAllocation, gfxImageAllocation};
aubCsr->processResidency(allocationsForResidency, *pDevice->getOsContext()); aubCsr->processResidency(allocationsForResidency);
EXPECT_FALSE(gfxBufferAllocation->isAubWritable()); EXPECT_FALSE(gfxBufferAllocation->isAubWritable());
EXPECT_FALSE(gfxImageAllocation->isAubWritable()); EXPECT_FALSE(gfxImageAllocation->isAubWritable());
@@ -653,7 +648,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInSubCaptur
aubCsr->dumpAubNonWritable = true; aubCsr->dumpAubNonWritable = true;
ResidencyContainer allocationsForResidency = {gfxBufferAllocation, gfxImageAllocation}; ResidencyContainer allocationsForResidency = {gfxBufferAllocation, gfxImageAllocation};
aubCsr->processResidency(allocationsForResidency, *pDevice->getOsContext()); aubCsr->processResidency(allocationsForResidency);
EXPECT_TRUE(gfxBufferAllocation->isAubWritable()); EXPECT_TRUE(gfxBufferAllocation->isAubWritable());
EXPECT_TRUE(gfxImageAllocation->isAubWritable()); EXPECT_TRUE(gfxImageAllocation->isAubWritable());
@@ -679,7 +674,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenProcess
aubCsr->dumpAubNonWritable = false; aubCsr->dumpAubNonWritable = false;
ResidencyContainer allocationsForResidency = {gfxBufferAllocation, gfxImageAllocation}; ResidencyContainer allocationsForResidency = {gfxBufferAllocation, gfxImageAllocation};
aubCsr->processResidency(allocationsForResidency, *pDevice->getOsContext()); aubCsr->processResidency(allocationsForResidency);
EXPECT_FALSE(gfxBufferAllocation->isAubWritable()); EXPECT_FALSE(gfxBufferAllocation->isAubWritable());
EXPECT_FALSE(gfxImageAllocation->isAubWritable()); EXPECT_FALSE(gfxImageAllocation->isAubWritable());

View File

@@ -259,11 +259,10 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenDefault
aubCsr->overwriteFlatBatchBufferHelper(mockHelper); aubCsr->overwriteFlatBatchBufferHelper(mockHelper);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
auto engineType = OCLRT::ENGINE_RCS;
ResidencyContainer allocationsForResidency = {}; ResidencyContainer allocationsForResidency = {};
EXPECT_CALL(*mockHelper, flattenBatchBuffer(::testing::_, ::testing::_, ::testing::_)).Times(0); EXPECT_CALL(*mockHelper, flattenBatchBuffer(::testing::_, ::testing::_, ::testing::_)).Times(0);
aubCsr->flush(batchBuffer, engineType, allocationsForResidency, *pDevice->getOsContext()); aubCsr->flush(batchBuffer, allocationsForResidency);
} }
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedFlattenBatchBufferAndImmediateDispatchModeThenExpectFlattenBatchBufferIsCalled) { HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedFlattenBatchBufferAndImmediateDispatchModeThenExpectFlattenBatchBufferIsCalled) {
@@ -283,7 +282,6 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedF
ASSERT_NE(nullptr, chainedBatchBuffer); ASSERT_NE(nullptr, chainedBatchBuffer);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 128u, chainedBatchBuffer, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 128u, chainedBatchBuffer, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
auto engineType = OCLRT::ENGINE_RCS;
aubCsr->makeResident(*chainedBatchBuffer); aubCsr->makeResident(*chainedBatchBuffer);
@@ -293,7 +291,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedF
auto expectedAllocation = ptr.get(); auto expectedAllocation = ptr.get();
EXPECT_CALL(*mockHelper, flattenBatchBuffer(::testing::_, ::testing::_, ::testing::_)).WillOnce(::testing::Return(ptr.release())); EXPECT_CALL(*mockHelper, flattenBatchBuffer(::testing::_, ::testing::_, ::testing::_)).WillOnce(::testing::Return(ptr.release()));
aubCsr->flush(batchBuffer, engineType, allocationsForResidency, *pDevice->getOsContext()); aubCsr->flush(batchBuffer, allocationsForResidency);
EXPECT_EQ(batchBuffer.commandBufferAllocation, expectedAllocation); EXPECT_EQ(batchBuffer.commandBufferAllocation, expectedAllocation);
@@ -314,10 +312,9 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedF
aubCsr->overwriteFlatBatchBufferHelper(mockHelper); aubCsr->overwriteFlatBatchBufferHelper(mockHelper);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 128u, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 128u, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
auto engineType = OCLRT::ENGINE_RCS;
EXPECT_CALL(*mockHelper, flattenBatchBuffer(::testing::_, ::testing::_, ::testing::_)).Times(1); EXPECT_CALL(*mockHelper, flattenBatchBuffer(::testing::_, ::testing::_, ::testing::_)).Times(1);
aubCsr->flush(batchBuffer, engineType, allocationsForResidency, *pDevice->getOsContext()); aubCsr->flush(batchBuffer, allocationsForResidency);
} }
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedFlattenBatchBufferAndBatchedDispatchModeThenExpectFlattenBatchBufferIsCalledAnyway) { HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedFlattenBatchBufferAndBatchedDispatchModeThenExpectFlattenBatchBufferIsCalledAnyway) {
@@ -334,10 +331,9 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedF
ResidencyContainer allocationsForResidency; ResidencyContainer allocationsForResidency;
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 128u, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 128u, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
auto engineType = OCLRT::ENGINE_RCS;
EXPECT_CALL(*mockHelper, flattenBatchBuffer(::testing::_, ::testing::_, ::testing::_)).Times(1); EXPECT_CALL(*mockHelper, flattenBatchBuffer(::testing::_, ::testing::_, ::testing::_)).Times(1);
aubCsr->flush(batchBuffer, engineType, allocationsForResidency, *pDevice->getOsContext()); aubCsr->flush(batchBuffer, allocationsForResidency);
} }
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenAddPatchInfoCommentsForAUBDumpIsSetThenAddPatchInfoCommentsIsCalled) { HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenAddPatchInfoCommentsForAUBDumpIsSetThenAddPatchInfoCommentsIsCalled) {
@@ -349,11 +345,11 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenAddPatc
LinearStream cs(aubExecutionEnvironment->commandBuffer); LinearStream cs(aubExecutionEnvironment->commandBuffer);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
auto engineType = OCLRT::ENGINE_RCS;
ResidencyContainer allocationsForResidency; ResidencyContainer allocationsForResidency;
EXPECT_CALL(*aubCsr, addPatchInfoComments()).Times(1); EXPECT_CALL(*aubCsr, addPatchInfoComments()).Times(1);
aubCsr->flush(batchBuffer, engineType, allocationsForResidency, *pDevice->getOsContext()); aubCsr->flush(batchBuffer, allocationsForResidency);
} }
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenAddPatchInfoCommentsForAUBDumpIsNotSetThenAddPatchInfoCommentsIsNotCalled) { HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenAddPatchInfoCommentsForAUBDumpIsNotSetThenAddPatchInfoCommentsIsNotCalled) {
@@ -362,12 +358,12 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenAddPatc
LinearStream cs(aubExecutionEnvironment->commandBuffer); LinearStream cs(aubExecutionEnvironment->commandBuffer);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
auto engineType = OCLRT::ENGINE_RCS;
ResidencyContainer allocationsForResidency; ResidencyContainer allocationsForResidency;
EXPECT_CALL(*aubCsr, addPatchInfoComments()).Times(0); EXPECT_CALL(*aubCsr, addPatchInfoComments()).Times(0);
aubCsr->flush(batchBuffer, engineType, allocationsForResidency, *pDevice->getOsContext()); aubCsr->flush(batchBuffer, allocationsForResidency);
} }
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenGetIndirectPatchCommandsIsCalledForEmptyPatchInfoListThenIndirectPatchCommandBufferIsNotCreated) { HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenGetIndirectPatchCommandsIsCalledForEmptyPatchInfoListThenIndirectPatchCommandBufferIsNotCreated) {
@@ -626,7 +622,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenProcess
ASSERT_EQ(1u, aubCsr->externalAllocations.size()); ASSERT_EQ(1u, aubCsr->externalAllocations.size());
ResidencyContainer allocationsForResidency; ResidencyContainer allocationsForResidency;
aubCsr->processResidency(allocationsForResidency, *pDevice->getOsContext()); aubCsr->processResidency(allocationsForResidency);
EXPECT_TRUE(aubCsr->writeMemoryParametrization.wasCalled); EXPECT_TRUE(aubCsr->writeMemoryParametrization.wasCalled);
EXPECT_EQ(addr, aubCsr->writeMemoryParametrization.receivedAllocationView.first); EXPECT_EQ(addr, aubCsr->writeMemoryParametrization.receivedAllocationView.first);
@@ -641,7 +637,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenProcess
ASSERT_EQ(1u, aubCsr->externalAllocations.size()); ASSERT_EQ(1u, aubCsr->externalAllocations.size());
ResidencyContainer allocationsForResidency; ResidencyContainer allocationsForResidency;
aubCsr->processResidency(allocationsForResidency, *pDevice->getOsContext()); aubCsr->processResidency(allocationsForResidency);
EXPECT_TRUE(aubCsr->writeMemoryParametrization.wasCalled); EXPECT_TRUE(aubCsr->writeMemoryParametrization.wasCalled);
EXPECT_EQ(0u, aubCsr->writeMemoryParametrization.receivedAllocationView.first); EXPECT_EQ(0u, aubCsr->writeMemoryParametrization.receivedAllocationView.first);

View File

@@ -111,10 +111,9 @@ HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenFlushIsCalledThenF
aubCsr->stream = mockAubFileStreamPtr; aubCsr->stream = mockAubFileStreamPtr;
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
auto engineType = OCLRT::ENGINE_RCS;
ResidencyContainer allocationsForResidency = {}; ResidencyContainer allocationsForResidency = {};
aubCsr->flush(batchBuffer, engineType, allocationsForResidency, *pDevice->getOsContext()); aubCsr->flush(batchBuffer, allocationsForResidency);
EXPECT_TRUE(mockAubFileStreamPtr->lockStreamCalled); EXPECT_TRUE(mockAubFileStreamPtr->lockStreamCalled);
} }
@@ -124,10 +123,9 @@ HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenFlushIsCalledThenI
LinearStream cs(aubExecutionEnvironment->commandBuffer); LinearStream cs(aubExecutionEnvironment->commandBuffer);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
auto engineType = OCLRT::ENGINE_RCS;
ResidencyContainer allocationsForResidency = {}; ResidencyContainer allocationsForResidency = {};
aubCsr->flush(batchBuffer, engineType, allocationsForResidency, *pDevice->getOsContext()); aubCsr->flush(batchBuffer, allocationsForResidency);
EXPECT_TRUE(aubCsr->writeMemoryCalled); EXPECT_TRUE(aubCsr->writeMemoryCalled);
EXPECT_TRUE(aubCsr->submitBatchBufferCalled); EXPECT_TRUE(aubCsr->submitBatchBufferCalled);
@@ -145,10 +143,9 @@ HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenFlushIsCalledThenF
aubCsr->stream = mockAubFileStreamPtr; aubCsr->stream = mockAubFileStreamPtr;
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
auto engineType = OCLRT::ENGINE_RCS;
ResidencyContainer allocationsForResidency = {}; ResidencyContainer allocationsForResidency = {};
aubCsr->flush(batchBuffer, engineType, allocationsForResidency, *pDevice->getOsContext()); aubCsr->flush(batchBuffer, allocationsForResidency);
EXPECT_TRUE(mockAubFileStreamPtr->flushCalled); EXPECT_TRUE(mockAubFileStreamPtr->flushCalled);
} }

View File

@@ -7,6 +7,7 @@
#include "runtime/command_queue/gpgpu_walker.h" #include "runtime/command_queue/gpgpu_walker.h"
#include "runtime/gmm_helper/gmm_helper.h" #include "runtime/gmm_helper/gmm_helper.h"
#include "runtime/os_interface/os_context.h"
#include "test.h" #include "test.h"
#include "unit_tests/fixtures/ult_command_stream_receiver_fixture.h" #include "unit_tests/fixtures/ult_command_stream_receiver_fixture.h"
#include "unit_tests/helpers/debug_manager_state_restore.h" #include "unit_tests/helpers/debug_manager_state_restore.h"
@@ -392,14 +393,11 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, completionStampValid) {
HWTEST_F(CommandStreamReceiverFlushTaskTests, completionStamp) { HWTEST_F(CommandStreamReceiverFlushTaskTests, completionStamp) {
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>(); auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
auto deviceEngineType = pDevice->getEngineType();
auto completionStamp = flushTask(commandStreamReceiver); auto completionStamp = flushTask(commandStreamReceiver);
EXPECT_EQ(1u, completionStamp.taskCount); EXPECT_EQ(1u, completionStamp.taskCount);
EXPECT_EQ(taskLevel, completionStamp.taskLevel); EXPECT_EQ(taskLevel, completionStamp.taskLevel);
EXPECT_EQ(commandStreamReceiver.flushStamp->peekStamp(), completionStamp.flushStamp); EXPECT_EQ(commandStreamReceiver.flushStamp->peekStamp(), completionStamp.flushStamp);
EXPECT_EQ(0u, completionStamp.deviceOrdinal);
EXPECT_EQ(deviceEngineType, completionStamp.engineType);
} }
HWTEST_F(CommandStreamReceiverFlushTaskTests, stateBaseAddressTracking) { HWTEST_F(CommandStreamReceiverFlushTaskTests, stateBaseAddressTracking) {
@@ -740,7 +738,7 @@ struct CommandStreamReceiverHwLog : public UltCommandStreamReceiver<FamilyType>
flushCount(0) { flushCount(0) {
} }
FlushStamp flush(BatchBuffer &batchBuffer, EngineType engineType, ResidencyContainer &allocationsForResidency, OsContext &osContext) override { FlushStamp flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) override {
++flushCount; ++flushCount;
return 0; return 0;
} }

View File

@@ -7,6 +7,7 @@
#include "reg_configs_common.h" #include "reg_configs_common.h"
#include "runtime/memory_manager/internal_allocation_storage.h" #include "runtime/memory_manager/internal_allocation_storage.h"
#include "runtime/os_interface/os_context.h"
#include "test.h" #include "test.h"
#include "unit_tests/fixtures/ult_command_stream_receiver_fixture.h" #include "unit_tests/fixtures/ult_command_stream_receiver_fixture.h"
#include "unit_tests/helpers/debug_manager_state_restore.h" #include "unit_tests/helpers/debug_manager_state_restore.h"
@@ -66,7 +67,6 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, FlushTaskWithTaskCSPassedAsCommand
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>(); auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
auto &commandStreamTask = commandQueue.getCS(1024); auto &commandStreamTask = commandQueue.getCS(1024);
auto deviceEngineType = pDevice->getEngineType();
DispatchFlags dispatchFlags; DispatchFlags dispatchFlags;
@@ -84,8 +84,6 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, FlushTaskWithTaskCSPassedAsCommand
// Verify that flushTask returned a valid completion stamp // Verify that flushTask returned a valid completion stamp
EXPECT_EQ(commandStreamReceiver.peekTaskCount(), cs.taskCount); EXPECT_EQ(commandStreamReceiver.peekTaskCount(), cs.taskCount);
EXPECT_EQ(commandStreamReceiver.peekTaskLevel(), cs.taskLevel); EXPECT_EQ(commandStreamReceiver.peekTaskLevel(), cs.taskLevel);
EXPECT_EQ(0u, cs.deviceOrdinal);
EXPECT_EQ(deviceEngineType, cs.engineType);
} }
HWTEST_F(CommandStreamReceiverFlushTaskTests, TrackSentTagsWhenEmptyQueue) { HWTEST_F(CommandStreamReceiverFlushTaskTests, TrackSentTagsWhenEmptyQueue) {

View File

@@ -210,7 +210,7 @@ TEST_F(CommandStreamReceiverTest, makeResidentPushesAllocationToMemoryManagerRes
} }
TEST_F(CommandStreamReceiverTest, makeResidentWithoutParametersDoesNothing) { TEST_F(CommandStreamReceiverTest, makeResidentWithoutParametersDoesNothing) {
commandStreamReceiver->processResidency(commandStreamReceiver->getResidencyAllocations(), *pDevice->getOsContext()); commandStreamReceiver->processResidency(commandStreamReceiver->getResidencyAllocations());
auto &residencyAllocations = commandStreamReceiver->getResidencyAllocations(); auto &residencyAllocations = commandStreamReceiver->getResidencyAllocations();
EXPECT_EQ(0u, residencyAllocations.size()); EXPECT_EQ(0u, residencyAllocations.size());
} }

View File

@@ -21,12 +21,12 @@ struct MyMockCsr : UltCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME> {
: UltCommandStreamReceiver(hwInfoIn, executionEnvironment) { : UltCommandStreamReceiver(hwInfoIn, executionEnvironment) {
} }
FlushStamp flush(BatchBuffer &batchBuffer, EngineType engineOrdinal, ResidencyContainer &allocationsForResidency, OsContext &osContext) override { FlushStamp flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) override {
flushParametrization.wasCalled = true; flushParametrization.wasCalled = true;
flushParametrization.receivedBatchBuffer = &batchBuffer; flushParametrization.receivedBatchBuffer = &batchBuffer;
flushParametrization.receivedEngine = engineOrdinal; flushParametrization.receivedEngine = osContext->getEngineType().type;
flushParametrization.receivedAllocationsForResidency = &allocationsForResidency; flushParametrization.receivedAllocationsForResidency = &allocationsForResidency;
processResidency(allocationsForResidency, osContext); processResidency(allocationsForResidency);
return flushParametrization.flushStampToReturn; return flushParametrization.flushStampToReturn;
} }
@@ -36,7 +36,7 @@ struct MyMockCsr : UltCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME> {
gfxAllocation.updateResidencyTaskCount(1, deviceIndex); gfxAllocation.updateResidencyTaskCount(1, deviceIndex);
} }
void processResidency(ResidencyContainer &allocationsForResidency, OsContext &osContext) override { void processResidency(ResidencyContainer &allocationsForResidency) override {
processResidencyParameterization.wasCalled = true; processResidencyParameterization.wasCalled = true;
processResidencyParameterization.receivedAllocationsForResidency = &allocationsForResidency; processResidencyParameterization.receivedAllocationsForResidency = &allocationsForResidency;
} }
@@ -109,6 +109,12 @@ struct CommandStreamReceiverWithAubDumpTest : public ::testing::TestWithParam<bo
memoryManager = csrWithAubDump->createMemoryManager(false, false); memoryManager = csrWithAubDump->createMemoryManager(false, false);
executionEnvironment.memoryManager.reset(memoryManager); executionEnvironment.memoryManager.reset(memoryManager);
ASSERT_NE(nullptr, memoryManager); ASSERT_NE(nullptr, memoryManager);
auto osContext = executionEnvironment.memoryManager->createAndRegisterOsContext(getChosenEngineType(DEFAULT_TEST_PLATFORM::hwInfo));
csrWithAubDump->setOsContext(osContext);
if (csrWithAubDump->aubCSR) {
csrWithAubDump->aubCSR->setOsContext(osContext);
}
} }
void TearDown() override { void TearDown() override {
@@ -134,12 +140,10 @@ HWTEST_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAub
LinearStream cs(commandBuffer); LinearStream cs(commandBuffer);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
auto engineType = OCLRT::ENGINE_RCS; auto engineType = csrWithAubDump->getOsContext().getEngineType().type;
OsContext osContext(nullptr, 0u);
ResidencyContainer allocationsForResidency; ResidencyContainer allocationsForResidency;
FlushStamp flushStamp = csrWithAubDump->flush(batchBuffer, engineType, allocationsForResidency, osContext); FlushStamp flushStamp = csrWithAubDump->flush(batchBuffer, allocationsForResidency);
EXPECT_EQ(flushStamp, csrWithAubDump->flushParametrization.flushStampToReturn); EXPECT_EQ(flushStamp, csrWithAubDump->flushParametrization.flushStampToReturn);
EXPECT_TRUE(csrWithAubDump->flushParametrization.wasCalled); EXPECT_TRUE(csrWithAubDump->flushParametrization.wasCalled);
@@ -179,14 +183,12 @@ HWTEST_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAub
ASSERT_NE(nullptr, commandBuffer); ASSERT_NE(nullptr, commandBuffer);
LinearStream cs(commandBuffer); LinearStream cs(commandBuffer);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
auto engineType = OCLRT::ENGINE_RCS;
auto gfxAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false); auto gfxAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
ASSERT_NE(nullptr, gfxAllocation); ASSERT_NE(nullptr, gfxAllocation);
ResidencyContainer allocationsForResidency = {gfxAllocation}; ResidencyContainer allocationsForResidency = {gfxAllocation};
OsContext osContext(nullptr, 0u);
FlushStamp flushStamp = csrWithAubDump->flush(batchBuffer, engineType, allocationsForResidency, osContext); FlushStamp flushStamp = csrWithAubDump->flush(batchBuffer, allocationsForResidency);
EXPECT_EQ(flushStamp, csrWithAubDump->flushParametrization.flushStampToReturn); EXPECT_EQ(flushStamp, csrWithAubDump->flushParametrization.flushStampToReturn);
EXPECT_TRUE(csrWithAubDump->processResidencyParameterization.wasCalled); EXPECT_TRUE(csrWithAubDump->processResidencyParameterization.wasCalled);

View File

@@ -92,7 +92,7 @@ TEST_F(TbxCommandStreamTests, DISABLED_flush) {
LinearStream cs(buffer, 4096); LinearStream cs(buffer, 4096);
size_t startOffset = 0; size_t startOffset = 0;
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), startOffset, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), startOffset, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
pCommandStreamReceiver->flush(batchBuffer, EngineType::ENGINE_RCS, pCommandStreamReceiver->getResidencyAllocations(), *pDevice->getOsContext()); pCommandStreamReceiver->flush(batchBuffer, pCommandStreamReceiver->getResidencyAllocations());
} }
HWTEST_F(TbxCommandStreamTests, DISABLED_flushUntilTailRCSLargerThanSizeRCS) { HWTEST_F(TbxCommandStreamTests, DISABLED_flushUntilTailRCSLargerThanSizeRCS) {
@@ -104,12 +104,12 @@ HWTEST_F(TbxCommandStreamTests, DISABLED_flushUntilTailRCSLargerThanSizeRCS) {
auto &engineInfo = tbxCsr->engineInfoTable[EngineType::ENGINE_RCS]; auto &engineInfo = tbxCsr->engineInfoTable[EngineType::ENGINE_RCS];
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), startOffset, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), startOffset, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
pCommandStreamReceiver->flush(batchBuffer, EngineType::ENGINE_RCS, pCommandStreamReceiver->getResidencyAllocations(), *pDevice->getOsContext()); pCommandStreamReceiver->flush(batchBuffer, pCommandStreamReceiver->getResidencyAllocations());
auto size = engineInfo.sizeRCS; auto size = engineInfo.sizeRCS;
engineInfo.sizeRCS = 64; engineInfo.sizeRCS = 64;
pCommandStreamReceiver->flush(batchBuffer, EngineType::ENGINE_RCS, pCommandStreamReceiver->getResidencyAllocations(), *pDevice->getOsContext()); pCommandStreamReceiver->flush(batchBuffer, pCommandStreamReceiver->getResidencyAllocations());
pCommandStreamReceiver->flush(batchBuffer, EngineType::ENGINE_RCS, pCommandStreamReceiver->getResidencyAllocations(), *pDevice->getOsContext()); pCommandStreamReceiver->flush(batchBuffer, pCommandStreamReceiver->getResidencyAllocations());
pCommandStreamReceiver->flush(batchBuffer, EngineType::ENGINE_RCS, pCommandStreamReceiver->getResidencyAllocations(), *pDevice->getOsContext()); pCommandStreamReceiver->flush(batchBuffer, pCommandStreamReceiver->getResidencyAllocations());
engineInfo.sizeRCS = size; engineInfo.sizeRCS = size;
} }
@@ -230,7 +230,7 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenProcessResidenc
EXPECT_FALSE(graphicsAllocation->isResident(0u)); EXPECT_FALSE(graphicsAllocation->isResident(0u));
ResidencyContainer allocationsForResidency = {graphicsAllocation}; ResidencyContainer allocationsForResidency = {graphicsAllocation};
tbxCsr->processResidency(allocationsForResidency, *pDevice->getOsContext()); tbxCsr->processResidency(allocationsForResidency);
EXPECT_TRUE(graphicsAllocation->isResident(0u)); EXPECT_TRUE(graphicsAllocation->isResident(0u));
EXPECT_EQ(tbxCsr->peekTaskCount() + 1, graphicsAllocation->getResidencyTaskCount(0u)); EXPECT_EQ(tbxCsr->peekTaskCount() + 1, graphicsAllocation->getResidencyTaskCount(0u));
@@ -249,7 +249,7 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenProcessResidenc
EXPECT_FALSE(graphicsAllocation->isResident(0u)); EXPECT_FALSE(graphicsAllocation->isResident(0u));
ResidencyContainer allocationsForResidency = {graphicsAllocation}; ResidencyContainer allocationsForResidency = {graphicsAllocation};
tbxCsr->processResidency(allocationsForResidency, *pDevice->getOsContext()); tbxCsr->processResidency(allocationsForResidency);
EXPECT_TRUE(graphicsAllocation->isResident(0u)); EXPECT_TRUE(graphicsAllocation->isResident(0u));
EXPECT_EQ(tbxCsr->peekTaskCount() + 1, graphicsAllocation->getResidencyTaskCount(0u)); EXPECT_EQ(tbxCsr->peekTaskCount() + 1, graphicsAllocation->getResidencyTaskCount(0u));
@@ -270,12 +270,12 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenFlushIsCalledTh
LinearStream cs(commandBuffer); LinearStream cs(commandBuffer);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
auto engineType = OCLRT::ENGINE_RCS;
ResidencyContainer allocationsForResidency = {graphicsAllocation}; ResidencyContainer allocationsForResidency = {graphicsAllocation};
EXPECT_FALSE(graphicsAllocation->isResident(0u)); EXPECT_FALSE(graphicsAllocation->isResident(0u));
tbxCsr->flush(batchBuffer, engineType, allocationsForResidency, *pDevice->getOsContext()); tbxCsr->flush(batchBuffer, allocationsForResidency);
EXPECT_TRUE(graphicsAllocation->isResident(0u)); EXPECT_TRUE(graphicsAllocation->isResident(0u));
EXPECT_EQ(tbxCsr->peekTaskCount() + 1, graphicsAllocation->getResidencyTaskCount(0u)); EXPECT_EQ(tbxCsr->peekTaskCount() + 1, graphicsAllocation->getResidencyTaskCount(0u));

View File

@@ -84,9 +84,10 @@ TEST_F(DeviceTest, retainAndRelease) {
TEST_F(DeviceTest, getEngineTypeDefault) { TEST_F(DeviceTest, getEngineTypeDefault) {
auto pTestDevice = std::unique_ptr<Device>(createWithUsDeviceId(0)); auto pTestDevice = std::unique_ptr<Device>(createWithUsDeviceId(0));
EngineType actualEngineType = pDevice->getEngineType(); EngineType actualEngineType = pDevice->getEngine(0).osContext->getEngineType().type;
EngineType defaultEngineType = pDevice->getHardwareInfo().capabilityTable.defaultEngineType; EngineType defaultEngineType = pDevice->getHardwareInfo().capabilityTable.defaultEngineType;
EXPECT_EQ(&pDevice->getEngine(0).commandStreamReceiver->getOsContext(), pDevice->getEngine(0).osContext);
EXPECT_EQ(defaultEngineType, actualEngineType); EXPECT_EQ(defaultEngineType, actualEngineType);
} }
@@ -96,7 +97,7 @@ TEST_F(DeviceTest, givenDebugVariableOverrideEngineTypeWhenDeviceIsCreatedThenUs
DebugManager.flags.NodeOrdinal.set(static_cast<int32_t>(expectedEngine)); DebugManager.flags.NodeOrdinal.set(static_cast<int32_t>(expectedEngine));
auto pTestDevice = std::unique_ptr<Device>(createWithUsDeviceId(0)); auto pTestDevice = std::unique_ptr<Device>(createWithUsDeviceId(0));
EngineType actualEngineType = pTestDevice->getEngineType(); EngineType actualEngineType = pTestDevice->getEngine(0).osContext->getEngineType().type;
EngineType defaultEngineType = pDevice->getHardwareInfo().capabilityTable.defaultEngineType; EngineType defaultEngineType = pDevice->getHardwareInfo().capabilityTable.defaultEngineType;
EXPECT_NE(defaultEngineType, actualEngineType); EXPECT_NE(defaultEngineType, actualEngineType);
@@ -166,12 +167,12 @@ TEST(DeviceCreation, givenDeviceWhenItIsCreatedThenOsContextIsRegistredInMemoryM
TEST(DeviceCreation, givenMultiDeviceWhenTheyAreCreatedThenEachOsContextHasUniqueId) { TEST(DeviceCreation, givenMultiDeviceWhenTheyAreCreatedThenEachOsContextHasUniqueId) {
ExecutionEnvironment executionEnvironment; ExecutionEnvironment executionEnvironment;
executionEnvironment.incRefInternal(); executionEnvironment.incRefInternal();
auto device = std::unique_ptr<Device>(Device::create<Device>(nullptr, &executionEnvironment, 0u)); auto device1 = std::unique_ptr<Device>(Device::create<Device>(nullptr, &executionEnvironment, 0u));
auto device2 = std::unique_ptr<Device>(Device::create<Device>(nullptr, &executionEnvironment, 1u)); auto device2 = std::unique_ptr<Device>(Device::create<Device>(nullptr, &executionEnvironment, 1u));
EXPECT_EQ(0u, device->getOsContext()->getContextId()); EXPECT_EQ(0u, device1->getEngine(0).osContext->getContextId());
EXPECT_EQ(1u, device2->getOsContext()->getContextId()); EXPECT_EQ(1u, device2->getEngine(0).osContext->getContextId());
EXPECT_EQ(2u, device->getMemoryManager()->getOsContextCount()); EXPECT_EQ(2u, executionEnvironment.memoryManager->getOsContextCount());
} }
TEST(DeviceCreation, givenMultiDeviceWhenTheyAreCreatedThenEachDeviceHasSeperateDeviceIndex) { TEST(DeviceCreation, givenMultiDeviceWhenTheyAreCreatedThenEachDeviceHasSeperateDeviceIndex) {

View File

@@ -54,6 +54,8 @@ struct UltCommandStreamReceiverTest
ssh.replaceBuffer(sshBuffer, sizeStream); ssh.replaceBuffer(sshBuffer, sizeStream);
graphicsAllocation = new MockGraphicsAllocation(sshBuffer, sizeStream); graphicsAllocation = new MockGraphicsAllocation(sshBuffer, sizeStream);
ssh.replaceGraphicsAllocation(graphicsAllocation); ssh.replaceGraphicsAllocation(graphicsAllocation);
pDevice->getCommandStreamReceiver().setOsContext(pDevice->getEngine(0).osContext);
} }
void TearDown() override { void TearDown() override {

View File

@@ -7,7 +7,6 @@
set(IGDRCL_SRCS_tests_gen10_linux set(IGDRCL_SRCS_tests_gen10_linux
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/device_factory_tests_gen10.cpp ${CMAKE_CURRENT_SOURCE_DIR}/device_factory_tests_gen10.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_mapper_tests_gen10.cpp
${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config_tests_gen10.cpp ${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config_tests_gen10.cpp
) )
if(UNIX) if(UNIX)

View File

@@ -1,35 +0,0 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "unit_tests/helpers/gtest_helpers.h"
#include "test.h"
#include "hw_cmds.h"
#include "runtime/os_interface/linux/drm_engine_mapper.h"
#include "drm/i915_drm.h"
using namespace OCLRT;
using namespace std;
struct DrmMapperTestsGen10 : public ::testing::Test {
void SetUp() override {}
void TearDown() override {}
};
GEN10TEST_F(DrmMapperTestsGen10, engineNodeMapPass) {
unsigned int flag = I915_EXEC_RING_MASK;
unsigned int expected = I915_EXEC_RENDER;
bool ret = DrmEngineMapper<CNLFamily>::engineNodeMap(EngineType::ENGINE_RCS, flag);
EXPECT_TRUE(ret);
EXPECT_EQ(expected, flag);
}
GEN10TEST_F(DrmMapperTestsGen10, engineNodeMapNegative) {
unsigned int flag = I915_EXEC_RING_MASK;
bool ret = DrmEngineMapper<CNLFamily>::engineNodeMap(EngineType::ENGINE_BCS, flag);
EXPECT_FALSE(ret);
}

View File

@@ -9,7 +9,6 @@ set(IGDRCL_SRCS_tests_gen10_windows
${CMAKE_CURRENT_SOURCE_DIR}/gmm_callbacks_tests_gen10.cpp ${CMAKE_CURRENT_SOURCE_DIR}/gmm_callbacks_tests_gen10.cpp
${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config_tests_gen10.cpp ${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config_tests_gen10.cpp
${CMAKE_CURRENT_SOURCE_DIR}/os_interface_tests_gen10.cpp ${CMAKE_CURRENT_SOURCE_DIR}/os_interface_tests_gen10.cpp
${CMAKE_CURRENT_SOURCE_DIR}/wddm_mapper_tests_gen10.cpp
) )
if(WIN32) if(WIN32)
target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_gen10_windows}) target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_gen10_windows})

View File

@@ -1,32 +0,0 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "unit_tests/helpers/gtest_helpers.h"
#include "test.h"
#include "hw_cmds.h"
#include "runtime/os_interface/windows/wddm_engine_mapper.h"
using namespace OCLRT;
using namespace std;
struct WddmMapperTestsGen10 : public ::testing::Test {
void SetUp() override {}
void TearDown() override {}
};
GEN10TEST_F(WddmMapperTestsGen10, engineNodeMapPass) {
GPUNODE_ORDINAL gpuNode = GPUNODE_MAX;
bool ret = WddmEngineMapper<CNLFamily>::engineNodeMap(EngineType::ENGINE_RCS, gpuNode);
EXPECT_TRUE(ret);
EXPECT_EQ(GPUNODE_3D, gpuNode);
}
GEN10TEST_F(WddmMapperTestsGen10, engineNodeMapNegative) {
GPUNODE_ORDINAL gpuNode = GPUNODE_MAX;
bool ret = WddmEngineMapper<CNLFamily>::engineNodeMap(EngineType::ENGINE_BCS, gpuNode);
EXPECT_FALSE(ret);
}

View File

@@ -1,12 +0,0 @@
#
# Copyright (C) 2018 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
set(IGDRCL_SRCS_tests_gen8_linux
${CMAKE_CURRENT_SOURCE_DIR}/drm_mapper_tests_gen8.cpp
)
if(UNIX)
target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_gen8_linux})
endif()

View File

@@ -1,34 +0,0 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "drm/i915_drm.h"
#include "runtime/os_interface/linux/drm_engine_mapper.h"
#include "unit_tests/helpers/gtest_helpers.h"
#include "test.h"
#include "hw_cmds.h"
using namespace OCLRT;
using namespace std;
struct DrmMapperTestsGen8 : public ::testing::Test {
void SetUp() override {}
void TearDown() override {}
};
GEN8TEST_F(DrmMapperTestsGen8, engineNodeMapPass) {
unsigned int flag = I915_EXEC_RING_MASK;
unsigned int expected = I915_EXEC_RENDER;
bool ret = DrmEngineMapper<BDWFamily>::engineNodeMap(EngineType::ENGINE_RCS, flag);
EXPECT_TRUE(ret);
EXPECT_EQ(expected, flag);
}
GEN8TEST_F(DrmMapperTestsGen8, engineNodeMapNegative) {
unsigned int flag = I915_EXEC_RING_MASK;
bool ret = DrmEngineMapper<BDWFamily>::engineNodeMap(EngineType::ENGINE_BCS, flag);
EXPECT_FALSE(ret);
}

View File

@@ -7,7 +7,6 @@
set(IGDRCL_SRCS_tests_gen8_windows set(IGDRCL_SRCS_tests_gen8_windows
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/gmm_callbacks_tests_gen8.cpp ${CMAKE_CURRENT_SOURCE_DIR}/gmm_callbacks_tests_gen8.cpp
${CMAKE_CURRENT_SOURCE_DIR}/wddm_mapper_tests_gen8.cpp
) )
if(WIN32) if(WIN32)
target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_gen8_windows}) target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_gen8_windows})

View File

@@ -1,32 +0,0 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "unit_tests/helpers/gtest_helpers.h"
#include "test.h"
#include "hw_cmds.h"
#include "runtime/os_interface/windows/wddm_engine_mapper.h"
using namespace OCLRT;
using namespace std;
struct WddmMapperTestsGen8 : public ::testing::Test {
void SetUp() override {}
void TearDown() override {}
};
GEN8TEST_F(WddmMapperTestsGen8, engineNodeMapPass) {
GPUNODE_ORDINAL gpuNode = GPUNODE_MAX;
bool ret = WddmEngineMapper<BDWFamily>::engineNodeMap(EngineType::ENGINE_RCS, gpuNode);
EXPECT_TRUE(ret);
EXPECT_EQ(GPUNODE_3D, gpuNode);
}
GEN8TEST_F(WddmMapperTestsGen8, engineNodeMapNegative) {
GPUNODE_ORDINAL gpuNode = GPUNODE_MAX;
bool ret = WddmEngineMapper<BDWFamily>::engineNodeMap(EngineType::ENGINE_BCS, gpuNode);
EXPECT_FALSE(ret);
}

View File

@@ -7,7 +7,6 @@
set(IGDRCL_SRCS_tests_gen9_linux set(IGDRCL_SRCS_tests_gen9_linux
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/device_factory_tests_gen9.cpp ${CMAKE_CURRENT_SOURCE_DIR}/device_factory_tests_gen9.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_mapper_tests_gen9.cpp
) )
if(UNIX) if(UNIX)
target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_gen9_linux}) target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_gen9_linux})

View File

@@ -1,34 +0,0 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "drm/i915_drm.h"
#include "runtime/os_interface/linux/drm_engine_mapper.h"
#include "unit_tests/helpers/gtest_helpers.h"
#include "test.h"
#include "hw_cmds.h"
using namespace OCLRT;
using namespace std;
struct DrmMapperTestsGen9 : public ::testing::Test {
void SetUp() override {}
void TearDown() override {}
};
GEN9TEST_F(DrmMapperTestsGen9, engineNodeMapPass) {
unsigned int flag = I915_EXEC_RING_MASK;
unsigned int expected = I915_EXEC_RENDER;
bool ret = DrmEngineMapper<SKLFamily>::engineNodeMap(EngineType::ENGINE_RCS, flag);
EXPECT_TRUE(ret);
EXPECT_EQ(expected, flag);
}
GEN9TEST_F(DrmMapperTestsGen9, engineNodeMapNegative) {
unsigned int flag = I915_EXEC_RING_MASK;
bool ret = DrmEngineMapper<SKLFamily>::engineNodeMap(EngineType::ENGINE_BCS, flag);
EXPECT_FALSE(ret);
}

View File

@@ -8,7 +8,6 @@ set(IGDRCL_SRCS_tests_gen9_windows
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/gmm_callbacks_tests_gen9.cpp ${CMAKE_CURRENT_SOURCE_DIR}/gmm_callbacks_tests_gen9.cpp
${CMAKE_CURRENT_SOURCE_DIR}/os_interface_tests_gen9.cpp ${CMAKE_CURRENT_SOURCE_DIR}/os_interface_tests_gen9.cpp
${CMAKE_CURRENT_SOURCE_DIR}/wddm_mapper_tests_gen9.cpp
) )
if(WIN32) if(WIN32)
target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_gen9_windows}) target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_gen9_windows})

View File

@@ -1,32 +0,0 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "unit_tests/helpers/gtest_helpers.h"
#include "test.h"
#include "hw_cmds.h"
#include "runtime/os_interface/windows/wddm_engine_mapper.h"
using namespace OCLRT;
using namespace std;
struct WddmMapperTestsGen9 : public ::testing::Test {
void SetUp() override {}
void TearDown() override {}
};
GEN9TEST_F(WddmMapperTestsGen9, engineNodeMapPass) {
GPUNODE_ORDINAL gpuNode = GPUNODE_MAX;
bool ret = WddmEngineMapper<SKLFamily>::engineNodeMap(EngineType::ENGINE_RCS, gpuNode);
EXPECT_TRUE(ret);
EXPECT_EQ(GPUNODE_3D, gpuNode);
}
GEN9TEST_F(WddmMapperTestsGen9, engineNodeMapNegative) {
GPUNODE_ORDINAL gpuNode = GPUNODE_MAX;
bool ret = WddmEngineMapper<SKLFamily>::engineNodeMap(EngineType::ENGINE_BCS, gpuNode);
EXPECT_FALSE(ret);
}

View File

@@ -27,7 +27,7 @@ struct KmdNotifyTests : public ::testing::Test {
device.reset(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&localHwInfo)); device.reset(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&localHwInfo));
cmdQ.reset(new MockCommandQueue(&context, device.get(), nullptr)); cmdQ.reset(new MockCommandQueue(&context, device.get(), nullptr));
*device->getTagAddress() = taskCountToWait; *device->getTagAddress() = taskCountToWait;
cmdQ->getCommandStreamReceiver().waitForFlushStamp(flushStampToWait, *device->getOsContext()); cmdQ->getCommandStreamReceiver().waitForFlushStamp(flushStampToWait);
overrideKmdNotifyParams(true, 2, true, 1, false, 0); overrideKmdNotifyParams(true, 2, true, 1, false, 0);
} }
@@ -72,7 +72,7 @@ struct KmdNotifyTests : public ::testing::Test {
class MockKmdNotifyCsr : public UltCommandStreamReceiver<Family> { class MockKmdNotifyCsr : public UltCommandStreamReceiver<Family> {
public: public:
MockKmdNotifyCsr(const HardwareInfo &hwInfo, const ExecutionEnvironment &executionEnvironment) : UltCommandStreamReceiver<Family>(hwInfo, const_cast<ExecutionEnvironment &>(executionEnvironment)) {} MockKmdNotifyCsr(const HardwareInfo &hwInfo, const ExecutionEnvironment &executionEnvironment) : UltCommandStreamReceiver<Family>(hwInfo, const_cast<ExecutionEnvironment &>(executionEnvironment)) {}
MOCK_METHOD2(waitForFlushStamp, bool(FlushStamp &flushStampToWait, OsContext &osContext)); MOCK_METHOD1(waitForFlushStamp, bool(FlushStamp &flushStampToWait));
MOCK_METHOD3(waitForCompletionWithTimeout, bool(bool enableTimeout, int64_t timeoutMs, uint32_t taskCountToWait)); MOCK_METHOD3(waitForCompletionWithTimeout, bool(bool enableTimeout, int64_t timeoutMs, uint32_t taskCountToWait));
}; };
@@ -109,7 +109,7 @@ HWTEST_F(KmdNotifyTests, givenTaskCountAndKmdNotifyDisabledWhenWaitUntilCompleti
auto csr = createMockCsr<FamilyType>(); auto csr = createMockCsr<FamilyType>();
EXPECT_CALL(*csr, waitForCompletionWithTimeout(false, 0, taskCountToWait)).Times(1).WillOnce(::testing::Return(true)); EXPECT_CALL(*csr, waitForCompletionWithTimeout(false, 0, taskCountToWait)).Times(1).WillOnce(::testing::Return(true));
EXPECT_CALL(*csr, waitForFlushStamp(::testing::_, ::testing::_)).Times(0); EXPECT_CALL(*csr, waitForFlushStamp(::testing::_)).Times(0);
cmdQ->waitUntilComplete(taskCountToWait, flushStampToWait, false); cmdQ->waitUntilComplete(taskCountToWait, flushStampToWait, false);
} }
@@ -120,7 +120,7 @@ HWTEST_F(KmdNotifyTests, givenNotReadyTaskCountWhenWaitUntilCompletionCalledThen
::testing::InSequence is; ::testing::InSequence is;
EXPECT_CALL(*csr, waitForCompletionWithTimeout(true, 2, taskCountToWait)).Times(1).WillOnce(::testing::Return(false)); EXPECT_CALL(*csr, waitForCompletionWithTimeout(true, 2, taskCountToWait)).Times(1).WillOnce(::testing::Return(false));
EXPECT_CALL(*csr, waitForFlushStamp(flushStampToWait, ::testing::_)).Times(1).WillOnce(::testing::Return(true)); EXPECT_CALL(*csr, waitForFlushStamp(flushStampToWait)).Times(1).WillOnce(::testing::Return(true));
EXPECT_CALL(*csr, waitForCompletionWithTimeout(false, 0, taskCountToWait)).Times(1).WillOnce(::testing::Return(false)); EXPECT_CALL(*csr, waitForCompletionWithTimeout(false, 0, taskCountToWait)).Times(1).WillOnce(::testing::Return(false));
//we have unrecoverable for this case, this will throw. //we have unrecoverable for this case, this will throw.
@@ -132,7 +132,7 @@ HWTEST_F(KmdNotifyTests, givenReadyTaskCountWhenWaitUntilCompletionCalledThenTry
::testing::InSequence is; ::testing::InSequence is;
EXPECT_CALL(*csr, waitForCompletionWithTimeout(true, 2, taskCountToWait)).Times(1).WillOnce(::testing::Return(true)); EXPECT_CALL(*csr, waitForCompletionWithTimeout(true, 2, taskCountToWait)).Times(1).WillOnce(::testing::Return(true));
EXPECT_CALL(*csr, waitForFlushStamp(::testing::_, ::testing::_)).Times(0); EXPECT_CALL(*csr, waitForFlushStamp(::testing::_)).Times(0);
cmdQ->waitUntilComplete(taskCountToWait, flushStampToWait, false); cmdQ->waitUntilComplete(taskCountToWait, flushStampToWait, false);
} }
@@ -176,9 +176,9 @@ HWTEST_F(KmdNotifyTests, givenZeroFlushStampWhenWaitIsCalledThenDisableTimeout)
EXPECT_TRUE(device->getHardwareInfo().capabilityTable.kmdNotifyProperties.enableKmdNotify); EXPECT_TRUE(device->getHardwareInfo().capabilityTable.kmdNotifyProperties.enableKmdNotify);
EXPECT_CALL(*csr, waitForCompletionWithTimeout(false, ::testing::_, taskCountToWait)).Times(1).WillOnce(::testing::Return(true)); EXPECT_CALL(*csr, waitForCompletionWithTimeout(false, ::testing::_, taskCountToWait)).Times(1).WillOnce(::testing::Return(true));
EXPECT_CALL(*csr, waitForFlushStamp(::testing::_, ::testing::_)).Times(0); EXPECT_CALL(*csr, waitForFlushStamp(::testing::_)).Times(0);
csr->waitForTaskCountWithKmdNotifyFallback(taskCountToWait, 0, false, *device->getOsContext(), false); csr->waitForTaskCountWithKmdNotifyFallback(taskCountToWait, 0, false, false);
} }
HWTEST_F(KmdNotifyTests, givenNonQuickSleepRequestWhenItsSporadicWaitThenOverrideQuickSleepRequest) { HWTEST_F(KmdNotifyTests, givenNonQuickSleepRequestWhenItsSporadicWaitThenOverrideQuickSleepRequest) {
@@ -191,7 +191,7 @@ HWTEST_F(KmdNotifyTests, givenNonQuickSleepRequestWhenItsSporadicWaitThenOverrid
int64_t timeSinceLastWait = mockKmdNotifyHelper->properties->delayQuickKmdSleepForSporadicWaitsMicroseconds + 1; int64_t timeSinceLastWait = mockKmdNotifyHelper->properties->delayQuickKmdSleepForSporadicWaitsMicroseconds + 1;
mockKmdNotifyHelper->lastWaitForCompletionTimestampUs = mockKmdNotifyHelper->getMicrosecondsSinceEpoch() - timeSinceLastWait; mockKmdNotifyHelper->lastWaitForCompletionTimestampUs = mockKmdNotifyHelper->getMicrosecondsSinceEpoch() - timeSinceLastWait;
csr->waitForTaskCountWithKmdNotifyFallback(taskCountToWait, 1, false, *device->getOsContext(), false); csr->waitForTaskCountWithKmdNotifyFallback(taskCountToWait, 1, false, false);
} }
HWTEST_F(KmdNotifyTests, givenNonQuickSleepRequestWhenItsNotSporadicWaitThenOverrideQuickSleepRequest) { HWTEST_F(KmdNotifyTests, givenNonQuickSleepRequestWhenItsNotSporadicWaitThenOverrideQuickSleepRequest) {
@@ -201,14 +201,14 @@ HWTEST_F(KmdNotifyTests, givenNonQuickSleepRequestWhenItsNotSporadicWaitThenOver
auto expectedDelay = device->getHardwareInfo().capabilityTable.kmdNotifyProperties.delayKmdNotifyMicroseconds; auto expectedDelay = device->getHardwareInfo().capabilityTable.kmdNotifyProperties.delayKmdNotifyMicroseconds;
EXPECT_CALL(*csr, waitForCompletionWithTimeout(::testing::_, expectedDelay, ::testing::_)).Times(1).WillOnce(::testing::Return(true)); EXPECT_CALL(*csr, waitForCompletionWithTimeout(::testing::_, expectedDelay, ::testing::_)).Times(1).WillOnce(::testing::Return(true));
csr->waitForTaskCountWithKmdNotifyFallback(taskCountToWait, 1, false, *device->getOsContext(), false); csr->waitForTaskCountWithKmdNotifyFallback(taskCountToWait, 1, false, false);
} }
HWTEST_F(KmdNotifyTests, givenKmdNotifyDisabledWhenPowerSavingModeIsRequestedThenTimeoutIsEnabled) { HWTEST_F(KmdNotifyTests, givenKmdNotifyDisabledWhenPowerSavingModeIsRequestedThenTimeoutIsEnabled) {
overrideKmdNotifyParams(false, 3, false, 2, false, 9999999); overrideKmdNotifyParams(false, 3, false, 2, false, 9999999);
auto csr = createMockCsr<FamilyType>(); auto csr = createMockCsr<FamilyType>();
EXPECT_CALL(*csr, waitForCompletionWithTimeout(true, 1, ::testing::_)).Times(1).WillOnce(::testing::Return(true)); EXPECT_CALL(*csr, waitForCompletionWithTimeout(true, 1, ::testing::_)).Times(1).WillOnce(::testing::Return(true));
csr->waitForTaskCountWithKmdNotifyFallback(taskCountToWait, 1, false, *device->getOsContext(), true); csr->waitForTaskCountWithKmdNotifyFallback(taskCountToWait, 1, false, true);
} }
HWTEST_F(KmdNotifyTests, givenKmdNotifyDisabledWhenQueueHasPowerSavingModeAndCallWaitThenTimeoutIsEnabled) { HWTEST_F(KmdNotifyTests, givenKmdNotifyDisabledWhenQueueHasPowerSavingModeAndCallWaitThenTimeoutIsEnabled) {
@@ -235,7 +235,7 @@ HWTEST_F(KmdNotifyTests, givenQuickSleepRequestWhenItsSporadicWaitOptimizationIs
auto expectedDelay = device->getHardwareInfo().capabilityTable.kmdNotifyProperties.delayQuickKmdSleepMicroseconds; auto expectedDelay = device->getHardwareInfo().capabilityTable.kmdNotifyProperties.delayQuickKmdSleepMicroseconds;
EXPECT_CALL(*csr, waitForCompletionWithTimeout(::testing::_, expectedDelay, ::testing::_)).Times(1).WillOnce(::testing::Return(true)); EXPECT_CALL(*csr, waitForCompletionWithTimeout(::testing::_, expectedDelay, ::testing::_)).Times(1).WillOnce(::testing::Return(true));
csr->waitForTaskCountWithKmdNotifyFallback(taskCountToWait, 1, true, *device->getOsContext(), false); csr->waitForTaskCountWithKmdNotifyFallback(taskCountToWait, 1, true, false);
} }
HWTEST_F(KmdNotifyTests, givenTaskCountEqualToHwTagWhenWaitCalledThenDontMultiplyTimeout) { HWTEST_F(KmdNotifyTests, givenTaskCountEqualToHwTagWhenWaitCalledThenDontMultiplyTimeout) {
@@ -246,7 +246,7 @@ HWTEST_F(KmdNotifyTests, givenTaskCountEqualToHwTagWhenWaitCalledThenDontMultipl
EXPECT_CALL(*csr, waitForCompletionWithTimeout(true, expectedTimeout, ::testing::_)).Times(1).WillOnce(::testing::Return(true)); EXPECT_CALL(*csr, waitForCompletionWithTimeout(true, expectedTimeout, ::testing::_)).Times(1).WillOnce(::testing::Return(true));
csr->waitForTaskCountWithKmdNotifyFallback(taskCountToWait, 1, false, *device->getOsContext(), false); csr->waitForTaskCountWithKmdNotifyFallback(taskCountToWait, 1, false, false);
} }
HWTEST_F(KmdNotifyTests, givenTaskCountLowerThanHwTagWhenWaitCalledThenDontMultiplyTimeout) { HWTEST_F(KmdNotifyTests, givenTaskCountLowerThanHwTagWhenWaitCalledThenDontMultiplyTimeout) {
@@ -257,7 +257,7 @@ HWTEST_F(KmdNotifyTests, givenTaskCountLowerThanHwTagWhenWaitCalledThenDontMulti
EXPECT_CALL(*csr, waitForCompletionWithTimeout(true, expectedTimeout, ::testing::_)).Times(1).WillOnce(::testing::Return(true)); EXPECT_CALL(*csr, waitForCompletionWithTimeout(true, expectedTimeout, ::testing::_)).Times(1).WillOnce(::testing::Return(true));
csr->waitForTaskCountWithKmdNotifyFallback(taskCountToWait, 1, false, *device->getOsContext(), false); csr->waitForTaskCountWithKmdNotifyFallback(taskCountToWait, 1, false, false);
} }
HWTEST_F(KmdNotifyTests, givenDefaultCommandStreamReceiverWhenWaitCalledThenUpdateWaitTimestamp) { HWTEST_F(KmdNotifyTests, givenDefaultCommandStreamReceiverWhenWaitCalledThenUpdateWaitTimestamp) {
@@ -267,7 +267,7 @@ HWTEST_F(KmdNotifyTests, givenDefaultCommandStreamReceiverWhenWaitCalledThenUpda
EXPECT_NE(0, mockKmdNotifyHelper->lastWaitForCompletionTimestampUs.load()); EXPECT_NE(0, mockKmdNotifyHelper->lastWaitForCompletionTimestampUs.load());
EXPECT_EQ(1u, mockKmdNotifyHelper->updateLastWaitForCompletionTimestampCalled); EXPECT_EQ(1u, mockKmdNotifyHelper->updateLastWaitForCompletionTimestampCalled);
csr->waitForTaskCountWithKmdNotifyFallback(0, 0, false, *device->getOsContext(), false); csr->waitForTaskCountWithKmdNotifyFallback(0, 0, false, false);
EXPECT_EQ(2u, mockKmdNotifyHelper->updateLastWaitForCompletionTimestampCalled); EXPECT_EQ(2u, mockKmdNotifyHelper->updateLastWaitForCompletionTimestampCalled);
} }
@@ -277,7 +277,7 @@ HWTEST_F(KmdNotifyTests, givenDefaultCommandStreamReceiverWithDisabledSporadicWa
auto csr = createMockCsr<FamilyType>(); auto csr = createMockCsr<FamilyType>();
EXPECT_EQ(0, mockKmdNotifyHelper->lastWaitForCompletionTimestampUs.load()); EXPECT_EQ(0, mockKmdNotifyHelper->lastWaitForCompletionTimestampUs.load());
csr->waitForTaskCountWithKmdNotifyFallback(0, 0, false, *device->getOsContext(), false); csr->waitForTaskCountWithKmdNotifyFallback(0, 0, false, false);
EXPECT_EQ(0u, mockKmdNotifyHelper->updateLastWaitForCompletionTimestampCalled); EXPECT_EQ(0u, mockKmdNotifyHelper->updateLastWaitForCompletionTimestampCalled);
} }

View File

@@ -194,7 +194,7 @@ HWTEST_F(KernelImageArgTest, givenImgWithMcsAllocWhenMakeResidentThenMakeMcsAllo
pKernel->makeResident(*csr.get()); pKernel->makeResident(*csr.get());
EXPECT_TRUE(csr->isMadeResident(mcsAlloc)); EXPECT_TRUE(csr->isMadeResident(mcsAlloc));
csr->makeSurfacePackNonResident(csr->getResidencyAllocations(), *pDevice->getOsContext()); csr->makeSurfacePackNonResident(csr->getResidencyAllocations());
EXPECT_TRUE(csr->isMadeNonResident(mcsAlloc)); EXPECT_TRUE(csr->isMadeNonResident(mcsAlloc));

View File

@@ -480,14 +480,14 @@ class CommandStreamReceiverMock : public CommandStreamReceiver {
CommandStreamReceiver::makeNonResident(graphicsAllocation); CommandStreamReceiver::makeNonResident(graphicsAllocation);
} }
FlushStamp flush(BatchBuffer &batchBuffer, EngineType engineType, ResidencyContainer &allocationsForResidency, OsContext &osContext) override { FlushStamp flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) override {
return flushStamp->peekStamp(); return flushStamp->peekStamp();
} }
void addPipeControl(LinearStream &commandStream, bool dcFlush) override { void addPipeControl(LinearStream &commandStream, bool dcFlush) override {
} }
void waitForTaskCountWithKmdNotifyFallback(uint32_t taskCountToWait, FlushStamp flushStampToWait, bool quickKmdSleep, OsContext &osContext, bool forcePowerSavingMode) override { void waitForTaskCountWithKmdNotifyFallback(uint32_t taskCountToWait, FlushStamp flushStampToWait, bool quickKmdSleep, bool forcePowerSavingMode) override {
} }
CompletionStamp flushTask( CompletionStamp flushTask(
@@ -553,7 +553,7 @@ TEST_F(KernelPrivateSurfaceTest, testPrivateSurface) {
pKernel->makeResident(*csr.get()); pKernel->makeResident(*csr.get());
EXPECT_EQ(1u, csr->residency.size()); EXPECT_EQ(1u, csr->residency.size());
csr->makeSurfacePackNonResident(csr->getResidencyAllocations(), *pDevice->getOsContext()); csr->makeSurfacePackNonResident(csr->getResidencyAllocations());
EXPECT_EQ(0u, csr->residency.size()); EXPECT_EQ(0u, csr->residency.size());
delete pKernel; delete pKernel;

View File

@@ -197,7 +197,7 @@ TEST_F(MemoryAllocatorTest, allocateSystemAligned) {
TEST_F(MemoryAllocatorTest, allocateGraphics) { TEST_F(MemoryAllocatorTest, allocateGraphics) {
unsigned int alignment = 4096; unsigned int alignment = 4096;
memoryManager->createAndRegisterOsContext(); memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0]);
auto allocation = memoryManager->allocateGraphicsMemory(sizeof(char)); auto allocation = memoryManager->allocateGraphicsMemory(sizeof(char));
ASSERT_NE(nullptr, allocation); ASSERT_NE(nullptr, allocation);
@@ -1226,7 +1226,7 @@ TEST_F(MemoryManagerWithCsrTest, givenAllocationThatWasUsedAndIsCompletedWhenche
} }
TEST_F(MemoryManagerWithCsrTest, givenAllocationThatWasUsedAndIsNotCompletedWhencheckGpuUsageAndDestroyGraphicsAllocationsIsCalledThenItIsAddedToTemporaryAllocationList) { TEST_F(MemoryManagerWithCsrTest, givenAllocationThatWasUsedAndIsNotCompletedWhencheckGpuUsageAndDestroyGraphicsAllocationsIsCalledThenItIsAddedToTemporaryAllocationList) {
memoryManager->createAndRegisterOsContext(); memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0]);
auto usedAllocationAndNotGpuCompleted = memoryManager->allocateGraphicsMemory(4096); auto usedAllocationAndNotGpuCompleted = memoryManager->allocateGraphicsMemory(4096);
auto tagAddress = csr->getTagAddress(); auto tagAddress = csr->getTagAddress();
@@ -1398,7 +1398,7 @@ TEST(GraphicsAllocation, givenSharedHandleBasedConstructorWhenGraphicsAllocation
TEST(ResidencyDataTest, givenOsContextWhenItIsRegisteredToMemoryManagerThenRefCountIncreases) { TEST(ResidencyDataTest, givenOsContextWhenItIsRegisteredToMemoryManagerThenRefCountIncreases) {
ExecutionEnvironment executionEnvironment; ExecutionEnvironment executionEnvironment;
MockMemoryManager memoryManager(false, false, executionEnvironment); MockMemoryManager memoryManager(false, false, executionEnvironment);
memoryManager.createAndRegisterOsContext(); memoryManager.createAndRegisterOsContext(gpgpuEngineInstances[0]);
EXPECT_EQ(1u, memoryManager.getOsContextCount()); EXPECT_EQ(1u, memoryManager.getOsContextCount());
EXPECT_EQ(1, memoryManager.registeredOsContexts[0]->getRefInternalCount()); EXPECT_EQ(1, memoryManager.registeredOsContexts[0]->getRefInternalCount());
} }
@@ -1406,8 +1406,8 @@ TEST(ResidencyDataTest, givenOsContextWhenItIsRegisteredToMemoryManagerThenRefCo
TEST(ResidencyDataTest, givenTwoOsContextsWhenTheyAreRegistredFromHigherToLowerThenProperSizeIsReturned) { TEST(ResidencyDataTest, givenTwoOsContextsWhenTheyAreRegistredFromHigherToLowerThenProperSizeIsReturned) {
ExecutionEnvironment executionEnvironment; ExecutionEnvironment executionEnvironment;
MockMemoryManager memoryManager(false, false, executionEnvironment); MockMemoryManager memoryManager(false, false, executionEnvironment);
memoryManager.createAndRegisterOsContext(); memoryManager.createAndRegisterOsContext(gpgpuEngineInstances[0]);
memoryManager.createAndRegisterOsContext(); memoryManager.createAndRegisterOsContext(gpgpuEngineInstances[1]);
EXPECT_EQ(2u, memoryManager.getOsContextCount()); EXPECT_EQ(2u, memoryManager.getOsContextCount());
EXPECT_EQ(1, memoryManager.registeredOsContexts[0]->getRefInternalCount()); EXPECT_EQ(1, memoryManager.registeredOsContexts[0]->getRefInternalCount());
EXPECT_EQ(1, memoryManager.registeredOsContexts[1]->getRefInternalCount()); EXPECT_EQ(1, memoryManager.registeredOsContexts[1]->getRefInternalCount());
@@ -1420,8 +1420,8 @@ TEST(ResidencyDataTest, givenResidencyDataWhenUpdateCompletionDataIsCalledThenIt
MockResidencyData residency; MockResidencyData residency;
OsContext osContext(nullptr, 0u); OsContext osContext(nullptr, 0u, gpgpuEngineInstances[0]);
OsContext osContext2(nullptr, 1u); OsContext osContext2(nullptr, 1u, gpgpuEngineInstances[1]);
auto lastFenceValue = 45llu; auto lastFenceValue = 45llu;
auto lastFenceValue2 = 23llu; auto lastFenceValue2 = 23llu;

View File

@@ -135,6 +135,9 @@ std::unique_ptr<AubExecutionEnvironment> getEnvironment(bool createTagAllocation
executionEnvironment->commandStreamReceivers[0][0]->initializeTagAllocation(); executionEnvironment->commandStreamReceivers[0][0]->initializeTagAllocation();
} }
auto osContext = executionEnvironment->memoryManager->createAndRegisterOsContext(getChosenEngineType(*platformDevices[0]));
executionEnvironment->commandStreamReceivers[0][0]->setOsContext(osContext);
std::unique_ptr<AubExecutionEnvironment> aubExecutionEnvironment(new AubExecutionEnvironment); std::unique_ptr<AubExecutionEnvironment> aubExecutionEnvironment(new AubExecutionEnvironment);
if (allocateCommandBuffer) { if (allocateCommandBuffer) {
aubExecutionEnvironment->commandBuffer = executionEnvironment->memoryManager->allocateGraphicsMemory(4096); aubExecutionEnvironment->commandBuffer = executionEnvironment->memoryManager->allocateGraphicsMemory(4096);

View File

@@ -8,7 +8,7 @@
#include "unit_tests/mocks/mock_csr.h" #include "unit_tests/mocks/mock_csr.h"
#include "runtime/os_interface/os_interface.h" #include "runtime/os_interface/os_interface.h"
FlushStamp MockCommandStreamReceiver::flush(BatchBuffer &batchBuffer, EngineType engineType, ResidencyContainer &allocationsForResidency, OsContext &osContext) { FlushStamp MockCommandStreamReceiver::flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) {
FlushStamp stamp = 0; FlushStamp stamp = 0;
return stamp; return stamp;
} }
@@ -23,7 +23,7 @@ CompletionStamp MockCommandStreamReceiver::flushTask(
DispatchFlags &dispatchFlags, DispatchFlags &dispatchFlags,
Device &device) { Device &device) {
++taskCount; ++taskCount;
CompletionStamp stamp = {taskCount, taskLevel, flushStamp->peekStamp(), 0, EngineType::ENGINE_RCS}; CompletionStamp stamp = {taskCount, taskLevel, flushStamp->peekStamp()};
return stamp; return stamp;
} }

View File

@@ -72,7 +72,7 @@ class MockCsrBase : public UltCommandStreamReceiver<GfxFamily> {
return this->GSBAFor32BitProgrammed; return this->GSBAFor32BitProgrammed;
} }
void processEviction(OsContext &osContext) override { void processEviction() override {
processEvictionCalled = true; processEvictionCalled = true;
} }
@@ -103,7 +103,7 @@ class MockCsr : public MockCsrBase<GfxFamily> {
MockCsr(int32_t &execStamp, ExecutionEnvironment &executionEnvironment) : BaseClass(execStamp, executionEnvironment) { MockCsr(int32_t &execStamp, ExecutionEnvironment &executionEnvironment) : BaseClass(execStamp, executionEnvironment) {
} }
FlushStamp flush(BatchBuffer &batchBuffer, EngineType engineType, ResidencyContainer &allocationsForResidency, OsContext &osContext) override { FlushStamp flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) override {
return 0; return 0;
} }
@@ -170,8 +170,7 @@ class MockCsrHw2 : public CommandStreamReceiverHw<GfxFamily> {
bool peekMediaVfeStateDirty() const { return mediaVfeStateDirty; } bool peekMediaVfeStateDirty() const { return mediaVfeStateDirty; }
FlushStamp flush(BatchBuffer &batchBuffer, EngineType engineType, FlushStamp flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) override {
ResidencyContainer &allocationsForResidency, OsContext &osContext) override {
flushCalledCount++; flushCalledCount++;
recordedCommandBuffer->batchBuffer = batchBuffer; recordedCommandBuffer->batchBuffer = batchBuffer;
copyOfAllocations = allocationsForResidency; copyOfAllocations = allocationsForResidency;
@@ -219,7 +218,7 @@ class MockCommandStreamReceiver : public CommandStreamReceiver {
~MockCommandStreamReceiver() { ~MockCommandStreamReceiver() {
} }
FlushStamp flush(BatchBuffer &batchBuffer, EngineType engineType, ResidencyContainer &allocationsForResidency, OsContext &osContext) override; FlushStamp flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) override;
CompletionStamp flushTask( CompletionStamp flushTask(
LinearStream &commandStream, LinearStream &commandStream,
@@ -237,7 +236,7 @@ class MockCommandStreamReceiver : public CommandStreamReceiver {
} }
} }
void waitForTaskCountWithKmdNotifyFallback(uint32_t taskCountToWait, FlushStamp flushStampToWait, bool quickKmdSleep, OsContext &osContext, bool forcePowerSavingMode) override { void waitForTaskCountWithKmdNotifyFallback(uint32_t taskCountToWait, FlushStamp flushStampToWait, bool quickKmdSleep, bool forcePowerSavingMode) override {
} }
void addPipeControl(LinearStream &commandStream, bool dcFlush) override { void addPipeControl(LinearStream &commandStream, bool dcFlush) override {

View File

@@ -50,6 +50,7 @@ void MockDevice::resetCommandStreamReceiver(CommandStreamReceiver *newCsr) {
executionEnvironment->commandStreamReceivers[getDeviceIndex()][0]->initializeTagAllocation(); executionEnvironment->commandStreamReceivers[getDeviceIndex()][0]->initializeTagAllocation();
executionEnvironment->commandStreamReceivers[getDeviceIndex()][0]->setPreemptionCsrAllocation(preemptionAllocation); executionEnvironment->commandStreamReceivers[getDeviceIndex()][0]->setPreemptionCsrAllocation(preemptionAllocation);
this->engines[0].commandStreamReceiver = newCsr; this->engines[0].commandStreamReceiver = newCsr;
this->engines[0].commandStreamReceiver->setOsContext(this->engines[0].osContext);
UNRECOVERABLE_IF(getDeviceIndex() != 0u); UNRECOVERABLE_IF(getDeviceIndex() != 0u);
this->tagAddress = executionEnvironment->commandStreamReceivers[getDeviceIndex()][0]->getTagAddress(); this->tagAddress = executionEnvironment->commandStreamReceivers[getDeviceIndex()][0]->getTagAddress();
} }

View File

@@ -103,9 +103,9 @@ bool WddmMock::openSharedHandle(D3DKMT_HANDLE handle, WddmAllocation *alloc) {
} }
} }
bool WddmMock::createContext(D3DKMT_HANDLE &context) { bool WddmMock::createContext(D3DKMT_HANDLE &context, EngineInstanceT engineType) {
createContextResult.called++; createContextResult.called++;
return createContextResult.success = Wddm::createContext(context); return createContextResult.success = Wddm::createContext(context, engineType);
} }
void WddmMock::applyAdditionalContextFlags(CREATECONTEXT_PVTDATA &privateData) { void WddmMock::applyAdditionalContextFlags(CREATECONTEXT_PVTDATA &privateData) {

View File

@@ -58,7 +58,7 @@ class WddmMock : public Wddm {
bool destroyAllocations(D3DKMT_HANDLE *handles, uint32_t allocationCount, D3DKMT_HANDLE resourceHandle) override; bool destroyAllocations(D3DKMT_HANDLE *handles, uint32_t allocationCount, D3DKMT_HANDLE resourceHandle) override;
bool destroyAllocation(WddmAllocation *alloc, OsContextWin *osContext); bool destroyAllocation(WddmAllocation *alloc, OsContextWin *osContext);
bool openSharedHandle(D3DKMT_HANDLE handle, WddmAllocation *alloc) override; bool openSharedHandle(D3DKMT_HANDLE handle, WddmAllocation *alloc) override;
bool createContext(D3DKMT_HANDLE &context) override; bool createContext(D3DKMT_HANDLE &context, EngineInstanceT engineType) override;
void applyAdditionalContextFlags(CREATECONTEXT_PVTDATA &privateData) override; void applyAdditionalContextFlags(CREATECONTEXT_PVTDATA &privateData) override;
bool destroyContext(D3DKMT_HANDLE context) override; bool destroyContext(D3DKMT_HANDLE context) override;
bool queryAdapterInfo() override; bool queryAdapterInfo() override;

View File

@@ -17,6 +17,7 @@ set(IGDRCL_SRCS_tests_os_interface_linux
${CMAKE_CURRENT_SOURCE_DIR}/drm_command_stream_mm_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/drm_command_stream_mm_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_command_stream_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/drm_command_stream_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_gem_close_worker_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/drm_gem_close_worker_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/drm_mapper_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_manager_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_manager_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_mock.h ${CMAKE_CURRENT_SOURCE_DIR}/drm_mock.h
${CMAKE_CURRENT_SOURCE_DIR}/drm_neo_create.cpp ${CMAKE_CURRENT_SOURCE_DIR}/drm_neo_create.cpp

View File

@@ -12,6 +12,7 @@
#include "runtime/os_interface/os_context.h" #include "runtime/os_interface/os_context.h"
#include "runtime/os_interface/linux/drm_buffer_object.h" #include "runtime/os_interface/linux/drm_buffer_object.h"
#include "runtime/os_interface/linux/drm_command_stream.h" #include "runtime/os_interface/linux/drm_command_stream.h"
#include "runtime/os_interface/linux/os_context_linux.h"
#include "runtime/os_interface/linux/os_interface.h" #include "runtime/os_interface/linux/os_interface.h"
#include "unit_tests/fixtures/device_fixture.h" #include "unit_tests/fixtures/device_fixture.h"
#include "unit_tests/helpers/debug_manager_state_restore.h" #include "unit_tests/helpers/debug_manager_state_restore.h"
@@ -31,7 +32,7 @@ using namespace OCLRT;
class DrmCommandStreamFixture { class DrmCommandStreamFixture {
public: public:
void SetUp() { void SetUp() {
osContext = std::make_unique<OsContext>(nullptr, 0u);
//make sure this is disabled, we don't want test this now //make sure this is disabled, we don't want test this now
DebugManager.flags.EnableForcePin.set(false); DebugManager.flags.EnableForcePin.set(false);
@@ -40,11 +41,14 @@ class DrmCommandStreamFixture {
executionEnvironment.osInterface = std::make_unique<OSInterface>(); executionEnvironment.osInterface = std::make_unique<OSInterface>();
executionEnvironment.osInterface->get()->setDrm(mock.get()); executionEnvironment.osInterface->get()->setDrm(mock.get());
osContext = std::make_unique<OsContext>(executionEnvironment.osInterface.get(), 0u, gpgpuEngineInstances[0]);
csr = new DrmCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME>(*platformDevices[0], executionEnvironment, csr = new DrmCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME>(*platformDevices[0], executionEnvironment,
gemCloseWorkerMode::gemCloseWorkerActive); gemCloseWorkerMode::gemCloseWorkerActive);
ASSERT_NE(nullptr, csr); ASSERT_NE(nullptr, csr);
executionEnvironment.commandStreamReceivers.resize(1); executionEnvironment.commandStreamReceivers.resize(1);
executionEnvironment.commandStreamReceivers[0][0].reset(csr); executionEnvironment.commandStreamReceivers[0][0].reset(csr);
csr->setOsContext(osContext.get());
// Memory manager creates pinBB with ioctl, expect one call // Memory manager creates pinBB with ioctl, expect one call
EXPECT_CALL(*mock, ioctl(::testing::_, ::testing::_)) EXPECT_CALL(*mock, ioctl(::testing::_, ::testing::_))
@@ -94,7 +98,7 @@ TEST_F(DrmCommandStreamTest, givenFlushStampWhenWaitCalledThenWaitForSpecifiedBo
.Times(1) .Times(1)
.WillRepeatedly(copyIoctlParam(&calledWait)); .WillRepeatedly(copyIoctlParam(&calledWait));
csr->waitForFlushStamp(handleToWait, *osContext); csr->waitForFlushStamp(handleToWait);
EXPECT_TRUE(memcmp(&expectedWait, &calledWait, sizeof(drm_i915_gem_wait)) == 0); EXPECT_TRUE(memcmp(&expectedWait, &calledWait, sizeof(drm_i915_gem_wait)) == 0);
} }
@@ -201,7 +205,7 @@ TEST_F(DrmCommandStreamTest, Flush) {
csr->alignToCacheLine(cs); csr->alignToCacheLine(cs);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
auto availableSpacePriorToFlush = cs.getAvailableSpace(); auto availableSpacePriorToFlush = cs.getAvailableSpace();
auto flushStamp = csr->flush(batchBuffer, EngineType::ENGINE_RCS, csr->getResidencyAllocations(), *osContext); auto flushStamp = csr->flush(batchBuffer, csr->getResidencyAllocations());
EXPECT_EQ(static_cast<uint64_t>(boHandle), flushStamp); EXPECT_EQ(static_cast<uint64_t>(boHandle), flushStamp);
EXPECT_NE(cs.getCpuBase(), nullptr); EXPECT_NE(cs.getCpuBase(), nullptr);
EXPECT_EQ(availableSpacePriorToFlush, cs.getAvailableSpace()); EXPECT_EQ(availableSpacePriorToFlush, cs.getAvailableSpace());
@@ -236,7 +240,7 @@ TEST_F(DrmCommandStreamTest, FlushWithLowPriorityContext) {
csr->addBatchBufferEnd(cs, nullptr); csr->addBatchBufferEnd(cs, nullptr);
csr->alignToCacheLine(cs); csr->alignToCacheLine(cs);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, true, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, true, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, csr->getResidencyAllocations(), *osContext); csr->flush(batchBuffer, csr->getResidencyAllocations());
EXPECT_NE(cs.getCpuBase(), nullptr); EXPECT_NE(cs.getCpuBase(), nullptr);
} }
@@ -265,7 +269,7 @@ TEST_F(DrmCommandStreamTest, FlushInvalidAddress) {
csr->addBatchBufferEnd(cs, nullptr); csr->addBatchBufferEnd(cs, nullptr);
csr->alignToCacheLine(cs); csr->alignToCacheLine(cs);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, csr->getResidencyAllocations(), *osContext); csr->flush(batchBuffer, csr->getResidencyAllocations());
delete[] commandBuffer; delete[] commandBuffer;
} }
@@ -296,7 +300,7 @@ TEST_F(DrmCommandStreamTest, FlushNotEmptyBB) {
csr->addBatchBufferEnd(cs, nullptr); csr->addBatchBufferEnd(cs, nullptr);
csr->alignToCacheLine(cs); csr->alignToCacheLine(cs);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, csr->getResidencyAllocations(), *osContext); csr->flush(batchBuffer, csr->getResidencyAllocations());
} }
TEST_F(DrmCommandStreamTest, FlushNotEmptyNotPaddedBB) { TEST_F(DrmCommandStreamTest, FlushNotEmptyNotPaddedBB) {
@@ -325,7 +329,7 @@ TEST_F(DrmCommandStreamTest, FlushNotEmptyNotPaddedBB) {
csr->addBatchBufferEnd(cs, nullptr); csr->addBatchBufferEnd(cs, nullptr);
csr->alignToCacheLine(cs); csr->alignToCacheLine(cs);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, csr->getResidencyAllocations(), *osContext); csr->flush(batchBuffer, csr->getResidencyAllocations());
} }
TEST_F(DrmCommandStreamTest, FlushNotAligned) { TEST_F(DrmCommandStreamTest, FlushNotAligned) {
@@ -356,7 +360,7 @@ TEST_F(DrmCommandStreamTest, FlushNotAligned) {
csr->alignToCacheLine(cs); csr->alignToCacheLine(cs);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 4, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 4, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, csr->getResidencyAllocations(), *osContext); csr->flush(batchBuffer, csr->getResidencyAllocations());
} }
ACTION_P(UserptrSetHandle, _set_handle) { ACTION_P(UserptrSetHandle, _set_handle) {
@@ -408,7 +412,7 @@ TEST_F(DrmCommandStreamTest, FlushCheckFlags) {
csr->addBatchBufferEnd(cs, nullptr); csr->addBatchBufferEnd(cs, nullptr);
csr->alignToCacheLine(cs); csr->alignToCacheLine(cs);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, csr->getResidencyAllocations(), *osContext); csr->flush(batchBuffer, csr->getResidencyAllocations());
} }
TEST_F(DrmCommandStreamTest, CheckDrmFree) { TEST_F(DrmCommandStreamTest, CheckDrmFree) {
@@ -441,7 +445,7 @@ TEST_F(DrmCommandStreamTest, CheckDrmFree) {
csr->addBatchBufferEnd(cs, nullptr); csr->addBatchBufferEnd(cs, nullptr);
csr->alignToCacheLine(cs); csr->alignToCacheLine(cs);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 4, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 4, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, csr->getResidencyAllocations(), *osContext); csr->flush(batchBuffer, csr->getResidencyAllocations());
} }
TEST_F(DrmCommandStreamTest, GIVENCSRWHENgetDMTHENNotNull) { TEST_F(DrmCommandStreamTest, GIVENCSRWHENgetDMTHENNotNull) {
@@ -482,7 +486,7 @@ TEST_F(DrmCommandStreamTest, CheckDrmFreeCloseFailed) {
csr->addBatchBufferEnd(cs, nullptr); csr->addBatchBufferEnd(cs, nullptr);
csr->alignToCacheLine(cs); csr->alignToCacheLine(cs);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 4, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 4, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, csr->getResidencyAllocations(), *osContext); csr->flush(batchBuffer, csr->getResidencyAllocations());
} }
struct DrmCsrVfeTests : ::testing::Test { struct DrmCsrVfeTests : ::testing::Test {
@@ -495,7 +499,7 @@ struct DrmCsrVfeTests : ::testing::Test {
MyCsr(ExecutionEnvironment &executionEnvironment) MyCsr(ExecutionEnvironment &executionEnvironment)
: DrmCommandStreamReceiver<FamilyType>(*platformDevices[0], executionEnvironment, : DrmCommandStreamReceiver<FamilyType>(*platformDevices[0], executionEnvironment,
gemCloseWorkerMode::gemCloseWorkerInactive) {} gemCloseWorkerMode::gemCloseWorkerInactive) {}
FlushStamp flush(BatchBuffer &batchBuffer, EngineType engineType, ResidencyContainer &allocationsForResidency, OsContext &osContext) override { FlushStamp flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) override {
return (FlushStamp)0; return (FlushStamp)0;
} }
bool peekDefaultMediaVfeStateDirty() { bool peekDefaultMediaVfeStateDirty() {
@@ -655,9 +659,9 @@ class DrmCommandStreamEnhancedFixture
DeviceCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME> *csr = nullptr; DeviceCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME> *csr = nullptr;
DrmMemoryManager *mm = nullptr; DrmMemoryManager *mm = nullptr;
MockDevice *device = nullptr; MockDevice *device = nullptr;
OsContext *osContext;
DebugManagerStateRestore *dbgState; DebugManagerStateRestore *dbgState;
ExecutionEnvironment *executionEnvironment; ExecutionEnvironment *executionEnvironment;
std::unique_ptr<OsContext> osContext;
void SetUp() { void SetUp() {
executionEnvironment = new ExecutionEnvironment; executionEnvironment = new ExecutionEnvironment;
@@ -669,16 +673,17 @@ class DrmCommandStreamEnhancedFixture
mock = new DrmMockCustom(); mock = new DrmMockCustom();
executionEnvironment->osInterface = std::make_unique<OSInterface>(); executionEnvironment->osInterface = std::make_unique<OSInterface>();
executionEnvironment->osInterface->get()->setDrm(mock); executionEnvironment->osInterface->get()->setDrm(mock);
osContext = std::make_unique<OsContext>(executionEnvironment->osInterface.get(), 0u, gpgpuEngineInstances[0]);
tCsr = new TestedDrmCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME>(*executionEnvironment); tCsr = new TestedDrmCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME>(*executionEnvironment);
csr = tCsr; csr = tCsr;
csr->setOsContext(osContext.get());
ASSERT_NE(nullptr, csr); ASSERT_NE(nullptr, csr);
mm = reinterpret_cast<DrmMemoryManager *>(csr->createMemoryManager(false, false)); mm = reinterpret_cast<DrmMemoryManager *>(csr->createMemoryManager(false, false));
ASSERT_NE(nullptr, mm); ASSERT_NE(nullptr, mm);
executionEnvironment->memoryManager.reset(mm); executionEnvironment->memoryManager.reset(mm);
device = Device::create<MockDevice>(platformDevices[0], executionEnvironment, 0u); device = Device::create<MockDevice>(platformDevices[0], executionEnvironment, 0u);
ASSERT_NE(nullptr, device); ASSERT_NE(nullptr, device);
osContext = device->getOsContext();
} }
void TearDown() { void TearDown() {
@@ -731,7 +736,7 @@ TEST_F(DrmCommandStreamGemWorkerTests, givenCommandStreamWhenItIsFlushedWithGemC
auto storedBase = cs.getCpuBase(); auto storedBase = cs.getCpuBase();
auto storedGraphicsAllocation = cs.getGraphicsAllocation(); auto storedGraphicsAllocation = cs.getGraphicsAllocation();
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, csr->getResidencyAllocations(), *osContext); csr->flush(batchBuffer, csr->getResidencyAllocations());
EXPECT_EQ(cs.getCpuBase(), storedBase); EXPECT_EQ(cs.getCpuBase(), storedBase);
EXPECT_EQ(cs.getGraphicsAllocation(), storedGraphicsAllocation); EXPECT_EQ(cs.getGraphicsAllocation(), storedGraphicsAllocation);
@@ -766,7 +771,7 @@ TEST_F(DrmCommandStreamGemWorkerTests, givenTaskThatRequiresLargeResourceCountWh
csr->addBatchBufferEnd(cs, nullptr); csr->addBatchBufferEnd(cs, nullptr);
csr->alignToCacheLine(cs); csr->alignToCacheLine(cs);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, csr->getResidencyAllocations(), *osContext); csr->flush(batchBuffer, csr->getResidencyAllocations());
EXPECT_EQ(11u, this->mock->execBuffer.buffer_count); EXPECT_EQ(11u, this->mock->execBuffer.buffer_count);
mm->freeGraphicsMemory(commandBuffer); mm->freeGraphicsMemory(commandBuffer);
@@ -785,7 +790,7 @@ TEST_F(DrmCommandStreamGemWorkerTests, givenGemCloseWorkerInactiveModeWhenMakeRe
csr->makeResident(*dummyAllocation); csr->makeResident(*dummyAllocation);
EXPECT_EQ(1u, bo->getRefCount()); EXPECT_EQ(1u, bo->getRefCount());
csr->processResidency(csr->getResidencyAllocations(), *osContext); csr->processResidency(csr->getResidencyAllocations());
csr->makeNonResident(*dummyAllocation); csr->makeNonResident(*dummyAllocation);
EXPECT_EQ(1u, bo->getRefCount()); EXPECT_EQ(1u, bo->getRefCount());
@@ -803,7 +808,7 @@ TEST_F(DrmCommandStreamGemWorkerTests, GivenTwoAllocationsWhenBackingStorageIsDi
EXPECT_TRUE(allocation->isResident(0u)); EXPECT_TRUE(allocation->isResident(0u));
EXPECT_TRUE(allocation2->isResident(0u)); EXPECT_TRUE(allocation2->isResident(0u));
csr->processResidency(csr->getResidencyAllocations(), *osContext); csr->processResidency(csr->getResidencyAllocations());
EXPECT_TRUE(allocation->isResident(0u)); EXPECT_TRUE(allocation->isResident(0u));
EXPECT_TRUE(allocation2->isResident(0u)); EXPECT_TRUE(allocation2->isResident(0u));
@@ -836,7 +841,7 @@ TEST_F(DrmCommandStreamGemWorkerTests, givenCommandStreamWithDuplicatesWhenItIsF
auto storedBase = cs.getCpuBase(); auto storedBase = cs.getCpuBase();
auto storedGraphicsAllocation = cs.getGraphicsAllocation(); auto storedGraphicsAllocation = cs.getGraphicsAllocation();
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, csr->getResidencyAllocations(), *osContext); csr->flush(batchBuffer, csr->getResidencyAllocations());
EXPECT_EQ(cs.getCpuBase(), storedBase); EXPECT_EQ(cs.getCpuBase(), storedBase);
EXPECT_EQ(cs.getGraphicsAllocation(), storedGraphicsAllocation); EXPECT_EQ(cs.getGraphicsAllocation(), storedGraphicsAllocation);
@@ -893,13 +898,15 @@ TEST_F(DrmCommandStreamBatchingTests, givenCSRWhenFlushIsCalledThenProperFlagsAr
csr->alignToCacheLine(cs); csr->alignToCacheLine(cs);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, csr->getResidencyAllocations(), *osContext); csr->flush(batchBuffer, csr->getResidencyAllocations());
//preemption allocation + Sip Kernel //preemption allocation + Sip Kernel
int ioctlExtraCnt = (PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]) == PreemptionMode::MidThread) ? 2 : 0; int ioctlExtraCnt = (PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]) == PreemptionMode::MidThread) ? 2 : 0;
auto engineFlag = csr->getOsContext().get()->getEngineFlag();
EXPECT_EQ(6 + ioctlExtraCnt, this->mock->ioctl_cnt.total); EXPECT_EQ(6 + ioctlExtraCnt, this->mock->ioctl_cnt.total);
uint64_t flags = I915_EXEC_RENDER | I915_EXEC_NO_RELOC; uint64_t flags = engineFlag | I915_EXEC_NO_RELOC;
EXPECT_EQ(flags, this->mock->execBuffer.flags); EXPECT_EQ(flags, this->mock->execBuffer.flags);
mm->freeGraphicsMemory(dummyAllocation); mm->freeGraphicsMemory(dummyAllocation);
@@ -1041,7 +1048,7 @@ TEST_F(DrmCommandStreamLeaksTest, makeResident) {
EXPECT_EQ(nullptr, allocation->getUnderlyingBuffer()); EXPECT_EQ(nullptr, allocation->getUnderlyingBuffer());
csr->makeResident(*allocation); csr->makeResident(*allocation);
csr->processResidency(csr->getResidencyAllocations(), *osContext); csr->processResidency(csr->getResidencyAllocations());
EXPECT_TRUE(isResident(buffer)); EXPECT_TRUE(isResident(buffer));
auto bo = getResident(buffer); auto bo = getResident(buffer);
@@ -1066,7 +1073,7 @@ TEST_F(DrmCommandStreamLeaksTest, makeResidentOnly) {
csr->makeResident(*allocation1); csr->makeResident(*allocation1);
csr->makeResident(*allocation2); csr->makeResident(*allocation2);
csr->processResidency(csr->getResidencyAllocations(), *osContext); csr->processResidency(csr->getResidencyAllocations());
EXPECT_TRUE(isResident(buffer1)); EXPECT_TRUE(isResident(buffer1));
EXPECT_TRUE(isResident(buffer2)); EXPECT_TRUE(isResident(buffer2));
@@ -1090,7 +1097,7 @@ TEST_F(DrmCommandStreamLeaksTest, makeResidentTwice) {
auto allocation = new DrmAllocation(buffer, nullptr, buffer->peekSize(), MemoryPool::MemoryNull, 1u, false); auto allocation = new DrmAllocation(buffer, nullptr, buffer->peekSize(), MemoryPool::MemoryNull, 1u, false);
csr->makeResident(*allocation); csr->makeResident(*allocation);
csr->processResidency(csr->getResidencyAllocations(), *osContext); csr->processResidency(csr->getResidencyAllocations());
EXPECT_TRUE(isResident(buffer)); EXPECT_TRUE(isResident(buffer));
auto bo1 = getResident(buffer); auto bo1 = getResident(buffer);
@@ -1099,7 +1106,7 @@ TEST_F(DrmCommandStreamLeaksTest, makeResidentTwice) {
csr->getResidencyAllocations().clear(); csr->getResidencyAllocations().clear();
csr->makeResident(*allocation); csr->makeResident(*allocation);
csr->processResidency(csr->getResidencyAllocations(), *osContext); csr->processResidency(csr->getResidencyAllocations());
EXPECT_TRUE(isResident(buffer)); EXPECT_TRUE(isResident(buffer));
auto bo2 = getResident(buffer); auto bo2 = getResident(buffer);
@@ -1126,7 +1133,7 @@ TEST_F(DrmCommandStreamLeaksTest, makeResidentTwiceWhenFragmentStorage) {
csr->makeResident(*allocation); csr->makeResident(*allocation);
csr->makeResident(*allocation); csr->makeResident(*allocation);
csr->processResidency(csr->getResidencyAllocations(), *osContext); csr->processResidency(csr->getResidencyAllocations());
for (int i = 0; i < maxFragmentsCount; i++) { for (int i = 0; i < maxFragmentsCount; i++) {
ASSERT_EQ(allocation->fragmentsStorage.fragmentStorageData[i].cpuPtr, ASSERT_EQ(allocation->fragmentsStorage.fragmentStorageData[i].cpuPtr,
reqs.AllocationFragments[i].allocationPtr); reqs.AllocationFragments[i].allocationPtr);
@@ -1166,7 +1173,7 @@ TEST_F(DrmCommandStreamLeaksTest, givenFragmentedAllocationsWithResuedFragmentsW
tCsr->makeResident(*graphicsAllocation); tCsr->makeResident(*graphicsAllocation);
tCsr->makeResident(*graphicsAllocation2); tCsr->makeResident(*graphicsAllocation2);
tCsr->processResidency(csr->getResidencyAllocations(), *osContext); tCsr->processResidency(csr->getResidencyAllocations());
EXPECT_TRUE(graphicsAllocation->fragmentsStorage.fragmentStorageData[0].residency->resident); EXPECT_TRUE(graphicsAllocation->fragmentsStorage.fragmentStorageData[0].residency->resident);
EXPECT_TRUE(graphicsAllocation->fragmentsStorage.fragmentStorageData[1].residency->resident); EXPECT_TRUE(graphicsAllocation->fragmentsStorage.fragmentStorageData[1].residency->resident);
@@ -1177,7 +1184,7 @@ TEST_F(DrmCommandStreamLeaksTest, givenFragmentedAllocationsWithResuedFragmentsW
EXPECT_EQ(3u, residency->size()); EXPECT_EQ(3u, residency->size());
tCsr->makeSurfacePackNonResident(tCsr->getResidencyAllocations(), *osContext); tCsr->makeSurfacePackNonResident(tCsr->getResidencyAllocations());
//check that each packet is not resident //check that each packet is not resident
EXPECT_FALSE(graphicsAllocation->fragmentsStorage.fragmentStorageData[0].residency->resident); EXPECT_FALSE(graphicsAllocation->fragmentsStorage.fragmentStorageData[0].residency->resident);
@@ -1190,7 +1197,7 @@ TEST_F(DrmCommandStreamLeaksTest, givenFragmentedAllocationsWithResuedFragmentsW
tCsr->makeResident(*graphicsAllocation); tCsr->makeResident(*graphicsAllocation);
tCsr->makeResident(*graphicsAllocation2); tCsr->makeResident(*graphicsAllocation2);
tCsr->processResidency(csr->getResidencyAllocations(), *osContext); tCsr->processResidency(csr->getResidencyAllocations());
EXPECT_TRUE(graphicsAllocation->fragmentsStorage.fragmentStorageData[0].residency->resident); EXPECT_TRUE(graphicsAllocation->fragmentsStorage.fragmentStorageData[0].residency->resident);
EXPECT_TRUE(graphicsAllocation->fragmentsStorage.fragmentStorageData[1].residency->resident); EXPECT_TRUE(graphicsAllocation->fragmentsStorage.fragmentStorageData[1].residency->resident);
@@ -1199,7 +1206,7 @@ TEST_F(DrmCommandStreamLeaksTest, givenFragmentedAllocationsWithResuedFragmentsW
EXPECT_EQ(3u, residency->size()); EXPECT_EQ(3u, residency->size());
tCsr->makeSurfacePackNonResident(tCsr->getResidencyAllocations(), *osContext); tCsr->makeSurfacePackNonResident(tCsr->getResidencyAllocations());
EXPECT_EQ(0u, residency->size()); EXPECT_EQ(0u, residency->size());
@@ -1223,7 +1230,7 @@ TEST_F(DrmCommandStreamLeaksTest, GivenAllocationCreatedFromThreeFragmentsWhenMa
ASSERT_EQ(3u, allocation->fragmentsStorage.fragmentCount); ASSERT_EQ(3u, allocation->fragmentsStorage.fragmentCount);
csr->makeResident(*allocation); csr->makeResident(*allocation);
csr->processResidency(csr->getResidencyAllocations(), *osContext); csr->processResidency(csr->getResidencyAllocations());
for (int i = 0; i < maxFragmentsCount; i++) { for (int i = 0; i < maxFragmentsCount; i++) {
ASSERT_EQ(allocation->fragmentsStorage.fragmentStorageData[i].cpuPtr, ASSERT_EQ(allocation->fragmentsStorage.fragmentStorageData[i].cpuPtr,
@@ -1258,7 +1265,7 @@ TEST_F(DrmCommandStreamLeaksTest, GivenAllocationsContainingDifferentCountOfFrag
ASSERT_EQ(2u, reqs.requiredFragmentsCount); ASSERT_EQ(2u, reqs.requiredFragmentsCount);
csr->makeResident(*allocation); csr->makeResident(*allocation);
csr->processResidency(csr->getResidencyAllocations(), *osContext); csr->processResidency(csr->getResidencyAllocations());
for (unsigned int i = 0; i < reqs.requiredFragmentsCount; i++) { for (unsigned int i = 0; i < reqs.requiredFragmentsCount; i++) {
ASSERT_EQ(allocation->fragmentsStorage.fragmentStorageData[i].cpuPtr, ASSERT_EQ(allocation->fragmentsStorage.fragmentStorageData[i].cpuPtr,
@@ -1287,7 +1294,7 @@ TEST_F(DrmCommandStreamLeaksTest, GivenAllocationsContainingDifferentCountOfFrag
ASSERT_EQ(1u, reqs.requiredFragmentsCount); ASSERT_EQ(1u, reqs.requiredFragmentsCount);
csr->makeResident(*allocation2); csr->makeResident(*allocation2);
csr->processResidency(csr->getResidencyAllocations(), *osContext); csr->processResidency(csr->getResidencyAllocations());
for (unsigned int i = 0; i < reqs.requiredFragmentsCount; i++) { for (unsigned int i = 0; i < reqs.requiredFragmentsCount; i++) {
ASSERT_EQ(allocation2->fragmentsStorage.fragmentStorageData[i].cpuPtr, ASSERT_EQ(allocation2->fragmentsStorage.fragmentStorageData[i].cpuPtr,
@@ -1320,7 +1327,7 @@ TEST_F(DrmCommandStreamLeaksTest, GivenTwoAllocationsWhenBackingStorageIsTheSame
csr->makeResident(*allocation); csr->makeResident(*allocation);
csr->makeResident(*allocation2); csr->makeResident(*allocation2);
csr->processResidency(csr->getResidencyAllocations(), *osContext); csr->processResidency(csr->getResidencyAllocations());
EXPECT_EQ(tCsr->getResidencyVector()->size(), 1u); EXPECT_EQ(tCsr->getResidencyVector()->size(), 1u);
@@ -1343,7 +1350,7 @@ TEST_F(DrmCommandStreamLeaksTest, GivenTwoAllocationsWhenBackingStorageIsDiffere
csr->makeResident(*allocation); csr->makeResident(*allocation);
csr->makeResident(*allocation2); csr->makeResident(*allocation2);
csr->processResidency(csr->getResidencyAllocations(), *osContext); csr->processResidency(csr->getResidencyAllocations());
EXPECT_EQ(tCsr->getResidencyVector()->size(), 2u); EXPECT_EQ(tCsr->getResidencyVector()->size(), 2u);
@@ -1362,7 +1369,7 @@ TEST_F(DrmCommandStreamLeaksTest, makeResidentSizeZero) {
EXPECT_EQ(buffer->peekSize(), allocation.getUnderlyingBufferSize()); EXPECT_EQ(buffer->peekSize(), allocation.getUnderlyingBufferSize());
csr->makeResident(allocation); csr->makeResident(allocation);
csr->processResidency(csr->getResidencyAllocations(), *osContext); csr->processResidency(csr->getResidencyAllocations());
EXPECT_FALSE(isResident(buffer.get())); EXPECT_FALSE(isResident(buffer.get()));
auto bo = getResident(buffer.get()); auto bo = getResident(buffer.get());
@@ -1377,7 +1384,7 @@ TEST_F(DrmCommandStreamLeaksTest, Flush) {
csr->addBatchBufferEnd(cs, nullptr); csr->addBatchBufferEnd(cs, nullptr);
csr->alignToCacheLine(cs); csr->alignToCacheLine(cs);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, csr->getResidencyAllocations(), *osContext); csr->flush(batchBuffer, csr->getResidencyAllocations());
EXPECT_NE(cs.getCpuBase(), nullptr); EXPECT_NE(cs.getCpuBase(), nullptr);
EXPECT_NE(cs.getGraphicsAllocation(), nullptr); EXPECT_NE(cs.getGraphicsAllocation(), nullptr);
} }
@@ -1391,7 +1398,7 @@ TEST_F(DrmCommandStreamLeaksTest, ClearResidencyWhenFlushNotCalled) {
EXPECT_EQ(tCsr->getResidencyVector()->size(), 0u); EXPECT_EQ(tCsr->getResidencyVector()->size(), 0u);
csr->makeResident(*allocation1); csr->makeResident(*allocation1);
csr->makeResident(*allocation2); csr->makeResident(*allocation2);
csr->processResidency(csr->getResidencyAllocations(), *osContext); csr->processResidency(csr->getResidencyAllocations());
EXPECT_TRUE(isResident(allocation1->getBO())); EXPECT_TRUE(isResident(allocation1->getBO()));
EXPECT_TRUE(isResident(allocation2->getBO())); EXPECT_TRUE(isResident(allocation2->getBO()));
@@ -1421,14 +1428,14 @@ TEST_F(DrmCommandStreamLeaksTest, FlushMultipleTimes) {
csr->addBatchBufferEnd(cs, nullptr); csr->addBatchBufferEnd(cs, nullptr);
csr->alignToCacheLine(cs); csr->alignToCacheLine(cs);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, csr->getResidencyAllocations(), *osContext); csr->flush(batchBuffer, csr->getResidencyAllocations());
cs.replaceBuffer(commandBuffer->getUnderlyingBuffer(), commandBuffer->getUnderlyingBufferSize()); cs.replaceBuffer(commandBuffer->getUnderlyingBuffer(), commandBuffer->getUnderlyingBufferSize());
cs.replaceGraphicsAllocation(commandBuffer); cs.replaceGraphicsAllocation(commandBuffer);
csr->addBatchBufferEnd(cs, nullptr); csr->addBatchBufferEnd(cs, nullptr);
csr->alignToCacheLine(cs); csr->alignToCacheLine(cs);
BatchBuffer batchBuffer2{cs.getGraphicsAllocation(), 8, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer2{cs.getGraphicsAllocation(), 8, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer2, EngineType::ENGINE_RCS, csr->getResidencyAllocations(), *osContext); csr->flush(batchBuffer2, csr->getResidencyAllocations());
auto allocation = mm->allocateGraphicsMemory(1024); auto allocation = mm->allocateGraphicsMemory(1024);
ASSERT_NE(nullptr, allocation); ASSERT_NE(nullptr, allocation);
@@ -1447,8 +1454,8 @@ TEST_F(DrmCommandStreamLeaksTest, FlushMultipleTimes) {
csr->addBatchBufferEnd(cs, nullptr); csr->addBatchBufferEnd(cs, nullptr);
csr->alignToCacheLine(cs); csr->alignToCacheLine(cs);
BatchBuffer batchBuffer3{cs.getGraphicsAllocation(), 16, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer3{cs.getGraphicsAllocation(), 16, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer3, EngineType::ENGINE_RCS, csr->getResidencyAllocations(), *osContext); csr->flush(batchBuffer3, csr->getResidencyAllocations());
csr->makeSurfacePackNonResident(csr->getResidencyAllocations(), *osContext); csr->makeSurfacePackNonResident(csr->getResidencyAllocations());
mm->freeGraphicsMemory(allocation); mm->freeGraphicsMemory(allocation);
mm->freeGraphicsMemory(allocation2); mm->freeGraphicsMemory(allocation2);
@@ -1460,7 +1467,7 @@ TEST_F(DrmCommandStreamLeaksTest, FlushMultipleTimes) {
csr->addBatchBufferEnd(cs, nullptr); csr->addBatchBufferEnd(cs, nullptr);
csr->alignToCacheLine(cs); csr->alignToCacheLine(cs);
BatchBuffer batchBuffer4{cs.getGraphicsAllocation(), 24, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer4{cs.getGraphicsAllocation(), 24, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer4, EngineType::ENGINE_RCS, csr->getResidencyAllocations(), *osContext); csr->flush(batchBuffer4, csr->getResidencyAllocations());
} }
TEST_F(DrmCommandStreamLeaksTest, FlushNotEmptyBB) { TEST_F(DrmCommandStreamLeaksTest, FlushNotEmptyBB) {
@@ -1473,7 +1480,7 @@ TEST_F(DrmCommandStreamLeaksTest, FlushNotEmptyBB) {
csr->addBatchBufferEnd(cs, nullptr); csr->addBatchBufferEnd(cs, nullptr);
csr->alignToCacheLine(cs); csr->alignToCacheLine(cs);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, csr->getResidencyAllocations(), *osContext); csr->flush(batchBuffer, csr->getResidencyAllocations());
} }
TEST_F(DrmCommandStreamLeaksTest, FlushNotEmptyNotPaddedBB) { TEST_F(DrmCommandStreamLeaksTest, FlushNotEmptyNotPaddedBB) {
@@ -1486,7 +1493,7 @@ TEST_F(DrmCommandStreamLeaksTest, FlushNotEmptyNotPaddedBB) {
csr->addBatchBufferEnd(cs, nullptr); csr->addBatchBufferEnd(cs, nullptr);
csr->alignToCacheLine(cs); csr->alignToCacheLine(cs);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, csr->getResidencyAllocations(), *osContext); csr->flush(batchBuffer, csr->getResidencyAllocations());
} }
TEST_F(DrmCommandStreamLeaksTest, FlushNotAligned) { TEST_F(DrmCommandStreamLeaksTest, FlushNotAligned) {
@@ -1500,7 +1507,7 @@ TEST_F(DrmCommandStreamLeaksTest, FlushNotAligned) {
csr->addBatchBufferEnd(cs, nullptr); csr->addBatchBufferEnd(cs, nullptr);
csr->alignToCacheLine(cs); csr->alignToCacheLine(cs);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 4, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 4, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, csr->getResidencyAllocations(), *osContext); csr->flush(batchBuffer, csr->getResidencyAllocations());
} }
TEST_F(DrmCommandStreamLeaksTest, CheckDrmFree) { TEST_F(DrmCommandStreamLeaksTest, CheckDrmFree) {
@@ -1517,7 +1524,7 @@ TEST_F(DrmCommandStreamLeaksTest, CheckDrmFree) {
csr->addBatchBufferEnd(cs, nullptr); csr->addBatchBufferEnd(cs, nullptr);
csr->alignToCacheLine(cs); csr->alignToCacheLine(cs);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 4, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 4, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, csr->getResidencyAllocations(), *osContext); csr->flush(batchBuffer, csr->getResidencyAllocations());
csr->makeNonResident(*allocation); csr->makeNonResident(*allocation);
mm->freeGraphicsMemory(allocation); mm->freeGraphicsMemory(allocation);
} }
@@ -1533,8 +1540,8 @@ TEST_F(DrmCommandStreamLeaksTest, MakeResidentClearResidencyAllocationsInCommand
csr->makeResident(*allocation2); csr->makeResident(*allocation2);
EXPECT_NE(0u, csr->getResidencyAllocations().size()); EXPECT_NE(0u, csr->getResidencyAllocations().size());
csr->processResidency(csr->getResidencyAllocations(), *device->getOsContext()); csr->processResidency(csr->getResidencyAllocations());
csr->makeSurfacePackNonResident(csr->getResidencyAllocations(), *osContext); csr->makeSurfacePackNonResident(csr->getResidencyAllocations());
EXPECT_EQ(0u, csr->getResidencyAllocations().size()); EXPECT_EQ(0u, csr->getResidencyAllocations().size());
mm->freeGraphicsMemory(allocation1); mm->freeGraphicsMemory(allocation1);
@@ -1551,8 +1558,8 @@ TEST_F(DrmCommandStreamLeaksTest, givenMultipleMakeResidentWhenMakeNonResidentIs
EXPECT_NE(0u, csr->getResidencyAllocations().size()); EXPECT_NE(0u, csr->getResidencyAllocations().size());
csr->processResidency(csr->getResidencyAllocations(), *device->getOsContext()); csr->processResidency(csr->getResidencyAllocations());
csr->makeSurfacePackNonResident(csr->getResidencyAllocations(), *osContext); csr->makeSurfacePackNonResident(csr->getResidencyAllocations());
EXPECT_EQ(0u, csr->getResidencyAllocations().size()); EXPECT_EQ(0u, csr->getResidencyAllocations().size());
EXPECT_FALSE(allocation1->isResident(0u)); EXPECT_FALSE(allocation1->isResident(0u));
@@ -1612,7 +1619,7 @@ TEST_F(DrmCommandStreamLeaksTest, BufferResidency) {
//make it resident 8 times //make it resident 8 times
for (int c = 0; c < 8; c++) { for (int c = 0; c < 8; c++) {
csr->makeResident(*buffer->getGraphicsAllocation()); csr->makeResident(*buffer->getGraphicsAllocation());
csr->processResidency(csr->getResidencyAllocations(), *osContext); csr->processResidency(csr->getResidencyAllocations());
EXPECT_TRUE(buffer->getGraphicsAllocation()->isResident(0u)); EXPECT_TRUE(buffer->getGraphicsAllocation()->isResident(0u));
EXPECT_EQ(buffer->getGraphicsAllocation()->getResidencyTaskCount(0u), csr->peekTaskCount() + 1); EXPECT_EQ(buffer->getGraphicsAllocation()->getResidencyTaskCount(0u), csr->peekTaskCount() + 1);
} }

View File

@@ -0,0 +1,22 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "drm/i915_drm.h"
#include "runtime/os_interface/linux/drm_engine_mapper.h"
#include "test.h"
using namespace OCLRT;
TEST(DrmMapperTests, engineNodeMapPass) {
unsigned int flag = DrmEngineMapper::engineNodeMap(EngineType::ENGINE_RCS);
unsigned int expected = I915_EXEC_RENDER;
EXPECT_EQ(expected, flag);
}
TEST(DrmMapperTests, engineNodeMapNegative) {
EXPECT_THROW(DrmEngineMapper::engineNodeMap(EngineType::ENGINE_BCS), std::exception);
}

View File

@@ -1622,8 +1622,7 @@ TEST_F(DrmMemoryManagerTest, givenTwoGraphicsAllocationsThatShareTheSameBufferOb
testedCsr->makeResident(*graphicsAllocation2); testedCsr->makeResident(*graphicsAllocation2);
EXPECT_EQ(2u, testedCsr->getResidencyAllocations().size()); EXPECT_EQ(2u, testedCsr->getResidencyAllocations().size());
OsContext osContext(executionEnvironment->osInterface.get(), 0u); testedCsr->processResidency(testedCsr->getResidencyAllocations());
testedCsr->processResidency(testedCsr->getResidencyAllocations(), osContext);
EXPECT_EQ(1u, testedCsr->residency.size()); EXPECT_EQ(1u, testedCsr->residency.size());
@@ -1651,8 +1650,7 @@ TEST_F(DrmMemoryManagerTest, givenTwoGraphicsAllocationsThatDoesnShareTheSameBuf
testedCsr->makeResident(*graphicsAllocation2); testedCsr->makeResident(*graphicsAllocation2);
EXPECT_EQ(2u, testedCsr->getResidencyAllocations().size()); EXPECT_EQ(2u, testedCsr->getResidencyAllocations().size());
OsContext osContext(executionEnvironment->osInterface.get(), 0u); testedCsr->processResidency(testedCsr->getResidencyAllocations());
testedCsr->processResidency(testedCsr->getResidencyAllocations(), osContext);
EXPECT_EQ(2u, testedCsr->residency.size()); EXPECT_EQ(2u, testedCsr->residency.size());

View File

@@ -26,7 +26,7 @@ TEST(OsContextTest, givenDrmWhenOsContextIsCreatedThenImplIsAvailable) {
OSInterface osInterface; OSInterface osInterface;
osInterface.get()->setDrm(&drmMock); osInterface.get()->setDrm(&drmMock);
auto osContext = std::make_unique<OsContext>(&osInterface, 0u); auto osContext = std::make_unique<OsContext>(&osInterface, 0u, gpgpuEngineInstances[0]);
EXPECT_NE(nullptr, osContext->get()); EXPECT_NE(nullptr, osContext->get());
} }
} // namespace OCLRT } // namespace OCLRT

View File

@@ -33,6 +33,7 @@ set(IGDRCL_SRCS_tests_os_interface_windows
${CMAKE_CURRENT_SOURCE_DIR}/wddm_kmdaf_listener_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/wddm_kmdaf_listener_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/wddm_memory_manager_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/wddm_memory_manager_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/wddm_memory_manager_tests.h ${CMAKE_CURRENT_SOURCE_DIR}/wddm_memory_manager_tests.h
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/wddm_mapper_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/wddm_memory_manager_allocate_in_device_pool_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/wddm_memory_manager_allocate_in_device_pool_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/wddm_memory_manager_allocate_in_device_pool_tests.inl ${CMAKE_CURRENT_SOURCE_DIR}/wddm_memory_manager_allocate_in_device_pool_tests.inl
${CMAKE_CURRENT_SOURCE_DIR}/wddm_preemption_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/wddm_preemption_tests.cpp

View File

@@ -179,7 +179,7 @@ TEST_F(DeviceCommandStreamTest, CreateWddmCSRWithAubDump) {
TEST_F(WddmCommandStreamTest, givenFlushStampWhenWaitCalledThenWaitForSpecifiedMonitoredFence) { TEST_F(WddmCommandStreamTest, givenFlushStampWhenWaitCalledThenWaitForSpecifiedMonitoredFence) {
uint64_t stampToWait = 123; uint64_t stampToWait = 123;
csr->waitForFlushStamp(stampToWait, *device->getOsContext()); csr->waitForFlushStamp(stampToWait);
EXPECT_EQ(1u, wddm->waitFromCpuResult.called); EXPECT_EQ(1u, wddm->waitFromCpuResult.called);
EXPECT_TRUE(wddm->waitFromCpuResult.success); EXPECT_TRUE(wddm->waitFromCpuResult.success);
EXPECT_EQ(stampToWait, wddm->waitFromCpuResult.uint64ParamPassed); EXPECT_EQ(stampToWait, wddm->waitFromCpuResult.uint64ParamPassed);
@@ -190,11 +190,11 @@ TEST_F(WddmCommandStreamTest, Flush) {
ASSERT_NE(nullptr, commandBuffer); ASSERT_NE(nullptr, commandBuffer);
LinearStream cs(commandBuffer); LinearStream cs(commandBuffer);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
auto flushStamp = csr->flush(batchBuffer, EngineType::ENGINE_RCS, csr->getResidencyAllocations(), *device->getOsContext()); auto flushStamp = csr->flush(batchBuffer, csr->getResidencyAllocations());
EXPECT_EQ(1u, wddm->submitResult.called); EXPECT_EQ(1u, wddm->submitResult.called);
EXPECT_TRUE(wddm->submitResult.success); EXPECT_TRUE(wddm->submitResult.success);
EXPECT_EQ(flushStamp, device->getOsContext()->get()->getResidencyController().getMonitoredFence().lastSubmittedFence); EXPECT_EQ(flushStamp, csr->getOsContext().get()->getResidencyController().getMonitoredFence().lastSubmittedFence);
memoryManager->freeGraphicsMemory(commandBuffer); memoryManager->freeGraphicsMemory(commandBuffer);
} }
@@ -208,7 +208,7 @@ TEST_F(WddmCommandStreamTest, givenGraphicsAllocationWithDifferentGpuAddressThen
LinearStream cs(commandBuffer); LinearStream cs(commandBuffer);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
auto flushStamp = csr->flush(batchBuffer, EngineType::ENGINE_RCS, csr->getResidencyAllocations(), *device->getOsContext()); auto flushStamp = csr->flush(batchBuffer, csr->getResidencyAllocations());
EXPECT_EQ(mockGpuAddres, wddm->submitResult.commandBufferSubmitted); EXPECT_EQ(mockGpuAddres, wddm->submitResult.commandBufferSubmitted);
memoryManager->freeGraphicsMemory(commandBuffer); memoryManager->freeGraphicsMemory(commandBuffer);
} }
@@ -219,7 +219,7 @@ TEST_F(WddmCommandStreamTest, FlushWithOffset) {
LinearStream cs(commandBuffer); LinearStream cs(commandBuffer);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), offset, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), offset, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, csr->getResidencyAllocations(), *device->getOsContext()); csr->flush(batchBuffer, csr->getResidencyAllocations());
EXPECT_EQ(1u, wddm->submitResult.called); EXPECT_EQ(1u, wddm->submitResult.called);
EXPECT_TRUE(wddm->submitResult.success); EXPECT_TRUE(wddm->submitResult.success);
EXPECT_EQ(wddm->submitResult.commandBufferSubmitted, commandBuffer->getGpuAddress() + offset); EXPECT_EQ(wddm->submitResult.commandBufferSubmitted, commandBuffer->getGpuAddress() + offset);
@@ -233,7 +233,7 @@ TEST_F(WddmCommandStreamTest, givenWdmmWhenSubmitIsCalledThenCoherencyRequiredFl
LinearStream cs(commandBuffer); LinearStream cs(commandBuffer);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, csr->getResidencyAllocations(), *device->getOsContext()); csr->flush(batchBuffer, csr->getResidencyAllocations());
auto commandHeader = wddm->submitResult.commandHeaderSubmitted; auto commandHeader = wddm->submitResult.commandHeaderSubmitted;
COMMAND_BUFFER_HEADER *pHeader = reinterpret_cast<COMMAND_BUFFER_HEADER *>(commandHeader); COMMAND_BUFFER_HEADER *pHeader = reinterpret_cast<COMMAND_BUFFER_HEADER *>(commandHeader);
@@ -253,20 +253,19 @@ TEST(WddmPreemptionHeaderTests, givenWddmCommandStreamReceiverWhenPreemptionIsOf
std::make_unique<MockWddmCsr<DEFAULT_TEST_FAMILY_NAME>>(hwInfo[0], *executionEnvironment); std::make_unique<MockWddmCsr<DEFAULT_TEST_FAMILY_NAME>>(hwInfo[0], *executionEnvironment);
executionEnvironment->memoryManager.reset(executionEnvironment->commandStreamReceivers[0][0]->createMemoryManager(false, false)); executionEnvironment->memoryManager.reset(executionEnvironment->commandStreamReceivers[0][0]->createMemoryManager(false, false));
executionEnvironment->commandStreamReceivers[0][0]->overrideDispatchPolicy(DispatchMode::ImmediateDispatch); executionEnvironment->commandStreamReceivers[0][0]->overrideDispatchPolicy(DispatchMode::ImmediateDispatch);
OsContext osContext(executionEnvironment->osInterface.get(), 0u, gpgpuEngineInstances[0]);
executionEnvironment->commandStreamReceivers[0][0]->setOsContext(&osContext);
auto commandBuffer = executionEnvironment->memoryManager->allocateGraphicsMemory(4096); auto commandBuffer = executionEnvironment->memoryManager->allocateGraphicsMemory(4096);
LinearStream cs(commandBuffer); LinearStream cs(commandBuffer);
OsContext *osContext = new OsContext(executionEnvironment->osInterface.get(), 0u);
osContext->incRefInternal();
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
executionEnvironment->commandStreamReceivers[0][0]->flush(batchBuffer, EngineType::ENGINE_RCS, executionEnvironment->commandStreamReceivers[0][0]->flush(batchBuffer, executionEnvironment->commandStreamReceivers[0][0]->getResidencyAllocations());
executionEnvironment->commandStreamReceivers[0][0]->getResidencyAllocations(), *osContext);
auto commandHeader = wddm->submitResult.commandHeaderSubmitted; auto commandHeader = wddm->submitResult.commandHeaderSubmitted;
COMMAND_BUFFER_HEADER *pHeader = reinterpret_cast<COMMAND_BUFFER_HEADER *>(commandHeader); COMMAND_BUFFER_HEADER *pHeader = reinterpret_cast<COMMAND_BUFFER_HEADER *>(commandHeader);
EXPECT_FALSE(pHeader->NeedsMidBatchPreEmptionSupport); EXPECT_FALSE(pHeader->NeedsMidBatchPreEmptionSupport);
executionEnvironment->memoryManager->freeGraphicsMemory(commandBuffer); executionEnvironment->memoryManager->freeGraphicsMemory(commandBuffer);
osContext->decRefInternal();
} }
TEST(WddmPreemptionHeaderTests, givenWddmCommandStreamReceiverWhenPreemptionIsOnWhenWorkloadIsSubmittedThenHeaderDoesHavePreemptionFieldSet) { TEST(WddmPreemptionHeaderTests, givenWddmCommandStreamReceiverWhenPreemptionIsOnWhenWorkloadIsSubmittedThenHeaderDoesHavePreemptionFieldSet) {
@@ -279,20 +278,20 @@ TEST(WddmPreemptionHeaderTests, givenWddmCommandStreamReceiverWhenPreemptionIsOn
*executionEnvironment); *executionEnvironment);
executionEnvironment->memoryManager.reset(executionEnvironment->commandStreamReceivers[0][0]->createMemoryManager(false, false)); executionEnvironment->memoryManager.reset(executionEnvironment->commandStreamReceivers[0][0]->createMemoryManager(false, false));
executionEnvironment->commandStreamReceivers[0][0]->overrideDispatchPolicy(DispatchMode::ImmediateDispatch); executionEnvironment->commandStreamReceivers[0][0]->overrideDispatchPolicy(DispatchMode::ImmediateDispatch);
OsContext osContext(executionEnvironment->osInterface.get(), 0u, gpgpuEngineInstances[0]);
executionEnvironment->commandStreamReceivers[0][0]->setOsContext(&osContext);
auto commandBuffer = executionEnvironment->memoryManager->allocateGraphicsMemory(4096); auto commandBuffer = executionEnvironment->memoryManager->allocateGraphicsMemory(4096);
LinearStream cs(commandBuffer); LinearStream cs(commandBuffer);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
OsContext *osContext = new OsContext(executionEnvironment->osInterface.get(), 0u);
osContext->incRefInternal(); executionEnvironment->commandStreamReceivers[0][0]->flush(batchBuffer, executionEnvironment->commandStreamReceivers[0][0]->getResidencyAllocations());
executionEnvironment->commandStreamReceivers[0][0]->flush(batchBuffer, EngineType::ENGINE_RCS, executionEnvironment->commandStreamReceivers[0][0]->getResidencyAllocations(), *osContext);
auto commandHeader = wddm->submitResult.commandHeaderSubmitted; auto commandHeader = wddm->submitResult.commandHeaderSubmitted;
COMMAND_BUFFER_HEADER *pHeader = reinterpret_cast<COMMAND_BUFFER_HEADER *>(commandHeader); COMMAND_BUFFER_HEADER *pHeader = reinterpret_cast<COMMAND_BUFFER_HEADER *>(commandHeader);
EXPECT_TRUE(pHeader->NeedsMidBatchPreEmptionSupport); EXPECT_TRUE(pHeader->NeedsMidBatchPreEmptionSupport);
executionEnvironment->memoryManager->freeGraphicsMemory(commandBuffer); executionEnvironment->memoryManager->freeGraphicsMemory(commandBuffer);
osContext->decRefInternal();
} }
TEST(WddmPreemptionHeaderTests, givenDeviceSupportingPreemptionWhenCommandStreamReceiverIsCreatedThenHeaderContainsPreemptionFieldSet) { TEST(WddmPreemptionHeaderTests, givenDeviceSupportingPreemptionWhenCommandStreamReceiverIsCreatedThenHeaderContainsPreemptionFieldSet) {
@@ -321,7 +320,7 @@ TEST_F(WddmCommandStreamTest, givenWdmmWhenSubmitIsCalledAndThrottleIsToLowThenS
LinearStream cs(commandBuffer); LinearStream cs(commandBuffer);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::LOW, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::LOW, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, csr->getResidencyAllocations(), *device->getOsContext()); csr->flush(batchBuffer, csr->getResidencyAllocations());
auto commandHeader = wddm->submitResult.commandHeaderSubmitted; auto commandHeader = wddm->submitResult.commandHeaderSubmitted;
COMMAND_BUFFER_HEADER *pHeader = reinterpret_cast<COMMAND_BUFFER_HEADER *>(commandHeader); COMMAND_BUFFER_HEADER *pHeader = reinterpret_cast<COMMAND_BUFFER_HEADER *>(commandHeader);
@@ -339,7 +338,7 @@ TEST_F(WddmCommandStreamTest, givenWdmmWhenSubmitIsCalledAndThrottleIsToMediumTh
LinearStream cs(commandBuffer); LinearStream cs(commandBuffer);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, csr->getResidencyAllocations(), *device->getOsContext()); csr->flush(batchBuffer, csr->getResidencyAllocations());
auto commandHeader = wddm->submitResult.commandHeaderSubmitted; auto commandHeader = wddm->submitResult.commandHeaderSubmitted;
COMMAND_BUFFER_HEADER *pHeader = reinterpret_cast<COMMAND_BUFFER_HEADER *>(commandHeader); COMMAND_BUFFER_HEADER *pHeader = reinterpret_cast<COMMAND_BUFFER_HEADER *>(commandHeader);
@@ -357,7 +356,7 @@ TEST_F(WddmCommandStreamTest, givenWdmmWhenSubmitIsCalledAndThrottleIsToHighThen
LinearStream cs(commandBuffer); LinearStream cs(commandBuffer);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::HIGH, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::HIGH, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, csr->getResidencyAllocations(), *device->getOsContext()); csr->flush(batchBuffer, csr->getResidencyAllocations());
auto commandHeader = wddm->submitResult.commandHeaderSubmitted; auto commandHeader = wddm->submitResult.commandHeaderSubmitted;
COMMAND_BUFFER_HEADER *pHeader = reinterpret_cast<COMMAND_BUFFER_HEADER *>(commandHeader); COMMAND_BUFFER_HEADER *pHeader = reinterpret_cast<COMMAND_BUFFER_HEADER *>(commandHeader);
@@ -381,7 +380,7 @@ TEST_F(WddmCommandStreamTest, givenWddmWithKmDafDisabledWhenFlushIsCalledWithAll
ResidencyContainer allocationsForResidency = {linearStreamAllocation}; ResidencyContainer allocationsForResidency = {linearStreamAllocation};
EXPECT_FALSE(wddm->isKmDafEnabled()); EXPECT_FALSE(wddm->isKmDafEnabled());
auto flushStamp = csr->flush(batchBuffer, EngineType::ENGINE_RCS, allocationsForResidency, *device->getOsContext()); auto flushStamp = csr->flush(batchBuffer, allocationsForResidency);
EXPECT_EQ(0u, wddm->kmDafLockResult.called); EXPECT_EQ(0u, wddm->kmDafLockResult.called);
EXPECT_EQ(0u, wddm->kmDafLockResult.lockedAllocations.size()); EXPECT_EQ(0u, wddm->kmDafLockResult.lockedAllocations.size());
@@ -397,7 +396,7 @@ TEST_F(WddmCommandStreamTest, givenWddmWithKmDafEnabledWhenFlushIsCalledWithoutA
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
wddm->setKmDafEnabled(true); wddm->setKmDafEnabled(true);
auto flushStamp = csr->flush(batchBuffer, EngineType::ENGINE_RCS, csr->getResidencyAllocations(), *device->getOsContext()); auto flushStamp = csr->flush(batchBuffer, csr->getResidencyAllocations());
EXPECT_EQ(0u, wddm->kmDafLockResult.called); EXPECT_EQ(0u, wddm->kmDafLockResult.called);
EXPECT_EQ(0u, wddm->kmDafLockResult.lockedAllocations.size()); EXPECT_EQ(0u, wddm->kmDafLockResult.lockedAllocations.size());
@@ -420,7 +419,7 @@ TEST_F(WddmCommandStreamTest, givenWddmWithKmDafEnabledWhenFlushIsCalledWithResi
EXPECT_EQ(linearStreamAllocation, csr->getResidencyAllocations()[0]); EXPECT_EQ(linearStreamAllocation, csr->getResidencyAllocations()[0]);
wddm->setKmDafEnabled(true); wddm->setKmDafEnabled(true);
auto flushStamp = csr->flush(batchBuffer, EngineType::ENGINE_RCS, csr->getResidencyAllocations(), *device->getOsContext()); auto flushStamp = csr->flush(batchBuffer, csr->getResidencyAllocations());
EXPECT_EQ(1u, wddm->kmDafLockResult.called); EXPECT_EQ(1u, wddm->kmDafLockResult.called);
EXPECT_EQ(1u, wddm->kmDafLockResult.lockedAllocations.size()); EXPECT_EQ(1u, wddm->kmDafLockResult.lockedAllocations.size());
@@ -442,7 +441,7 @@ TEST_F(WddmCommandStreamTest, givenWddmWithKmDafEnabledWhenFlushIsCalledWithAllo
ResidencyContainer allocationsForResidency = {linearStreamAllocation}; ResidencyContainer allocationsForResidency = {linearStreamAllocation};
wddm->setKmDafEnabled(true); wddm->setKmDafEnabled(true);
auto flushStamp = csr->flush(batchBuffer, EngineType::ENGINE_RCS, allocationsForResidency, *device->getOsContext()); auto flushStamp = csr->flush(batchBuffer, allocationsForResidency);
EXPECT_EQ(1u, wddm->kmDafLockResult.called); EXPECT_EQ(1u, wddm->kmDafLockResult.called);
EXPECT_EQ(1u, wddm->kmDafLockResult.lockedAllocations.size()); EXPECT_EQ(1u, wddm->kmDafLockResult.lockedAllocations.size());
@@ -464,7 +463,7 @@ TEST_F(WddmCommandStreamTest, givenWddmWithKmDafEnabledWhenFlushIsCalledWithAllo
ResidencyContainer allocationsForResidency = {fillPatternAllocation}; ResidencyContainer allocationsForResidency = {fillPatternAllocation};
wddm->setKmDafEnabled(true); wddm->setKmDafEnabled(true);
auto flushStamp = csr->flush(batchBuffer, EngineType::ENGINE_RCS, allocationsForResidency, *device->getOsContext()); auto flushStamp = csr->flush(batchBuffer, allocationsForResidency);
EXPECT_EQ(1u, wddm->kmDafLockResult.called); EXPECT_EQ(1u, wddm->kmDafLockResult.called);
EXPECT_EQ(1u, wddm->kmDafLockResult.lockedAllocations.size()); EXPECT_EQ(1u, wddm->kmDafLockResult.lockedAllocations.size());
@@ -485,7 +484,7 @@ TEST_F(WddmCommandStreamTest, givenWddmWithKmDafEnabledWhenFlushIsCalledWithAllo
ResidencyContainer allocationsForResidency = {nonLinearStreamAllocation}; ResidencyContainer allocationsForResidency = {nonLinearStreamAllocation};
wddm->setKmDafEnabled(true); wddm->setKmDafEnabled(true);
auto flushStamp = csr->flush(batchBuffer, EngineType::ENGINE_RCS, allocationsForResidency, *device->getOsContext()); auto flushStamp = csr->flush(batchBuffer, allocationsForResidency);
EXPECT_EQ(0u, wddm->kmDafLockResult.called); EXPECT_EQ(0u, wddm->kmDafLockResult.called);
EXPECT_EQ(0u, wddm->kmDafLockResult.lockedAllocations.size()); EXPECT_EQ(0u, wddm->kmDafLockResult.lockedAllocations.size());
@@ -539,9 +538,9 @@ TEST_F(WddmCommandStreamTest, processEvictionPlacesAllAllocationsOnTrimCandidate
EXPECT_EQ(2u, csr->getEvictionAllocations().size()); EXPECT_EQ(2u, csr->getEvictionAllocations().size());
csr->processEviction(*device->getOsContext()); csr->processEviction();
EXPECT_EQ(2u, device->getOsContext()->get()->getResidencyController().peekTrimCandidateList().size()); EXPECT_EQ(2u, csr->getOsContext().get()->getResidencyController().peekTrimCandidateList().size());
memoryManager->freeGraphicsMemory(allocation); memoryManager->freeGraphicsMemory(allocation);
memoryManager->freeGraphicsMemory(allocation2); memoryManager->freeGraphicsMemory(allocation2);
@@ -557,7 +556,7 @@ TEST_F(WddmCommandStreamTest, processEvictionClearsEvictionAllocations) {
EXPECT_EQ(1u, csr->getEvictionAllocations().size()); EXPECT_EQ(1u, csr->getEvictionAllocations().size());
csr->processEviction(*device->getOsContext()); csr->processEviction();
EXPECT_EQ(0u, csr->getEvictionAllocations().size()); EXPECT_EQ(0u, csr->getEvictionAllocations().size());
@@ -661,7 +660,7 @@ TEST_F(WddmCommandStreamMockGdiTest, FlushCallsWddmMakeResidentForResidencyAlloc
gdi->getMakeResidentArg().NumAllocations = 0; gdi->getMakeResidentArg().NumAllocations = 0;
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, csr->getResidencyAllocations(), *device->getOsContext()); csr->flush(batchBuffer, csr->getResidencyAllocations());
EXPECT_NE(0u, gdi->getMakeResidentArg().NumAllocations); EXPECT_NE(0u, gdi->getMakeResidentArg().NumAllocations);
@@ -678,16 +677,16 @@ TEST_F(WddmCommandStreamMockGdiTest, makeResidentClearsResidencyAllocations) {
EXPECT_EQ(1u, csr->getResidencyAllocations().size()); EXPECT_EQ(1u, csr->getResidencyAllocations().size());
EXPECT_EQ(0u, csr->getEvictionAllocations().size()); EXPECT_EQ(0u, csr->getEvictionAllocations().size());
EXPECT_EQ(trimListUnusedPosition, ((WddmAllocation *)commandBuffer)->getTrimCandidateListPosition(device->getOsContext()->getContextId())); EXPECT_EQ(trimListUnusedPosition, ((WddmAllocation *)commandBuffer)->getTrimCandidateListPosition(csr->getOsContext().getContextId()));
csr->processResidency(csr->getResidencyAllocations(), *device->getOsContext()); csr->processResidency(csr->getResidencyAllocations());
csr->makeSurfacePackNonResident(csr->getResidencyAllocations(), *device->getOsContext()); csr->makeSurfacePackNonResident(csr->getResidencyAllocations());
EXPECT_EQ(0u, csr->getResidencyAllocations().size()); EXPECT_EQ(0u, csr->getResidencyAllocations().size());
EXPECT_EQ(0u, csr->getEvictionAllocations().size()); EXPECT_EQ(0u, csr->getEvictionAllocations().size());
EXPECT_EQ(0u, ((WddmAllocation *)commandBuffer)->getTrimCandidateListPosition(device->getOsContext()->getContextId())); EXPECT_EQ(0u, ((WddmAllocation *)commandBuffer)->getTrimCandidateListPosition(csr->getOsContext().getContextId()));
memoryManager->freeGraphicsMemory(commandBuffer); memoryManager->freeGraphicsMemory(commandBuffer);
} }
@@ -761,12 +760,12 @@ HWTEST_F(WddmCommandStreamMockGdiTest, givenRecordedCommandBufferWhenItIsSubmitt
EXPECT_TRUE(found); EXPECT_TRUE(found);
} }
EXPECT_NE(trimListUnusedPosition, ((WddmAllocation *)tagAllocation)->getTrimCandidateListPosition(device->getOsContext()->getContextId())); EXPECT_NE(trimListUnusedPosition, ((WddmAllocation *)tagAllocation)->getTrimCandidateListPosition(csr->getOsContext().getContextId()));
EXPECT_NE(trimListUnusedPosition, ((WddmAllocation *)commandBuffer)->getTrimCandidateListPosition(device->getOsContext()->getContextId())); EXPECT_NE(trimListUnusedPosition, ((WddmAllocation *)commandBuffer)->getTrimCandidateListPosition(csr->getOsContext().getContextId()));
EXPECT_EQ(trimListUnusedPosition, ((WddmAllocation *)dshAlloc)->getTrimCandidateListPosition(device->getOsContext()->getContextId())); EXPECT_EQ(trimListUnusedPosition, ((WddmAllocation *)dshAlloc)->getTrimCandidateListPosition(csr->getOsContext().getContextId()));
EXPECT_EQ(trimListUnusedPosition, ((WddmAllocation *)iohAlloc)->getTrimCandidateListPosition(device->getOsContext()->getContextId())); EXPECT_EQ(trimListUnusedPosition, ((WddmAllocation *)iohAlloc)->getTrimCandidateListPosition(csr->getOsContext().getContextId()));
EXPECT_NE(trimListUnusedPosition, ((WddmAllocation *)sshAlloc)->getTrimCandidateListPosition(device->getOsContext()->getContextId())); EXPECT_NE(trimListUnusedPosition, ((WddmAllocation *)sshAlloc)->getTrimCandidateListPosition(csr->getOsContext().getContextId()));
EXPECT_NE(trimListUnusedPosition, ((WddmAllocation *)csrCommandStream)->getTrimCandidateListPosition(device->getOsContext()->getContextId())); EXPECT_NE(trimListUnusedPosition, ((WddmAllocation *)csrCommandStream)->getTrimCandidateListPosition(csr->getOsContext().getContextId()));
memoryManager->freeGraphicsMemory(dshAlloc); memoryManager->freeGraphicsMemory(dshAlloc);
memoryManager->freeGraphicsMemory(iohAlloc); memoryManager->freeGraphicsMemory(iohAlloc);

View File

@@ -323,7 +323,7 @@ TEST_F(GlArbSyncEventOsTest, GivenCallToSignalArbSyncObjectWhenSignalSynchroniza
}; };
FailSignalSyncObjectMock::reset(); FailSignalSyncObjectMock::reset();
wddm->init(); wddm->init();
OsContext osContext(&osInterface, 0u); OsContext osContext(&osInterface, 0u, gpgpuEngineInstances[0]);
CL_GL_SYNC_INFO syncInfo = {}; CL_GL_SYNC_INFO syncInfo = {};
syncInfo.serverSynchronizationObject = 0x5cU; syncInfo.serverSynchronizationObject = 0x5cU;
@@ -381,7 +381,7 @@ TEST_F(GlArbSyncEventOsTest, GivenCallToSignalArbSyncObjectWhenSignalSynchroniza
}; };
FailSignalSyncObjectMock::reset(); FailSignalSyncObjectMock::reset();
wddm->init(); wddm->init();
OsContext osContext(&osInterface, 0u); OsContext osContext(&osInterface, 0u, gpgpuEngineInstances[0]);
CL_GL_SYNC_INFO syncInfo = {}; CL_GL_SYNC_INFO syncInfo = {};
syncInfo.submissionSynchronizationObject = 0x7cU; syncInfo.submissionSynchronizationObject = 0x7cU;

View File

@@ -29,7 +29,7 @@ TEST(OsContextTest, givenWddmWhenCreateOsContextBeforeInitWddmThenOsContextIsNot
auto wddm = new WddmMock; auto wddm = new WddmMock;
OSInterface osInterface; OSInterface osInterface;
osInterface.get()->setWddm(wddm); osInterface.get()->setWddm(wddm);
EXPECT_THROW(auto osContext = std::make_unique<OsContext>(&osInterface, 0u), std::exception); EXPECT_THROW(auto osContext = std::make_unique<OsContext>(&osInterface, 0u, gpgpuEngineInstances[0]), std::exception);
} }
TEST(OsContextTest, givenWddmWhenCreateOsContextAfterInitWddmThenOsContextIsInitializedAndTrimCallbackIsRegistered) { TEST(OsContextTest, givenWddmWhenCreateOsContextAfterInitWddmThenOsContextIsInitializedAndTrimCallbackIsRegistered) {
@@ -38,7 +38,7 @@ TEST(OsContextTest, givenWddmWhenCreateOsContextAfterInitWddmThenOsContextIsInit
osInterface.get()->setWddm(wddm); osInterface.get()->setWddm(wddm);
wddm->init(); wddm->init();
EXPECT_EQ(0u, wddm->registerTrimCallbackResult.called); EXPECT_EQ(0u, wddm->registerTrimCallbackResult.called);
auto osContext = std::make_unique<OsContext>(&osInterface, 0u); auto osContext = std::make_unique<OsContext>(&osInterface, 0u, gpgpuEngineInstances[0]);
EXPECT_NE(nullptr, osContext->get()); EXPECT_NE(nullptr, osContext->get());
EXPECT_TRUE(osContext->get()->isInitialized()); EXPECT_TRUE(osContext->get()->isInitialized());
EXPECT_EQ(osContext->get()->getWddm(), wddm); EXPECT_EQ(osContext->get()->getWddm(), wddm);
@@ -46,6 +46,6 @@ TEST(OsContextTest, givenWddmWhenCreateOsContextAfterInitWddmThenOsContextIsInit
} }
TEST(OsContextTest, whenCreateOsContextWithoutOsInterfaceThenOsContextImplIsNotAvailable) { TEST(OsContextTest, whenCreateOsContextWithoutOsInterfaceThenOsContextImplIsNotAvailable) {
auto osContext = std::make_unique<OsContext>(nullptr, 0u); auto osContext = std::make_unique<OsContext>(nullptr, 0u, gpgpuEngineInstances[0]);
EXPECT_EQ(nullptr, osContext->get()); EXPECT_EQ(nullptr, osContext->get());
} }

View File

@@ -17,6 +17,7 @@
#include "runtime/os_interface/os_library.h" #include "runtime/os_interface/os_library.h"
#include "runtime/os_interface/windows/os_context_win.h" #include "runtime/os_interface/windows/os_context_win.h"
#include "runtime/os_interface/windows/wddm_allocation.h" #include "runtime/os_interface/windows/wddm_allocation.h"
#include "runtime/os_interface/windows/wddm_engine_mapper.h"
#include "runtime/os_interface/windows/wddm_memory_manager.h" #include "runtime/os_interface/windows/wddm_memory_manager.h"
#include "unit_tests/helpers/debug_manager_state_restore.h" #include "unit_tests/helpers/debug_manager_state_restore.h"
@@ -547,6 +548,13 @@ TEST_F(Wddm20WithMockGdiDllTestsWithoutWddmInit, givenUseNoRingFlushesKmdModeDeb
EXPECT_TRUE(!!privateData->NoRingFlushes); EXPECT_TRUE(!!privateData->NoRingFlushes);
} }
TEST_F(Wddm20WithMockGdiDllTestsWithoutWddmInit, givenEngineTypeWhenCreatingContextThenPassCorrectNodeOrdinal) {
init();
auto createContextParams = this->getCreateContextDataFcn();
UINT expected = WddmEngineMapper::engineNodeMap(gpgpuEngineInstances[0].type);
EXPECT_EQ(expected, createContextParams->NodeOrdinal);
}
TEST_F(Wddm20WithMockGdiDllTests, whenCreateContextIsCalledThenDisableHwQueues) { TEST_F(Wddm20WithMockGdiDllTests, whenCreateContextIsCalledThenDisableHwQueues) {
EXPECT_FALSE(wddm->wddmInterface->hwQueuesSupported()); EXPECT_FALSE(wddm->wddmInterface->hwQueuesSupported());
EXPECT_EQ(0u, getCreateContextDataFcn()->Flags.HwQueueSupported); EXPECT_EQ(0u, getCreateContextDataFcn()->Flags.HwQueueSupported);

View File

@@ -35,7 +35,7 @@ struct Wddm23TestsWithoutWddmInit : public ::testing::Test, GdiDllFixture, publi
void init() { void init() {
EXPECT_TRUE(wddm->init()); EXPECT_TRUE(wddm->init());
osContext = std::make_unique<OsContext>(osInterface.get(), 0u); osContext = std::make_unique<OsContext>(osInterface.get(), 0u, gpgpuEngineInstances[0]);
osContextWin = osContext->get(); osContextWin = osContext->get();
} }

View File

@@ -26,7 +26,7 @@ struct WddmFixture : public GmmEnvironmentFixture {
gdi = new MockGdi(); gdi = new MockGdi();
wddm->gdi.reset(gdi); wddm->gdi.reset(gdi);
wddm->init(); wddm->init();
osContext = std::make_unique<OsContext>(osInterface.get(), 0u); osContext = std::make_unique<OsContext>(osInterface.get(), 0u, gpgpuEngineInstances[0]);
osContextWin = osContext->get(); osContextWin = osContext->get();
ASSERT_TRUE(wddm->isInitialized()); ASSERT_TRUE(wddm->isInitialized());
} }
@@ -54,7 +54,7 @@ struct WddmFixtureWithMockGdiDll : public GmmEnvironmentFixture, public GdiDllFi
void init() { void init() {
EXPECT_TRUE(wddm->init()); EXPECT_TRUE(wddm->init());
osContext = std::make_unique<OsContext>(osInterface.get(), 0u); osContext = std::make_unique<OsContext>(osInterface.get(), 0u, gpgpuEngineInstances[0]);
osContextWin = osContext->get(); osContextWin = osContext->get();
ASSERT_TRUE(wddm->isInitialized()); ASSERT_TRUE(wddm->isInitialized());
} }

View File

@@ -0,0 +1,21 @@
/*
* Copyright (C) 2018 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "runtime/os_interface/windows/wddm_engine_mapper.h"
#include "test.h"
using namespace OCLRT;
TEST(WddmMapperTests, givenRcsEngineTypeWhenAskedForNodeOrdinalThenReturn3d) {
GPUNODE_ORDINAL gpuNode = WddmEngineMapper::engineNodeMap(EngineType::ENGINE_RCS);
GPUNODE_ORDINAL expected = GPUNODE_3D;
EXPECT_EQ(expected, gpuNode);
}
TEST(WddmMapperTests, givenNotSupportedEngineWhenAskedForNodeThenAbort) {
EXPECT_THROW(WddmEngineMapper::engineNodeMap(EngineType::ENGINE_BCS), std::exception);
}

View File

@@ -58,7 +58,7 @@ TEST(WddmMemoryManager, NonAssignable) {
TEST(WddmAllocationTest, givenAllocationIsTrimCandidateInOneOsContextWhenGettingTrimCandidatePositionThenReturnItsPositionAndUnusedPositionInOtherContexts) { TEST(WddmAllocationTest, givenAllocationIsTrimCandidateInOneOsContextWhenGettingTrimCandidatePositionThenReturnItsPositionAndUnusedPositionInOtherContexts) {
WddmAllocation allocation{nullptr, 0, nullptr, MemoryPool::MemoryNull, 3u, false}; WddmAllocation allocation{nullptr, 0, nullptr, MemoryPool::MemoryNull, 3u, false};
OsContext osContext{nullptr, 1u}; OsContext osContext(nullptr, 1u, gpgpuEngineInstances[0]);
allocation.setTrimCandidateListPosition(osContext.getContextId(), 700u); allocation.setTrimCandidateListPosition(osContext.getContextId(), 700u);
EXPECT_EQ(trimListUnusedPosition, allocation.getTrimCandidateListPosition(0u)); EXPECT_EQ(trimListUnusedPosition, allocation.getTrimCandidateListPosition(0u));
EXPECT_EQ(700u, allocation.getTrimCandidateListPosition(1u)); EXPECT_EQ(700u, allocation.getTrimCandidateListPosition(1u));
@@ -1195,16 +1195,16 @@ TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWithNoRegisteredOsContextsWh
} }
TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWithRegisteredOsContextWhenCallingIsMemoryBudgetExhaustedThenReturnFalse) { TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWithRegisteredOsContextWhenCallingIsMemoryBudgetExhaustedThenReturnFalse) {
memoryManager->createAndRegisterOsContext(); memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0]);
memoryManager->createAndRegisterOsContext(); memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0]);
memoryManager->createAndRegisterOsContext(); memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0]);
EXPECT_FALSE(memoryManager->isMemoryBudgetExhausted()); EXPECT_FALSE(memoryManager->isMemoryBudgetExhausted());
} }
TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWithRegisteredOsContextWithExhaustedMemoryBudgetWhenCallingIsMemoryBudgetExhaustedThenReturnTrue) { TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWithRegisteredOsContextWithExhaustedMemoryBudgetWhenCallingIsMemoryBudgetExhaustedThenReturnTrue) {
memoryManager->createAndRegisterOsContext(); memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0]);
memoryManager->createAndRegisterOsContext(); memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0]);
memoryManager->createAndRegisterOsContext(); memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0]);
memoryManager->getRegisteredOsContext(1)->get()->getResidencyController().setMemoryBudgetExhausted(); memoryManager->getRegisteredOsContext(1)->get()->getResidencyController().setMemoryBudgetExhausted();
EXPECT_TRUE(memoryManager->isMemoryBudgetExhausted()); EXPECT_TRUE(memoryManager->isMemoryBudgetExhausted());
} }

View File

@@ -56,7 +56,7 @@ class MockWddmMemoryManagerFixture : public GmmEnvironmentFixture {
executionEnvironment.osInterface->get()->setWddm(wddm); executionEnvironment.osInterface->get()->setWddm(wddm);
memoryManager = std::make_unique<MockWddmMemoryManager>(wddm, executionEnvironment); memoryManager = std::make_unique<MockWddmMemoryManager>(wddm, executionEnvironment);
memoryManager->createAndRegisterOsContext(); memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0]);
osContext = memoryManager->getRegisteredOsContext(0); osContext = memoryManager->getRegisteredOsContext(0);
osContext->incRefInternal(); osContext->incRefInternal();
@@ -120,7 +120,7 @@ class WddmMemoryManagerFixtureWithGmockWddm : public GmmEnvironmentFixture {
memoryManager = new (std::nothrow) MockWddmMemoryManager(wddm, executionEnvironment); memoryManager = new (std::nothrow) MockWddmMemoryManager(wddm, executionEnvironment);
//assert we have memory manager //assert we have memory manager
ASSERT_NE(nullptr, memoryManager); ASSERT_NE(nullptr, memoryManager);
memoryManager->createAndRegisterOsContext(); memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0]);
osContext = memoryManager->getRegisteredOsContext(0); osContext = memoryManager->getRegisteredOsContext(0);
osContext->incRefInternal(); osContext->incRefInternal();

View File

@@ -36,7 +36,7 @@ class WddmPreemptionTests : public Test<WddmFixtureWithMockGdiDll> {
PreemptionMode preemptionMode = PreemptionHelper::getDefaultPreemptionMode(hwInfoTest); PreemptionMode preemptionMode = PreemptionHelper::getDefaultPreemptionMode(hwInfoTest);
wddm->setPreemptionMode(preemptionMode); wddm->setPreemptionMode(preemptionMode);
wddm->init(); wddm->init();
osContext = std::make_unique<OsContext>(osInterface.get(), 0u); osContext = std::make_unique<OsContext>(osInterface.get(), 0u, gpgpuEngineInstances[0]);
osContextWin = osContext->get(); osContextWin = osContext->get();
} }

View File

@@ -91,7 +91,7 @@ struct WddmResidencyControllerWithMockWddmTest : public WddmResidencyControllerT
executionEnvironment->osInterface->get()->setWddm(wddm); executionEnvironment->osInterface->get()->setWddm(wddm);
memoryManager = std::make_unique<MockWddmMemoryManager>(wddm, *executionEnvironment); memoryManager = std::make_unique<MockWddmMemoryManager>(wddm, *executionEnvironment);
memoryManager->createAndRegisterOsContext(); memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0]);
osContext = memoryManager->getRegisteredOsContext(0); osContext = memoryManager->getRegisteredOsContext(0);
osContext->incRefInternal(); osContext->incRefInternal();
residencyController = &osContext->get()->getResidencyController(); residencyController = &osContext->get()->getResidencyController();
@@ -122,7 +122,7 @@ struct WddmResidencyControllerWithGdiAndMemoryManagerTest : ::testing::Test {
executionEnvironment->osInterface->get()->setWddm(wddm); executionEnvironment->osInterface->get()->setWddm(wddm);
memoryManager = std::make_unique<MockWddmMemoryManager>(wddm, *executionEnvironment); memoryManager = std::make_unique<MockWddmMemoryManager>(wddm, *executionEnvironment);
memoryManager->createAndRegisterOsContext(); memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0]);
osContext = memoryManager->getRegisteredOsContext(0); osContext = memoryManager->getRegisteredOsContext(0);
osContext->incRefInternal(); osContext->incRefInternal();

View File

@@ -1364,7 +1364,7 @@ HWTEST_F(PatchTokenTests, givenKernelRequiringConstantAllocationWhenMakeResident
EXPECT_EQ(*pDst, reinterpret_cast<uintptr_t>(constBuffGpuAddr)); EXPECT_EQ(*pDst, reinterpret_cast<uintptr_t>(constBuffGpuAddr));
pCommandStreamReceiver->makeSurfacePackNonResident(pCommandStreamReceiver->getResidencyAllocations(), *pDevice->getOsContext()); pCommandStreamReceiver->makeSurfacePackNonResident(pCommandStreamReceiver->getResidencyAllocations());
EXPECT_EQ(0u, pCommandStreamReceiver->residency.size()); EXPECT_EQ(0u, pCommandStreamReceiver->residency.size());
std::vector<Surface *> surfaces; std::vector<Surface *> surfaces;