From 0b839722f4a10851922eb4eb9b0ad2230f72f297 Mon Sep 17 00:00:00 2001 From: Piotr Fusik Date: Mon, 10 Dec 2018 10:30:39 +0100 Subject: [PATCH] Don't store preemption mode in Wddm. Change-Id: I6088e5fec65b6910fefb42ec9735181867c44a1b --- runtime/device/device.cpp | 4 +- runtime/device/device.h | 2 +- runtime/memory_manager/memory_manager.cpp | 4 +- runtime/memory_manager/memory_manager.h | 9 +--- .../os_interface/linux/os_context_linux.cpp | 2 +- runtime/os_interface/os_context.h | 6 ++- .../windows/device_factory_win.cpp | 4 +- .../os_interface/windows/os_context_win.cpp | 10 ++--- runtime/os_interface/windows/os_context_win.h | 2 +- runtime/os_interface/windows/wddm/wddm.cpp | 8 ++-- runtime/os_interface/windows/wddm/wddm.h | 17 ++------ .../windows/wddm_device_command_stream.inl | 1 - ...nd_stream_receiver_with_aub_dump_tests.cpp | 6 ++- unit_tests/device/device_win_timers_tests.cpp | 2 +- .../fixtures/memory_allocator_fixture.h | 7 +-- .../fixtures/memory_manager_fixture.cpp | 3 +- .../memory_manager/memory_manager_tests.cpp | 15 ++++--- unit_tests/memory_manager/surface_tests.cpp | 5 ++- unit_tests/mocks/mock_aub_csr.h | 3 +- unit_tests/mocks/mock_wddm.cpp | 4 +- unit_tests/mocks/mock_wddm.h | 3 +- .../linux/drm_command_stream_tests.cpp | 4 +- .../linux/drm_memory_manager_tests.cpp | 7 +-- .../linux/os_interface_linux_tests.cpp | 3 +- .../windows/device_command_stream_tests.cpp | 4 +- .../windows/driver_info_tests.cpp | 3 +- .../windows/gl/gl_os_sharing_tests.cpp | 20 +++++---- .../windows/os_interface_win_tests.cpp | 10 +++-- .../windows/os_time_win_tests.cpp | 2 +- .../os_interface/windows/wddm20_tests.cpp | 8 ++-- .../os_interface/windows/wddm23_tests.cpp | 12 +++--- .../windows/wddm_address_space_tests.cpp | 11 ++--- .../os_interface/windows/wddm_fixture.h | 11 +++-- .../windows/wddm_kmdaf_listener_tests.cpp | 3 +- .../windows/wddm_memory_manager_tests.cpp | 43 ++++++++++--------- .../windows/wddm_memory_manager_tests.h | 13 +++--- .../windows/wddm_preemption_tests.cpp | 7 ++- .../wddm_residency_controller_tests.cpp | 18 ++++---- 38 files changed, 153 insertions(+), 143 deletions(-) diff --git a/runtime/device/device.cpp b/runtime/device/device.cpp index 8b53229d95..521562ce91 100644 --- a/runtime/device/device.cpp +++ b/runtime/device/device.cpp @@ -166,7 +166,7 @@ bool Device::createDeviceImpl(const HardwareInfo *pHwInfo, Device &outDevice) { bool Device::createEngines(const HardwareInfo *pHwInfo, Device &outDevice) { auto executionEnvironment = outDevice.executionEnvironment; - EngineType defaultEngineType = getChosenEngineType(*pHwInfo); + auto defaultEngineType = getChosenEngineType(*pHwInfo); for (uint32_t deviceCsrIndex = 0; deviceCsrIndex < gpgpuEngineInstances.size(); deviceCsrIndex++) { if (!executionEnvironment->initializeCommandStreamReceiver(pHwInfo, outDevice.getDeviceIndex(), deviceCsrIndex)) { @@ -175,7 +175,7 @@ bool Device::createEngines(const HardwareInfo *pHwInfo, Device &outDevice) { executionEnvironment->initializeMemoryManager(outDevice.getEnabled64kbPages(), outDevice.getEnableLocalMemory(), outDevice.getDeviceIndex(), deviceCsrIndex); - auto osContext = executionEnvironment->memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[deviceCsrIndex]); + auto osContext = executionEnvironment->memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[deviceCsrIndex], outDevice.preemptionMode); auto commandStreamReceiver = executionEnvironment->commandStreamReceivers[outDevice.getDeviceIndex()][deviceCsrIndex].get(); commandStreamReceiver->setOsContext(*osContext); if (!commandStreamReceiver->initializeTagAllocation()) { diff --git a/runtime/device/device.h b/runtime/device/device.h index 7b81976363..c228e83a4b 100644 --- a/runtime/device/device.h +++ b/runtime/device/device.h @@ -115,7 +115,7 @@ class Device : public BaseObject<_cl_device_id> { SourceLevelDebugger *getSourceLevelDebugger() { return executionEnvironment->sourceLevelDebugger.get(); } ExecutionEnvironment *getExecutionEnvironment() const { return executionEnvironment; } const HardwareCapabilities &getHardwareCapabilities() const { return hardwareCapabilities; } - uint32_t getDeviceIndex() { return deviceIndex; } + uint32_t getDeviceIndex() const { return deviceIndex; } bool isFullRangeSvm() { return getHardwareInfo().capabilityTable.gpuAddressSpace == MemoryConstants::max48BitAddress; } diff --git a/runtime/memory_manager/memory_manager.cpp b/runtime/memory_manager/memory_manager.cpp index 1e676ff8f4..ed5037c3f4 100644 --- a/runtime/memory_manager/memory_manager.cpp +++ b/runtime/memory_manager/memory_manager.cpp @@ -162,12 +162,12 @@ bool MemoryManager::isMemoryBudgetExhausted() const { return false; } -OsContext *MemoryManager::createAndRegisterOsContext(EngineInstanceT engineType) { +OsContext *MemoryManager::createAndRegisterOsContext(EngineInstanceT engineType, PreemptionMode preemptionMode) { auto contextId = ++latestContextId; if (contextId + 1 > registeredOsContexts.size()) { registeredOsContexts.resize(contextId + 1); } - auto osContext = new OsContext(executionEnvironment.osInterface.get(), contextId, engineType); + auto osContext = new OsContext(executionEnvironment.osInterface.get(), contextId, engineType, preemptionMode); osContext->incRefInternal(); registeredOsContexts[contextId] = osContext; diff --git a/runtime/memory_manager/memory_manager.h b/runtime/memory_manager/memory_manager.h index 63e9c0c7e2..82babc562e 100644 --- a/runtime/memory_manager/memory_manager.h +++ b/runtime/memory_manager/memory_manager.h @@ -17,18 +17,13 @@ #include namespace OCLRT { -class AllocationsList; -class Device; class DeferredDeleter; class ExecutionEnvironment; class GraphicsAllocation; class HostPtrManager; class CommandStreamReceiver; class OsContext; -class OSInterface; -class AllocsTracker; -class MapBaseAllocationTracker; -class SVMAllocsManager; +enum class PreemptionMode : uint32_t; using CsrContainer = std::vector, EngineInstanceConstants::numGpgpuEngineInstances>>; @@ -248,7 +243,7 @@ class MemoryManager { ::alignedFree(ptr); } - OsContext *createAndRegisterOsContext(EngineInstanceT engineType); + OsContext *createAndRegisterOsContext(EngineInstanceT engineType, PreemptionMode preemptionMode); uint32_t getOsContextCount() { return static_cast(registeredOsContexts.size()); } CommandStreamReceiver *getDefaultCommandStreamReceiver(uint32_t deviceId) const; const CsrContainer &getCommandStreamReceivers() const; diff --git a/runtime/os_interface/linux/os_context_linux.cpp b/runtime/os_interface/linux/os_context_linux.cpp index f4ced61786..fabeba0393 100644 --- a/runtime/os_interface/linux/os_context_linux.cpp +++ b/runtime/os_interface/linux/os_context_linux.cpp @@ -13,7 +13,7 @@ namespace OCLRT { -OsContext::OsContext(OSInterface *osInterface, uint32_t contextId, EngineInstanceT engineType) +OsContext::OsContext(OSInterface *osInterface, uint32_t contextId, EngineInstanceT engineType, PreemptionMode preemptionMode) : contextId(contextId), engineType(engineType) { if (osInterface) { osContextImpl = std::make_unique(*osInterface->get()->getDrm(), engineType); diff --git a/runtime/os_interface/os_context.h b/runtime/os_interface/os_context.h index ae152f46fc..3450b5dfed 100644 --- a/runtime/os_interface/os_context.h +++ b/runtime/os_interface/os_context.h @@ -12,16 +12,18 @@ namespace OCLRT { class OSInterface; +enum class PreemptionMode : uint32_t; + class OsContext : public ReferenceTrackedObject { public: class OsContextImpl; - OsContext(OSInterface *osInterface, uint32_t contextId, EngineInstanceT engineType); + OsContext(OSInterface *osInterface, uint32_t contextId, EngineInstanceT engineType, PreemptionMode preemptionMode); ~OsContext() override; OsContextImpl *get() const { return osContextImpl.get(); }; - uint32_t getContextId() { return contextId; } + uint32_t getContextId() const { return contextId; } EngineInstanceT &getEngineType() { return engineType; } protected: diff --git a/runtime/os_interface/windows/device_factory_win.cpp b/runtime/os_interface/windows/device_factory_win.cpp index d86c65733a..aabbd5859d 100644 --- a/runtime/os_interface/windows/device_factory_win.cpp +++ b/runtime/os_interface/windows/device_factory_win.cpp @@ -7,6 +7,7 @@ #ifdef _WIN32 +#include "runtime/command_stream/preemption.h" #include "runtime/device/device.h" #include "runtime/os_interface/debug_settings_manager.h" #include "runtime/os_interface/device_factory.h" @@ -51,7 +52,8 @@ bool DeviceFactory::getDevices(HardwareInfo **pHWInfos, size_t &numDevices, Exec tempHwInfos.release(); executionEnvironment.initGmm(*pHWInfos); - bool success = executionEnvironment.osInterface->get()->getWddm()->init(); + auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(**pHWInfos); + bool success = executionEnvironment.osInterface->get()->getWddm()->init(preemptionMode); DEBUG_BREAK_IF(!success); return true; diff --git a/runtime/os_interface/windows/os_context_win.cpp b/runtime/os_interface/windows/os_context_win.cpp index b5f6f903a0..f449df6b1c 100644 --- a/runtime/os_interface/windows/os_context_win.cpp +++ b/runtime/os_interface/windows/os_context_win.cpp @@ -12,14 +12,14 @@ namespace OCLRT { -OsContextWin::OsContextImpl(Wddm &wddm, uint32_t osContextId, EngineInstanceT engineType) : wddm(wddm), residencyController(wddm, osContextId) { +OsContextWin::OsContextImpl(Wddm &wddm, uint32_t osContextId, EngineInstanceT engineType, PreemptionMode preemptionMode) : wddm(wddm), residencyController(wddm, osContextId) { UNRECOVERABLE_IF(!wddm.isInitialized()); auto wddmInterface = wddm.getWddmInterface(); - if (!wddm.createContext(context, engineType)) { + if (!wddm.createContext(context, engineType, preemptionMode)) { return; } if (wddmInterface->hwQueuesSupported()) { - if (!wddmInterface->createHwQueue(wddm.getPreemptionMode(), *this)) { + if (!wddmInterface->createHwQueue(preemptionMode, *this)) { return; } } @@ -31,10 +31,10 @@ OsContextWin::~OsContextImpl() { wddm.destroyContext(context); } -OsContext::OsContext(OSInterface *osInterface, uint32_t contextId, EngineInstanceT engineType) +OsContext::OsContext(OSInterface *osInterface, uint32_t contextId, EngineInstanceT engineType, PreemptionMode preemptionMode) : contextId(contextId), engineType(engineType) { if (osInterface) { - osContextImpl = std::make_unique(*osInterface->get()->getWddm(), contextId, engineType); + osContextImpl = std::make_unique(*osInterface->get()->getWddm(), contextId, engineType, preemptionMode); } } OsContext::~OsContext() = default; diff --git a/runtime/os_interface/windows/os_context_win.h b/runtime/os_interface/windows/os_context_win.h index 8c6425e578..1593a0ddf5 100644 --- a/runtime/os_interface/windows/os_context_win.h +++ b/runtime/os_interface/windows/os_context_win.h @@ -17,7 +17,7 @@ using OsContextWin = OsContext::OsContextImpl; class OsContext::OsContextImpl { public: OsContextImpl() = delete; - OsContextImpl(Wddm &wddm, uint32_t osContextId, EngineInstanceT engineType); + OsContextImpl(Wddm &wddm, uint32_t osContextId, EngineInstanceT engineType, PreemptionMode preemptionMode); ~OsContextImpl(); D3DKMT_HANDLE getContext() const { return context; diff --git a/runtime/os_interface/windows/wddm/wddm.cpp b/runtime/os_interface/windows/wddm/wddm.cpp index dd00152f2f..ec0e48ba7f 100644 --- a/runtime/os_interface/windows/wddm/wddm.cpp +++ b/runtime/os_interface/windows/wddm/wddm.cpp @@ -156,7 +156,7 @@ bool Wddm::destroyPagingQueue() { return true; } -bool Wddm::createDevice() { +bool Wddm::createDevice(PreemptionMode preemptionMode) { NTSTATUS status = STATUS_UNSUCCESSFUL; D3DKMT_CREATEDEVICE CreateDevice = {{0}}; if (adapter) { @@ -662,7 +662,7 @@ void Wddm::kmDafLock(WddmAllocation *wddmAllocation) { kmDafListener->notifyLock(featureTable->ftrKmdDaf, adapter, device, wddmAllocation->handle, 0, gdi->escape); } -bool Wddm::createContext(D3DKMT_HANDLE &context, EngineInstanceT engineType) { +bool Wddm::createContext(D3DKMT_HANDLE &context, EngineInstanceT engineType, PreemptionMode preemptionMode) { NTSTATUS status = STATUS_UNSUCCESSFUL; D3DKMT_CREATECONTEXTVIRTUAL CreateContext = {0}; CREATECONTEXT_PVTDATA PrivateData = {{0}}; @@ -911,7 +911,7 @@ bool Wddm::configureDeviceAddressSpace() { return gmmMemory->configureDevice(adapter, device, gdi->escape, svmSize, featureTable->ftrL3IACoherency, gfxPartition, minAddress); } -bool Wddm::init() { +bool Wddm::init(PreemptionMode preemptionMode) { if (gdi != nullptr && gdi->isInitialized() && !initialized) { if (!openAdapter()) { return false; @@ -928,7 +928,7 @@ bool Wddm::init() { } } - if (!createDevice()) { + if (!createDevice(preemptionMode)) { return false; } if (!createPagingQueue()) { diff --git a/runtime/os_interface/windows/wddm/wddm.h b/runtime/os_interface/windows/wddm/wddm.h index d43a63b998..a585b66810 100644 --- a/runtime/os_interface/windows/wddm/wddm.h +++ b/runtime/os_interface/windows/wddm/wddm.h @@ -28,11 +28,10 @@ namespace OCLRT { class WddmAllocation; class Gdi; class Gmm; -class LinearStream; class GmmPageTableMngr; -struct FeatureTable; struct WorkaroundTable; struct KmDafListener; +enum class PreemptionMode : uint32_t; using OsContextWin = OsContext::OsContextImpl; @@ -57,7 +56,7 @@ class Wddm { 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(AllocationStorageData *allocationStorageData, bool allocation32bit, bool use64kbPages); - MOCKABLE_VIRTUAL bool createContext(D3DKMT_HANDLE &context, EngineInstanceT engineType); + MOCKABLE_VIRTUAL bool createContext(D3DKMT_HANDLE &context, EngineInstanceT engineType, PreemptionMode preemptionMode); MOCKABLE_VIRTUAL void applyAdditionalContextFlags(CREATECONTEXT_PVTDATA &privateData); MOCKABLE_VIRTUAL bool freeGpuVirtualAddres(D3DGPU_VIRTUAL_ADDRESS &gpuPtr, uint64_t size); MOCKABLE_VIRTUAL NTSTATUS createAllocation(WddmAllocation *alloc); @@ -88,7 +87,7 @@ class Wddm { bool configureDeviceAddressSpace(); - bool init(); + bool init(PreemptionMode preemptionMode); bool isInitialized() const { return initialized; @@ -128,10 +127,6 @@ class Wddm { std::unique_ptr registryReader; - void setPreemptionMode(PreemptionMode mode) { - this->preemptionMode = mode; - } - GmmPageTableMngr *getPageTableManager() const { return pageTableManager.get(); } void resetPageTableManager(GmmPageTableMngr *newPageTableManager); bool updateAuxTable(D3DGPU_VIRTUAL_ADDRESS gpuVa, Gmm *gmm, bool map); @@ -142,9 +137,6 @@ class Wddm { WddmInterface *getWddmInterface() const { return wddmInterface.get(); } - PreemptionMode getPreemptionMode() const { - return preemptionMode; - } unsigned int readEnablePreemptionRegKey(); @@ -173,7 +165,6 @@ class Wddm { unsigned long hwContextId = 0; LUID adapterLuid; uintptr_t maximumApplicationAddress = 0; - PreemptionMode preemptionMode = PreemptionMode::Disabled; std::unique_ptr gmmMemory; uintptr_t minAddress = 0; @@ -181,7 +172,7 @@ class Wddm { MOCKABLE_VIRTUAL bool mapGpuVirtualAddressImpl(Gmm *gmm, D3DKMT_HANDLE handle, void *cpuPtr, D3DGPU_VIRTUAL_ADDRESS &gpuPtr, bool allocation32bit, bool use64kbPages, bool useHeap1); MOCKABLE_VIRTUAL bool openAdapter(); MOCKABLE_VIRTUAL bool waitOnGPU(D3DKMT_HANDLE context); - bool createDevice(); + bool createDevice(PreemptionMode preemptionMode); bool createPagingQueue(); bool destroyPagingQueue(); bool destroyDevice(); diff --git a/runtime/os_interface/windows/wddm_device_command_stream.inl b/runtime/os_interface/windows/wddm_device_command_stream.inl index 3b7575a01a..b5805246c1 100644 --- a/runtime/os_interface/windows/wddm_device_command_stream.inl +++ b/runtime/os_interface/windows/wddm_device_command_stream.inl @@ -41,7 +41,6 @@ WddmCommandStreamReceiver::WddmCommandStreamReceiver(const HardwareIn this->osInterface = executionEnvironment.osInterface.get(); PreemptionMode preemptionMode = PreemptionHelper::getDefaultPreemptionMode(hwInfoIn); - this->wddm->setPreemptionMode(preemptionMode); commandBufferHeader = new COMMAND_BUFFER_HEADER; *commandBufferHeader = CommandBufferHeader; diff --git a/unit_tests/command_stream/command_stream_receiver_with_aub_dump_tests.cpp b/unit_tests/command_stream/command_stream_receiver_with_aub_dump_tests.cpp index 8c4577821a..efc265077a 100644 --- a/unit_tests/command_stream/command_stream_receiver_with_aub_dump_tests.cpp +++ b/unit_tests/command_stream/command_stream_receiver_with_aub_dump_tests.cpp @@ -8,6 +8,7 @@ #include "unit_tests/libult/ult_command_stream_receiver.h" #include "runtime/command_stream/command_stream_receiver_with_aub_dump.h" #include "runtime/command_stream/command_stream_receiver_with_aub_dump.inl" +#include "runtime/command_stream/preemption.h" #include "runtime/execution_environment/execution_environment.h" #include "runtime/helpers/dispatch_info.h" #include "runtime/os_interface/os_context.h" @@ -110,7 +111,8 @@ struct CommandStreamReceiverWithAubDumpTest : public ::testing::TestWithParamcreateAndRegisterOsContext(getChosenEngineType(DEFAULT_TEST_PLATFORM::hwInfo)); + auto osContext = executionEnvironment.memoryManager->createAndRegisterOsContext( + getChosenEngineType(DEFAULT_TEST_PLATFORM::hwInfo), PreemptionHelper::getDefaultPreemptionMode(DEFAULT_TEST_PLATFORM::hwInfo)); csrWithAubDump->setOsContext(*osContext); if (csrWithAubDump->aubCSR) { csrWithAubDump->aubCSR->setOsContext(*osContext); @@ -132,7 +134,7 @@ HWTEST_F(CommandStreamReceiverWithAubDumpSimpleTest, givenCsrWithAubDumpWhenSett ExecutionEnvironment executionEnvironment; CommandStreamReceiverWithAUBDump> csrWithAubDump(*platformDevices[0], executionEnvironment); - OsContext osContext(nullptr, 0, gpgpuEngineInstances[0]); + OsContext osContext(nullptr, 0, gpgpuEngineInstances[0], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); csrWithAubDump.setOsContext(osContext); EXPECT_EQ(&osContext, &csrWithAubDump.getOsContext()); diff --git a/unit_tests/device/device_win_timers_tests.cpp b/unit_tests/device/device_win_timers_tests.cpp index ab4deada00..11997bab69 100644 --- a/unit_tests/device/device_win_timers_tests.cpp +++ b/unit_tests/device/device_win_timers_tests.cpp @@ -22,7 +22,7 @@ TEST_F(MockOSTimeWinTest, DynamicResolution) { auto wddmMock = std::unique_ptr(new WddmMock()); auto mDev = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); - bool error = wddmMock->init(); + bool error = wddmMock->init(mDev->getPreemptionMode()); std::unique_ptr timeWin(new MockOSTimeWin(wddmMock.get())); double res = 0.0; diff --git a/unit_tests/fixtures/memory_allocator_fixture.h b/unit_tests/fixtures/memory_allocator_fixture.h index 2914fd8a77..7634e0e8fd 100644 --- a/unit_tests/fixtures/memory_allocator_fixture.h +++ b/unit_tests/fixtures/memory_allocator_fixture.h @@ -7,10 +7,11 @@ #pragma once +#include "runtime/command_stream/preemption.h" +#include "runtime/execution_environment/execution_environment.h" +#include "runtime/memory_manager/os_agnostic_memory_manager.h" #include "unit_tests/fixtures/memory_management_fixture.h" #include "unit_tests/libult/create_command_stream.h" -#include "runtime/memory_manager/os_agnostic_memory_manager.h" -#include "runtime/execution_environment/execution_environment.h" using namespace OCLRT; @@ -23,7 +24,7 @@ class MemoryAllocatorFixture : public MemoryManagementFixture { memoryManager = new OsAgnosticMemoryManager(false, false, *executionEnvironment); executionEnvironment->memoryManager.reset(memoryManager); csr = memoryManager->getDefaultCommandStreamReceiver(0); - csr->setOsContext(*memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0])); + csr->setOsContext(*memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]))); } void TearDown() override { diff --git a/unit_tests/fixtures/memory_manager_fixture.cpp b/unit_tests/fixtures/memory_manager_fixture.cpp index 1bfc2e431c..16eead611c 100644 --- a/unit_tests/fixtures/memory_manager_fixture.cpp +++ b/unit_tests/fixtures/memory_manager_fixture.cpp @@ -5,6 +5,7 @@ * */ +#include "runtime/command_stream/preemption.h" #include "runtime/os_interface/os_context.h" #include "unit_tests/fixtures/memory_manager_fixture.h" #include "unit_tests/mocks/mock_csr.h" @@ -20,7 +21,7 @@ void MemoryManagerWithCsrFixture::SetUp() { executionEnvironment.commandStreamReceivers.resize(1); executionEnvironment.commandStreamReceivers[0][0].reset(csr); - csr->setOsContext(*memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0])); + csr->setOsContext(*memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]))); } void MemoryManagerWithCsrFixture::TearDown() { diff --git a/unit_tests/memory_manager/memory_manager_tests.cpp b/unit_tests/memory_manager/memory_manager_tests.cpp index edd5d34461..f8e23466de 100644 --- a/unit_tests/memory_manager/memory_manager_tests.cpp +++ b/unit_tests/memory_manager/memory_manager_tests.cpp @@ -5,6 +5,7 @@ * */ +#include "runtime/command_stream/preemption.h" #include "runtime/event/event.h" #include "runtime/helpers/dispatch_info.h" #include "runtime/helpers/kernel_commands.h" @@ -195,7 +196,7 @@ TEST_F(MemoryAllocatorTest, allocateSystemAligned) { TEST_F(MemoryAllocatorTest, allocateGraphics) { unsigned int alignment = 4096; - memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0]); + memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); auto allocation = memoryManager->allocateGraphicsMemory(sizeof(char)); ASSERT_NE(nullptr, allocation); @@ -1196,7 +1197,7 @@ TEST_F(MemoryManagerWithCsrTest, givenAllocationThatWasUsedAndIsCompletedWhenche } TEST_F(MemoryManagerWithCsrTest, givenAllocationThatWasUsedAndIsNotCompletedWhencheckGpuUsageAndDestroyGraphicsAllocationsIsCalledThenItIsAddedToTemporaryAllocationList) { - memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0]); + memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); auto usedAllocationAndNotGpuCompleted = memoryManager->allocateGraphicsMemory(4096); auto tagAddress = csr->getTagAddress(); @@ -1368,7 +1369,7 @@ TEST(GraphicsAllocation, givenSharedHandleBasedConstructorWhenGraphicsAllocation TEST(ResidencyDataTest, givenOsContextWhenItIsRegisteredToMemoryManagerThenRefCountIncreases) { ExecutionEnvironment executionEnvironment; MockMemoryManager memoryManager(false, false, executionEnvironment); - memoryManager.createAndRegisterOsContext(gpgpuEngineInstances[0]); + memoryManager.createAndRegisterOsContext(gpgpuEngineInstances[0], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); EXPECT_EQ(1u, memoryManager.getOsContextCount()); EXPECT_EQ(1, memoryManager.registeredOsContexts[0]->getRefInternalCount()); } @@ -1376,8 +1377,8 @@ TEST(ResidencyDataTest, givenOsContextWhenItIsRegisteredToMemoryManagerThenRefCo TEST(ResidencyDataTest, givenTwoOsContextsWhenTheyAreRegistredFromHigherToLowerThenProperSizeIsReturned) { ExecutionEnvironment executionEnvironment; MockMemoryManager memoryManager(false, false, executionEnvironment); - memoryManager.createAndRegisterOsContext(gpgpuEngineInstances[0]); - memoryManager.createAndRegisterOsContext(gpgpuEngineInstances[1]); + memoryManager.createAndRegisterOsContext(gpgpuEngineInstances[0], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); + memoryManager.createAndRegisterOsContext(gpgpuEngineInstances[1], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); EXPECT_EQ(2u, memoryManager.getOsContextCount()); EXPECT_EQ(1, memoryManager.registeredOsContexts[0]->getRefInternalCount()); EXPECT_EQ(1, memoryManager.registeredOsContexts[1]->getRefInternalCount()); @@ -1390,8 +1391,8 @@ TEST(ResidencyDataTest, givenResidencyDataWhenUpdateCompletionDataIsCalledThenIt MockResidencyData residency; - OsContext osContext(nullptr, 0u, gpgpuEngineInstances[0]); - OsContext osContext2(nullptr, 1u, gpgpuEngineInstances[1]); + OsContext osContext(nullptr, 0u, gpgpuEngineInstances[0], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); + OsContext osContext2(nullptr, 1u, gpgpuEngineInstances[1], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); auto lastFenceValue = 45llu; auto lastFenceValue2 = 23llu; diff --git a/unit_tests/memory_manager/surface_tests.cpp b/unit_tests/memory_manager/surface_tests.cpp index 30f88c3426..bb1b3ed28b 100644 --- a/unit_tests/memory_manager/surface_tests.cpp +++ b/unit_tests/memory_manager/surface_tests.cpp @@ -9,8 +9,9 @@ #include "test.h" #include "unit_tests/mocks/mock_buffer.h" #include "unit_tests/mocks/mock_csr.h" -#include "runtime/memory_manager/surface.h" +#include "runtime/command_stream/preemption.h" #include "runtime/memory_manager/graphics_allocation.h" +#include "runtime/memory_manager/surface.h" #include "hw_cmds.h" #include @@ -61,7 +62,7 @@ HWTEST_TYPED_TEST(SurfaceTest, GivenSurfaceWhenInterfaceIsUsedThenSurfaceBehaves MockCsr *csr = new MockCsr(execStamp, executionEnvironment); executionEnvironment.commandStreamReceivers[0][0].reset(csr); executionEnvironment.memoryManager.reset(csr->createMemoryManager(false, false)); - csr->setOsContext(*executionEnvironment.memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0])); + csr->setOsContext(*executionEnvironment.memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]))); Surface *surface = createSurface::Create(this->data, &this->buffer, diff --git a/unit_tests/mocks/mock_aub_csr.h b/unit_tests/mocks/mock_aub_csr.h index 13209af523..c6639d2bc1 100644 --- a/unit_tests/mocks/mock_aub_csr.h +++ b/unit_tests/mocks/mock_aub_csr.h @@ -8,6 +8,7 @@ #pragma once #include "runtime/command_stream/aub_command_stream_receiver_hw.h" +#include "runtime/command_stream/preemption.h" #include "runtime/execution_environment/execution_environment.h" #include "runtime/helpers/hw_info.h" #include "gmock/gmock.h" @@ -152,7 +153,7 @@ std::unique_ptr getEnvironment(bool createTagAllocation executionEnvironment->commandStreamReceivers[0][0]->initializeTagAllocation(); } - auto osContext = executionEnvironment->memoryManager->createAndRegisterOsContext(getChosenEngineType(*platformDevices[0])); + auto osContext = executionEnvironment->memoryManager->createAndRegisterOsContext(getChosenEngineType(*platformDevices[0]), PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); executionEnvironment->commandStreamReceivers[0][0]->setOsContext(*osContext); std::unique_ptr aubExecutionEnvironment(new AubExecutionEnvironment); diff --git a/unit_tests/mocks/mock_wddm.cpp b/unit_tests/mocks/mock_wddm.cpp index f713fba4ae..c821c31791 100644 --- a/unit_tests/mocks/mock_wddm.cpp +++ b/unit_tests/mocks/mock_wddm.cpp @@ -103,9 +103,9 @@ bool WddmMock::openSharedHandle(D3DKMT_HANDLE handle, WddmAllocation *alloc) { } } -bool WddmMock::createContext(D3DKMT_HANDLE &context, EngineInstanceT engineType) { +bool WddmMock::createContext(D3DKMT_HANDLE &context, EngineInstanceT engineType, PreemptionMode preemptionMode) { createContextResult.called++; - return createContextResult.success = Wddm::createContext(context, engineType); + return createContextResult.success = Wddm::createContext(context, engineType, preemptionMode); } void WddmMock::applyAdditionalContextFlags(CREATECONTEXT_PVTDATA &privateData) { diff --git a/unit_tests/mocks/mock_wddm.h b/unit_tests/mocks/mock_wddm.h index b437539b8f..b85fe36a83 100644 --- a/unit_tests/mocks/mock_wddm.h +++ b/unit_tests/mocks/mock_wddm.h @@ -43,7 +43,6 @@ class WddmMock : public Wddm { using Wddm::gmmMemory; using Wddm::pagingFenceAddress; using Wddm::pagingQueue; - using Wddm::preemptionMode; using Wddm::wddmInterface; WddmMock() : Wddm(){}; @@ -58,7 +57,7 @@ class WddmMock : public Wddm { bool destroyAllocations(D3DKMT_HANDLE *handles, uint32_t allocationCount, D3DKMT_HANDLE resourceHandle) override; bool destroyAllocation(WddmAllocation *alloc, OsContextWin *osContext); bool openSharedHandle(D3DKMT_HANDLE handle, WddmAllocation *alloc) override; - bool createContext(D3DKMT_HANDLE &context, EngineInstanceT engineType) override; + bool createContext(D3DKMT_HANDLE &context, EngineInstanceT engineType, PreemptionMode preemptionMode) override; void applyAdditionalContextFlags(CREATECONTEXT_PVTDATA &privateData) override; bool destroyContext(D3DKMT_HANDLE context) override; bool queryAdapterInfo() override; diff --git a/unit_tests/os_interface/linux/drm_command_stream_tests.cpp b/unit_tests/os_interface/linux/drm_command_stream_tests.cpp index 29a5f17318..b805eedb38 100644 --- a/unit_tests/os_interface/linux/drm_command_stream_tests.cpp +++ b/unit_tests/os_interface/linux/drm_command_stream_tests.cpp @@ -41,7 +41,7 @@ class DrmCommandStreamFixture { executionEnvironment.osInterface = std::make_unique(); executionEnvironment.osInterface->get()->setDrm(mock.get()); - osContext = std::make_unique(executionEnvironment.osInterface.get(), 0u, gpgpuEngineInstances[0]); + osContext = std::make_unique(executionEnvironment.osInterface.get(), 0u, gpgpuEngineInstances[0], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); csr = new DrmCommandStreamReceiver(*platformDevices[0], executionEnvironment, gemCloseWorkerMode::gemCloseWorkerActive); @@ -673,7 +673,7 @@ class DrmCommandStreamEnhancedFixture mock = new DrmMockCustom(); executionEnvironment->osInterface = std::make_unique(); executionEnvironment->osInterface->get()->setDrm(mock); - osContext = std::make_unique(executionEnvironment->osInterface.get(), 0u, gpgpuEngineInstances[0]); + osContext = std::make_unique(executionEnvironment->osInterface.get(), 0u, gpgpuEngineInstances[0], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); tCsr = new TestedDrmCommandStreamReceiver(*executionEnvironment); csr = tCsr; diff --git a/unit_tests/os_interface/linux/drm_memory_manager_tests.cpp b/unit_tests/os_interface/linux/drm_memory_manager_tests.cpp index b3107c01f8..1885681e74 100644 --- a/unit_tests/os_interface/linux/drm_memory_manager_tests.cpp +++ b/unit_tests/os_interface/linux/drm_memory_manager_tests.cpp @@ -6,8 +6,9 @@ */ #include "hw_cmds.h" -#include "runtime/command_stream/linear_stream.h" #include "runtime/command_stream/device_command_stream.h" +#include "runtime/command_stream/linear_stream.h" +#include "runtime/command_stream/preemption.h" #include "runtime/event/event.h" #include "runtime/helpers/aligned_memory.h" #include "runtime/helpers/ptr_math.h" @@ -1624,7 +1625,7 @@ TEST_F(DrmMemoryManagerTest, givenTwoGraphicsAllocationsThatShareTheSameBufferOb auto testedCsr = new TestedDrmCommandStreamReceiver(*executionEnvironment); executionEnvironment->commandStreamReceivers.resize(1); executionEnvironment->commandStreamReceivers[0][0].reset(testedCsr); - testedCsr->setOsContext(*memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0])); + testedCsr->setOsContext(*memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]))); testedCsr->makeResident(*graphicsAllocation); testedCsr->makeResident(*graphicsAllocation2); @@ -1653,7 +1654,7 @@ TEST_F(DrmMemoryManagerTest, givenTwoGraphicsAllocationsThatDoesnShareTheSameBuf auto testedCsr = new TestedDrmCommandStreamReceiver(*executionEnvironment); executionEnvironment->commandStreamReceivers.resize(1); executionEnvironment->commandStreamReceivers[0][0].reset(testedCsr); - testedCsr->setOsContext(*memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0])); + testedCsr->setOsContext(*memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]))); testedCsr->makeResident(*graphicsAllocation); testedCsr->makeResident(*graphicsAllocation2); diff --git a/unit_tests/os_interface/linux/os_interface_linux_tests.cpp b/unit_tests/os_interface/linux/os_interface_linux_tests.cpp index be640eb587..8b8e734db5 100644 --- a/unit_tests/os_interface/linux/os_interface_linux_tests.cpp +++ b/unit_tests/os_interface/linux/os_interface_linux_tests.cpp @@ -5,6 +5,7 @@ * */ +#include "runtime/command_stream/preemption.h" #include "runtime/os_interface/linux/os_context_linux.h" #include "runtime/os_interface/linux/os_interface.h" #include "unit_tests/os_interface/linux/drm_mock.h" @@ -26,7 +27,7 @@ TEST(OsContextTest, givenDrmWhenOsContextIsCreatedThenImplIsAvailable) { OSInterface osInterface; osInterface.get()->setDrm(&drmMock); - auto osContext = std::make_unique(&osInterface, 0u, gpgpuEngineInstances[0]); + auto osContext = std::make_unique(&osInterface, 0u, gpgpuEngineInstances[0], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); EXPECT_NE(nullptr, osContext->get()); } } // namespace OCLRT diff --git a/unit_tests/os_interface/windows/device_command_stream_tests.cpp b/unit_tests/os_interface/windows/device_command_stream_tests.cpp index f1d9d05362..1c3dcd1db3 100644 --- a/unit_tests/os_interface/windows/device_command_stream_tests.cpp +++ b/unit_tests/os_interface/windows/device_command_stream_tests.cpp @@ -249,7 +249,7 @@ TEST(WddmPreemptionHeaderTests, givenWddmCommandStreamReceiverWhenPreemptionIsOf std::make_unique>(hwInfo[0], *executionEnvironment); executionEnvironment->memoryManager.reset(executionEnvironment->commandStreamReceivers[0][0]->createMemoryManager(false, false)); executionEnvironment->commandStreamReceivers[0][0]->overrideDispatchPolicy(DispatchMode::ImmediateDispatch); - OsContext osContext(executionEnvironment->osInterface.get(), 0u, gpgpuEngineInstances[0]); + OsContext osContext(executionEnvironment->osInterface.get(), 0u, gpgpuEngineInstances[0], PreemptionHelper::getDefaultPreemptionMode(*hwInfo)); executionEnvironment->commandStreamReceivers[0][0]->setOsContext(osContext); auto commandBuffer = executionEnvironment->memoryManager->allocateGraphicsMemory(4096); @@ -274,7 +274,7 @@ TEST(WddmPreemptionHeaderTests, givenWddmCommandStreamReceiverWhenPreemptionIsOn *executionEnvironment); executionEnvironment->memoryManager.reset(executionEnvironment->commandStreamReceivers[0][0]->createMemoryManager(false, false)); executionEnvironment->commandStreamReceivers[0][0]->overrideDispatchPolicy(DispatchMode::ImmediateDispatch); - OsContext osContext(executionEnvironment->osInterface.get(), 0u, gpgpuEngineInstances[0]); + OsContext osContext(executionEnvironment->osInterface.get(), 0u, gpgpuEngineInstances[0], PreemptionHelper::getDefaultPreemptionMode(*hwInfo)); executionEnvironment->commandStreamReceivers[0][0]->setOsContext(osContext); auto commandBuffer = executionEnvironment->memoryManager->allocateGraphicsMemory(4096); diff --git a/unit_tests/os_interface/windows/driver_info_tests.cpp b/unit_tests/os_interface/windows/driver_info_tests.cpp index b95cef234d..8eafb36ae6 100644 --- a/unit_tests/os_interface/windows/driver_info_tests.cpp +++ b/unit_tests/os_interface/windows/driver_info_tests.cpp @@ -5,6 +5,7 @@ * */ +#include "runtime/command_stream/preemption.h" #include "runtime/os_interface/windows/driver_info.h" #include "runtime/os_interface/windows/registry_reader.h" #include "runtime/os_interface/windows/os_interface.h" @@ -43,7 +44,7 @@ CommandStreamReceiver *createMockCommandStreamReceiver(const HardwareInfo &hwInf OSInterface *osInterface = new OSInterface(); executionEnvironment.osInterface.reset(osInterface); auto wddm = new WddmMock(); - wddm->init(); + wddm->init(PreemptionHelper::getDefaultPreemptionMode(hwInfoIn)); osInterface->get()->setWddm(wddm); csr->setOSInterface(osInterface); return csr; diff --git a/unit_tests/os_interface/windows/gl/gl_os_sharing_tests.cpp b/unit_tests/os_interface/windows/gl/gl_os_sharing_tests.cpp index cb21500d0f..9991d5f583 100644 --- a/unit_tests/os_interface/windows/gl/gl_os_sharing_tests.cpp +++ b/unit_tests/os_interface/windows/gl/gl_os_sharing_tests.cpp @@ -133,7 +133,7 @@ TEST_F(GlArbSyncEventOsTest, WhenCreateSynchronizationObjectSucceedsThenAllHAndl }; CreateSyncObjectMock::reset(); - wddm->init(); + wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); gdi->createSynchronizationObject.mFunc = CreateSyncObjectMock::createSynchObject; gdi->createSynchronizationObject2.mFunc = CreateSyncObjectMock::createSynchObject2; auto ret = setupArbSyncObject(sharing, osInterface, syncInfo); @@ -183,7 +183,7 @@ TEST_F(GlArbSyncEventOsTest, GivenNewGlSyncInfoWhenCreateSynchronizationObjectFa } }; CreateSyncObjectMock::reset(); - wddm->init(); + wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); gdi->createSynchronizationObject.mFunc = CreateSyncObjectMock::createSynchObject; gdi->createSynchronizationObject2.mFunc = CreateSyncObjectMock::createSynchObject2; @@ -207,7 +207,7 @@ TEST_F(GlArbSyncEventOsTest, GivenNewGlSyncInfoWhenCreateEventFailsThenSetupArbS auto wddm = new WddmMock(); auto gdi = new MockGdi(); wddm->gdi.reset(gdi); - wddm->init(); + wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); mockOsInterface.get()->setWddm(wddm); @@ -235,7 +235,7 @@ TEST_F(GlArbSyncEventOsTest, GivenInvalidGlSyncInfoWhenCleanupArbSyncObjectIsCal auto wddm = new WddmMock(); auto gdi = new MockGdi(); wddm->gdi.reset(gdi); - wddm->init(); + wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); MockOSInterface mockOsInterface; MockOSInterfaceImpl *mockOsInterfaceImpl = static_cast(mockOsInterface.get()); @@ -264,7 +264,7 @@ TEST_F(GlArbSyncEventOsTest, GivenValidGlSyncInfoWhenCleanupArbSyncObjectIsCalle auto wddm = new WddmMock(); auto gdi = new MockGdi(); wddm->gdi.reset(gdi); - wddm->init(); + wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); MockOSInterface mockOsInterface; MockOSInterfaceImpl *mockOsInterfaceImpl = static_cast(mockOsInterface.get()); @@ -322,8 +322,9 @@ TEST_F(GlArbSyncEventOsTest, GivenCallToSignalArbSyncObjectWhenSignalSynchroniza } }; FailSignalSyncObjectMock::reset(); - wddm->init(); - OsContext osContext(&osInterface, 0u, gpgpuEngineInstances[0]); + auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]); + wddm->init(preemptionMode); + OsContext osContext(&osInterface, 0u, gpgpuEngineInstances[0], preemptionMode); CL_GL_SYNC_INFO syncInfo = {}; syncInfo.serverSynchronizationObject = 0x5cU; @@ -380,8 +381,9 @@ TEST_F(GlArbSyncEventOsTest, GivenCallToSignalArbSyncObjectWhenSignalSynchroniza } }; FailSignalSyncObjectMock::reset(); - wddm->init(); - OsContext osContext(&osInterface, 0u, gpgpuEngineInstances[0]); + auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]); + wddm->init(preemptionMode); + OsContext osContext(&osInterface, 0u, gpgpuEngineInstances[0], preemptionMode); CL_GL_SYNC_INFO syncInfo = {}; syncInfo.submissionSynchronizationObject = 0x7cU; diff --git a/unit_tests/os_interface/windows/os_interface_win_tests.cpp b/unit_tests/os_interface/windows/os_interface_win_tests.cpp index 246fcea1c3..6310b8743e 100644 --- a/unit_tests/os_interface/windows/os_interface_win_tests.cpp +++ b/unit_tests/os_interface/windows/os_interface_win_tests.cpp @@ -29,16 +29,17 @@ TEST(OsContextTest, givenWddmWhenCreateOsContextBeforeInitWddmThenOsContextIsNot auto wddm = new WddmMock; OSInterface osInterface; osInterface.get()->setWddm(wddm); - EXPECT_THROW(auto osContext = std::make_unique(&osInterface, 0u, gpgpuEngineInstances[0]), std::exception); + EXPECT_THROW(auto osContext = std::make_unique(&osInterface, 0u, gpgpuEngineInstances[0], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])), std::exception); } TEST(OsContextTest, givenWddmWhenCreateOsContextAfterInitWddmThenOsContextIsInitializedAndTrimCallbackIsRegistered) { auto wddm = new WddmMock; OSInterface osInterface; osInterface.get()->setWddm(wddm); - wddm->init(); + auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]); + wddm->init(preemptionMode); EXPECT_EQ(0u, wddm->registerTrimCallbackResult.called); - auto osContext = std::make_unique(&osInterface, 0u, gpgpuEngineInstances[0]); + auto osContext = std::make_unique(&osInterface, 0u, gpgpuEngineInstances[0], preemptionMode); EXPECT_NE(nullptr, osContext->get()); EXPECT_TRUE(osContext->get()->isInitialized()); EXPECT_EQ(osContext->get()->getWddm(), wddm); @@ -46,6 +47,7 @@ TEST(OsContextTest, givenWddmWhenCreateOsContextAfterInitWddmThenOsContextIsInit } TEST(OsContextTest, whenCreateOsContextWithoutOsInterfaceThenOsContextImplIsNotAvailable) { - auto osContext = std::make_unique(nullptr, 0u, gpgpuEngineInstances[0]); + auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]); + auto osContext = std::make_unique(nullptr, 0u, gpgpuEngineInstances[0], preemptionMode); EXPECT_EQ(nullptr, osContext->get()); } diff --git a/unit_tests/os_interface/windows/os_time_win_tests.cpp b/unit_tests/os_interface/windows/os_time_win_tests.cpp index 8f244e7a74..5211c625ef 100644 --- a/unit_tests/os_interface/windows/os_time_win_tests.cpp +++ b/unit_tests/os_interface/windows/os_time_win_tests.cpp @@ -84,7 +84,7 @@ TEST(OSTimeWinTests, givenNoOSInterfaceWhenGetCpuGpuTimeThenReturnsError) { TEST(OSTimeWinTests, givenOSInterfaceWhenGetCpuGpuTimeThenReturnsSuccess) { auto wddm = new WddmMock; - wddm->init(); + wddm->init(PreemptionHelper::getDefaultPreemptionMode(DEFAULT_TEST_PLATFORM::hwInfo)); TimeStampData CPUGPUTime01 = {0}; TimeStampData CPUGPUTime02 = {0}; std::unique_ptr osInterface(new OSInterface()); diff --git a/unit_tests/os_interface/windows/wddm20_tests.cpp b/unit_tests/os_interface/windows/wddm20_tests.cpp index 2087a4fb3a..dcb51994a4 100644 --- a/unit_tests/os_interface/windows/wddm20_tests.cpp +++ b/unit_tests/os_interface/windows/wddm20_tests.cpp @@ -62,7 +62,7 @@ TEST_F(Wddm20Tests, givenMinWindowsAddressWhenWddmIsInitializedThenWddmUseThisAd TEST_F(Wddm20Tests, doubleCreation) { EXPECT_EQ(1u, wddm->createContextResult.called); - auto error = wddm->init(); + auto error = wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); EXPECT_EQ(1u, wddm->createContextResult.called); EXPECT_TRUE(error); @@ -480,7 +480,7 @@ HWTEST_F(Wddm20InstrumentationTest, configureDeviceAddressSpaceOnInit) { FtrL3IACoherency)) .Times(1) .WillRepeatedly(::testing::Return(true)); - wddm->init(); + wddm->init(PreemptionHelper::getDefaultPreemptionMode(hwInfo)); EXPECT_TRUE(wddm->isInitialized()); } @@ -561,7 +561,7 @@ TEST_F(Wddm20WithMockGdiDllTests, whenCreateContextIsCalledThenDisableHwQueues) } TEST_F(Wddm20Tests, whenCreateHwQueueIsCalledThenAlwaysReturnFalse) { - EXPECT_FALSE(wddm->wddmInterface->createHwQueue(wddm->preemptionMode, *osContextWin)); + EXPECT_FALSE(wddm->wddmInterface->createHwQueue(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]), *osContextWin)); } TEST_F(Wddm20Tests, whenWddmIsInitializedThenGdiDoesntHaveHwQueueDDIs) { @@ -782,7 +782,7 @@ TEST_F(Wddm20Tests, givenReadOnlyMemoryWhenCreateAllocationFailsWithNoVideoMemor } TEST_F(Wddm20Tests, whenContextIsInitializedThenApplyAdditionalContextFlagsIsCalled) { - auto result = wddm->init(); + auto result = wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); EXPECT_TRUE(result); EXPECT_EQ(1u, wddm->applyAdditionalContextFlagsResult.called); } diff --git a/unit_tests/os_interface/windows/wddm23_tests.cpp b/unit_tests/os_interface/windows/wddm23_tests.cpp index d161e00ab2..cf8358532e 100644 --- a/unit_tests/os_interface/windows/wddm23_tests.cpp +++ b/unit_tests/os_interface/windows/wddm23_tests.cpp @@ -5,6 +5,7 @@ * */ +#include "runtime/command_stream/preemption.h" #include "runtime/memory_manager/memory_constants.h" #include "runtime/os_interface/windows/gdi_interface.h" #include "unit_tests/fixtures/gmm_environment_fixture.h" @@ -34,8 +35,9 @@ struct Wddm23TestsWithoutWddmInit : public ::testing::Test, GdiDllFixture, publi } void init() { - EXPECT_TRUE(wddm->init()); - osContext = std::make_unique(osInterface.get(), 0u, gpgpuEngineInstances[0]); + auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]); + EXPECT_TRUE(wddm->init(preemptionMode)); + osContext = std::make_unique(osInterface.get(), 0u, gpgpuEngineInstances[0], preemptionMode); osContextWin = osContext->get(); } @@ -65,12 +67,10 @@ TEST_F(Wddm23Tests, whenCreateContextIsCalledThenEnableHwQueues) { } TEST_F(Wddm23Tests, givenPreemptionModeWhenCreateHwQueueCalledThenSetGpuTimeoutIfEnabled) { - wddm->setPreemptionMode(PreemptionMode::Disabled); - wddm->wddmInterface->createHwQueue(wddm->preemptionMode, *osContextWin); + wddm->wddmInterface->createHwQueue(PreemptionMode::Disabled, *osContextWin); EXPECT_EQ(0u, getCreateHwQueueDataFcn()->Flags.DisableGpuTimeout); - wddm->setPreemptionMode(PreemptionMode::MidBatch); - wddm->wddmInterface->createHwQueue(wddm->preemptionMode, *osContextWin); + wddm->wddmInterface->createHwQueue(PreemptionMode::MidBatch, *osContextWin); EXPECT_EQ(1u, getCreateHwQueueDataFcn()->Flags.DisableGpuTimeout); } diff --git a/unit_tests/os_interface/windows/wddm_address_space_tests.cpp b/unit_tests/os_interface/windows/wddm_address_space_tests.cpp index afd86e50c9..ebfaa7be15 100644 --- a/unit_tests/os_interface/windows/wddm_address_space_tests.cpp +++ b/unit_tests/os_interface/windows/wddm_address_space_tests.cpp @@ -5,6 +5,7 @@ * */ +#include "runtime/command_stream/preemption.h" #include "unit_tests/fixtures/gmm_environment_fixture.h" #include "unit_tests/mocks/mock_wddm.h" #include "test.h" @@ -60,7 +61,7 @@ TEST_F(WddmReserveAddressTest, givenWddmWhenFirstIsSuccessfulThenReturnReserveAd size_t size = 0x1000; void *reserve = nullptr; - bool ret = wddm->init(); + bool ret = wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); EXPECT_TRUE(ret); wddm->returnGood = 1; @@ -77,7 +78,7 @@ TEST_F(WddmReserveAddressTest, givenWddmWhenFirstIsNullThenReturnNull) { size_t size = 0x1000; void *reserve = nullptr; - bool ret = wddm->init(); + bool ret = wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); EXPECT_TRUE(ret); uintptr_t expectedReserve = 0; ret = wddm->reserveValidAddressRange(size, reserve); @@ -90,7 +91,7 @@ TEST_F(WddmReserveAddressTest, givenWddmWhenFirstIsInvalidSecondSuccessfulThenRe size_t size = 0x1000; void *reserve = nullptr; - bool ret = wddm->init(); + bool ret = wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); EXPECT_TRUE(ret); wddm->returnInvalidCount = 1; @@ -107,7 +108,7 @@ TEST_F(WddmReserveAddressTest, givenWddmWhenSecondIsInvalidThirdSuccessfulThenRe size_t size = 0x1000; void *reserve = nullptr; - bool ret = wddm->init(); + bool ret = wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); EXPECT_TRUE(ret); wddm->returnInvalidCount = 2; @@ -124,7 +125,7 @@ TEST_F(WddmReserveAddressTest, givenWddmWhenFirstIsInvalidSecondNullThenReturnSe size_t size = 0x1000; void *reserve = nullptr; - bool ret = wddm->init(); + bool ret = wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); EXPECT_TRUE(ret); wddm->returnInvalidCount = 2; diff --git a/unit_tests/os_interface/windows/wddm_fixture.h b/unit_tests/os_interface/windows/wddm_fixture.h index a5d15a0397..5308232b0c 100644 --- a/unit_tests/os_interface/windows/wddm_fixture.h +++ b/unit_tests/os_interface/windows/wddm_fixture.h @@ -7,6 +7,7 @@ #pragma once +#include "runtime/command_stream/preemption.h" #include "runtime/os_interface/windows/gdi_interface.h" #include "runtime/os_interface/windows/os_interface.h" #include "unit_tests/fixtures/gmm_environment_fixture.h" @@ -25,8 +26,9 @@ struct WddmFixture : public GmmEnvironmentFixture { osInterface->get()->setWddm(wddm); gdi = new MockGdi(); wddm->gdi.reset(gdi); - wddm->init(); - osContext = std::make_unique(osInterface.get(), 0u, gpgpuEngineInstances[0]); + auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]); + wddm->init(preemptionMode); + osContext = std::make_unique(osInterface.get(), 0u, gpgpuEngineInstances[0], preemptionMode); osContextWin = osContext->get(); ASSERT_TRUE(wddm->isInitialized()); } @@ -53,8 +55,9 @@ struct WddmFixtureWithMockGdiDll : public GmmEnvironmentFixture, public GdiDllFi } void init() { - EXPECT_TRUE(wddm->init()); - osContext = std::make_unique(osInterface.get(), 0u, gpgpuEngineInstances[0]); + auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]); + EXPECT_TRUE(wddm->init(preemptionMode)); + osContext = std::make_unique(osInterface.get(), 0u, gpgpuEngineInstances[0], preemptionMode); osContextWin = osContext->get(); ASSERT_TRUE(wddm->isInitialized()); } diff --git a/unit_tests/os_interface/windows/wddm_kmdaf_listener_tests.cpp b/unit_tests/os_interface/windows/wddm_kmdaf_listener_tests.cpp index 990b64d838..dede3efab8 100644 --- a/unit_tests/os_interface/windows/wddm_kmdaf_listener_tests.cpp +++ b/unit_tests/os_interface/windows/wddm_kmdaf_listener_tests.cpp @@ -5,6 +5,7 @@ * */ +#include "runtime/command_stream/preemption.h" #include "runtime/gmm_helper/gmm.h" #include "runtime/gmm_helper/gmm_helper.h" #include "runtime/os_interface/windows/wddm/wddm.h" @@ -45,7 +46,7 @@ class WddmKmDafListenerTest : public GmmEnvironmentFixture, public ::testing::Te GmmEnvironmentFixture::SetUp(); wddmWithKmDafMock.reset(new WddmWithKmDafMock()); wddmWithKmDafMock->gdi.reset(new MockGdi()); - wddmWithKmDafMock->init(); + wddmWithKmDafMock->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); wddmWithKmDafMock->getFeatureTable()->ftrKmdDaf = true; } void TearDown() { diff --git a/unit_tests/os_interface/windows/wddm_memory_manager_tests.cpp b/unit_tests/os_interface/windows/wddm_memory_manager_tests.cpp index c9992a1ae2..17dcad0be8 100644 --- a/unit_tests/os_interface/windows/wddm_memory_manager_tests.cpp +++ b/unit_tests/os_interface/windows/wddm_memory_manager_tests.cpp @@ -36,7 +36,7 @@ void WddmMemoryManagerFixture::SetUp() { GMM_TRANSLATIONTABLE_CALLBACKS dummyTTCallbacks = {}; wddm->resetPageTableManager(GmmPageTableMngr::create(&dummyDeviceCallbacks, 0, &dummyTTCallbacks)); } - EXPECT_TRUE(wddm->init()); + EXPECT_TRUE(wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]))); constexpr uint64_t heap32Base = (is32bit) ? 0x1000 : 0x800000000000; wddm->setHeap32(heap32Base, 1000 * MemoryConstants::pageSize - 1); @@ -65,7 +65,7 @@ TEST(WddmMemoryManager, NonAssignable) { TEST(WddmAllocationTest, givenAllocationIsTrimCandidateInOneOsContextWhenGettingTrimCandidatePositionThenReturnItsPositionAndUnusedPositionInOtherContexts) { WddmAllocation allocation{nullptr, 0, nullptr, MemoryPool::MemoryNull, 3u, false}; - OsContext osContext(nullptr, 1u, gpgpuEngineInstances[0]); + OsContext osContext(nullptr, 1u, gpgpuEngineInstances[0], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); allocation.setTrimCandidateListPosition(osContext.getContextId(), 700u); EXPECT_EQ(trimListUnusedPosition, allocation.getTrimCandidateListPosition(0u)); EXPECT_EQ(700u, allocation.getTrimCandidateListPosition(1u)); @@ -1140,7 +1140,7 @@ TEST(WddmMemoryManagerDefaults, givenDefaultWddmMemoryManagerWhenItIsQueriedForI TEST_F(MockWddmMemoryManagerTest, givenValidateAllocationFunctionWhenItIsCalledWithTripleAllocationThenSuccessIsReturned) { ExecutionEnvironment executionEnvironment; auto wddm = std::make_unique(); - EXPECT_TRUE(wddm->init()); + EXPECT_TRUE(wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]))); MockWddmMemoryManager memoryManager(wddm.get(), executionEnvironment); auto wddmAlloc = (WddmAllocation *)memoryManager.allocateGraphicsMemory(4096u, reinterpret_cast(0x1000)); @@ -1153,7 +1153,7 @@ TEST_F(MockWddmMemoryManagerTest, givenValidateAllocationFunctionWhenItIsCalledW TEST_F(MockWddmMemoryManagerTest, givenEnabled64kbpagesWhenCreatingGraphicsMemoryForBufferWithoutHostPtrThen64kbAdressIsAllocated) { DebugManagerStateRestore dbgRestore; auto wddm = std::make_unique(); - EXPECT_TRUE(wddm->init()); + EXPECT_TRUE(wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]))); DebugManager.flags.Enable64kbpages.set(true); WddmMemoryManager memoryManager64k(true, false, wddm.get(), executionEnvironment); EXPECT_EQ(0, wddm->createAllocationResult.called); @@ -1171,7 +1171,7 @@ TEST_F(MockWddmMemoryManagerTest, givenEnabled64kbpagesWhenCreatingGraphicsMemor TEST_F(OsAgnosticMemoryManagerUsingWddmTest, givenEnabled64kbPagesWhenAllocationIsCreatedWithSizeSmallerThan64kbThenGraphicsAllocationsHas64kbAlignedUnderlyingSize) { DebugManagerStateRestore dbgRestore; auto wddm = std::make_unique(); - EXPECT_TRUE(wddm->init()); + EXPECT_TRUE(wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]))); DebugManager.flags.Enable64kbpages.set(true); WddmMemoryManager memoryManager(true, false, wddm.get(), executionEnvironment); auto graphicsAllocation = memoryManager.allocateGraphicsMemory64kb(1, MemoryConstants::pageSize64k, false, false); @@ -1190,7 +1190,7 @@ TEST_F(MockWddmMemoryManagerTest, givenWddmWhenallocateGraphicsMemory64kbThenLoc DebugManagerStateRestore dbgRestore; DebugManager.flags.Enable64kbpages.set(true); auto wddm = std::make_unique(); - EXPECT_TRUE(wddm->init()); + EXPECT_TRUE(wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]))); MockWddmMemoryManager memoryManager64k(wddm.get(), executionEnvironment); uint32_t lockCount = wddm->lockResult.called; uint32_t mapGpuVirtualAddressResult = wddm->mapGpuVirtualAddressResult.called; @@ -1213,16 +1213,16 @@ TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWithNoRegisteredOsContextsWh } TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWithRegisteredOsContextWhenCallingIsMemoryBudgetExhaustedThenReturnFalse) { - memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0]); - memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0]); - memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0]); + memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); + memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); + memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); EXPECT_FALSE(memoryManager->isMemoryBudgetExhausted()); } TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWithRegisteredOsContextWithExhaustedMemoryBudgetWhenCallingIsMemoryBudgetExhaustedThenReturnTrue) { - memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0]); - memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0]); - memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0]); + memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); + memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); + memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); memoryManager->getRegisteredOsContext(1)->get()->getResidencyController().setMemoryBudgetExhausted(); EXPECT_TRUE(memoryManager->isMemoryBudgetExhausted()); } @@ -1249,7 +1249,7 @@ TEST_F(MockWddmMemoryManagerTest, givenDisabledAsyncDeleterFlagWhenMemoryManager TEST_F(MockWddmMemoryManagerTest, givenPageTableManagerWhenMapAuxGpuVaCalledThenUseWddmToMap) { auto myWddm = std::make_unique(); - EXPECT_TRUE(myWddm->init()); + EXPECT_TRUE(myWddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]))); WddmMemoryManager memoryManager(false, false, myWddm.get(), executionEnvironment); auto mockMngr = new NiceMock(); @@ -1277,7 +1277,7 @@ TEST_F(MockWddmMemoryManagerTest, givenRenderCompressedAllocationWhenMappedGpuVa gmm->isRenderCompressed = true; D3DGPU_VIRTUAL_ADDRESS gpuVa = 0; WddmMock wddm; - EXPECT_TRUE(wddm.init()); + EXPECT_TRUE(wddm.init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]))); auto mockMngr = new NiceMock(); wddm.resetPageTableManager(mockMngr); @@ -1309,7 +1309,7 @@ TEST_F(MockWddmMemoryManagerTest, givenRenderCompressedAllocationWhenMappedGpuVa TEST_F(MockWddmMemoryManagerTest, givenRenderCompressedAllocationWhenReleaseingThenUnmapAuxVa) { auto wddm = std::make_unique(); - EXPECT_TRUE(wddm->init()); + EXPECT_TRUE(wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]))); WddmMemoryManager memoryManager(false, false, wddm.get(), executionEnvironment); D3DGPU_VIRTUAL_ADDRESS gpuVa = 123; @@ -1335,7 +1335,7 @@ TEST_F(MockWddmMemoryManagerTest, givenRenderCompressedAllocationWhenReleaseingT TEST_F(MockWddmMemoryManagerTest, givenNonRenderCompressedAllocationWhenReleaseingThenDontUnmapAuxVa) { auto wddm = std::make_unique(); - EXPECT_TRUE(wddm->init()); + EXPECT_TRUE(wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]))); WddmMemoryManager memoryManager(false, false, wddm.get(), executionEnvironment); auto mockMngr = new NiceMock(); @@ -1354,7 +1354,7 @@ TEST_F(MockWddmMemoryManagerTest, givenNonRenderCompressedAllocationWhenMappedGp gmm->isRenderCompressed = false; D3DGPU_VIRTUAL_ADDRESS gpuVa = 0; WddmMock wddm; - EXPECT_TRUE(wddm.init()); + EXPECT_TRUE(wddm.init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]))); auto mockMngr = new NiceMock(); wddm.resetPageTableManager(mockMngr); @@ -1370,7 +1370,7 @@ TEST_F(MockWddmMemoryManagerTest, givenFailingAllocationWhenMappedGpuVaThenRetur gmm->isRenderCompressed = false; D3DGPU_VIRTUAL_ADDRESS gpuVa = 0; WddmMock wddm; - EXPECT_TRUE(wddm.init()); + EXPECT_TRUE(wddm.init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]))); auto result = wddm.mapGpuVirtualAddressImpl(gmm.get(), 0, nullptr, gpuVa, false, false, false); ASSERT_FALSE(result); @@ -1379,7 +1379,7 @@ TEST_F(MockWddmMemoryManagerTest, givenFailingAllocationWhenMappedGpuVaThenRetur TEST_F(MockWddmMemoryManagerTest, givenRenderCompressedFlagSetWhenInternalIsUnsetThenDontUpdateAuxTable) { D3DGPU_VIRTUAL_ADDRESS gpuVa = 0; auto wddm = std::make_unique(); - EXPECT_TRUE(wddm->init()); + EXPECT_TRUE(wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]))); WddmMemoryManager memoryManager(false, false, wddm.get(), executionEnvironment); auto mockMngr = new NiceMock(); @@ -1445,7 +1445,8 @@ TEST(WddmMemoryManagerCleanupTest, givenUsedTagAllocationInWddmMemoryManagerWhen ExecutionEnvironment executionEnvironment; auto csr = createCommandStream(*platformDevices, executionEnvironment); auto wddm = new WddmMock(); - EXPECT_TRUE(wddm->init()); + auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]); + EXPECT_TRUE(wddm->init(preemptionMode)); executionEnvironment.osInterface = std::make_unique(); executionEnvironment.osInterface->get()->setWddm(wddm); @@ -1453,7 +1454,7 @@ TEST(WddmMemoryManagerCleanupTest, givenUsedTagAllocationInWddmMemoryManagerWhen executionEnvironment.commandStreamReceivers[0][0] = std::unique_ptr(csr); executionEnvironment.memoryManager = std::make_unique(false, false, wddm, executionEnvironment); - csr->setOsContext(*executionEnvironment.memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0])); + csr->setOsContext(*executionEnvironment.memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0], preemptionMode)); EXPECT_EQ(csr, executionEnvironment.memoryManager->getDefaultCommandStreamReceiver(0)); auto tagAllocator = csr->getEventPerfCountAllocator(); diff --git a/unit_tests/os_interface/windows/wddm_memory_manager_tests.h b/unit_tests/os_interface/windows/wddm_memory_manager_tests.h index 341a20eb72..ea2934e89a 100644 --- a/unit_tests/os_interface/windows/wddm_memory_manager_tests.h +++ b/unit_tests/os_interface/windows/wddm_memory_manager_tests.h @@ -50,13 +50,13 @@ class MockWddmMemoryManagerFixture : public GmmEnvironmentFixture { wddm->gdi.reset(gdi); constexpr uint64_t heap32Base = (is32bit) ? 0x1000 : 0x800000000000; wddm->setHeap32(heap32Base, 1000 * MemoryConstants::pageSize - 1); - EXPECT_TRUE(wddm->init()); + EXPECT_TRUE(wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]))); executionEnvironment.osInterface.reset(new OSInterface()); executionEnvironment.osInterface->get()->setWddm(wddm); memoryManager = std::make_unique(wddm, executionEnvironment); - memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0]); + memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); osContext = memoryManager->getRegisteredOsContext(0); osContext->incRefInternal(); @@ -114,13 +114,14 @@ class WddmMemoryManagerFixtureWithGmockWddm : public GmmEnvironmentFixture { wddm = new NiceMock; osInterface = std::make_unique(); ASSERT_NE(nullptr, wddm); - EXPECT_TRUE(wddm->init()); + auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]); + EXPECT_TRUE(wddm->init(preemptionMode)); osInterface->get()->setWddm(wddm); - wddm->init(); + wddm->init(preemptionMode); memoryManager = new (std::nothrow) MockWddmMemoryManager(wddm, executionEnvironment); //assert we have memory manager ASSERT_NE(nullptr, memoryManager); - memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0]); + memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0], preemptionMode); osContext = memoryManager->getRegisteredOsContext(0); osContext->incRefInternal(); @@ -167,7 +168,7 @@ class WddmMemoryManagerSimpleTest : public MockWddmMemoryManagerFixture, public public: void SetUp() override { MockWddmMemoryManagerFixture::SetUp(); - wddm->init(); + wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); } void TearDown() override { MockWddmMemoryManagerFixture::TearDown(); diff --git a/unit_tests/os_interface/windows/wddm_preemption_tests.cpp b/unit_tests/os_interface/windows/wddm_preemption_tests.cpp index 546dfff5a0..eceb9c98b7 100644 --- a/unit_tests/os_interface/windows/wddm_preemption_tests.cpp +++ b/unit_tests/os_interface/windows/wddm_preemption_tests.cpp @@ -33,10 +33,9 @@ class WddmPreemptionTests : public Test { auto regReader = new RegistryReaderMock(); wddm->registryReader.reset(regReader); regReader->forceRetValue = forceReturnPreemptionRegKeyValue; - PreemptionMode preemptionMode = PreemptionHelper::getDefaultPreemptionMode(hwInfoTest); - wddm->setPreemptionMode(preemptionMode); - wddm->init(); - osContext = std::make_unique(osInterface.get(), 0u, gpgpuEngineInstances[0]); + auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(hwInfoTest); + wddm->init(preemptionMode); + osContext = std::make_unique(osInterface.get(), 0u, gpgpuEngineInstances[0], preemptionMode); osContextWin = osContext->get(); } diff --git a/unit_tests/os_interface/windows/wddm_residency_controller_tests.cpp b/unit_tests/os_interface/windows/wddm_residency_controller_tests.cpp index b26ae148b2..7022bcb484 100644 --- a/unit_tests/os_interface/windows/wddm_residency_controller_tests.cpp +++ b/unit_tests/os_interface/windows/wddm_residency_controller_tests.cpp @@ -5,6 +5,7 @@ * */ +#include "runtime/command_stream/preemption.h" #include "runtime/execution_environment/execution_environment.h" #include "runtime/os_interface/os_context.h" #include "runtime/os_interface/windows/os_context_win.h" @@ -45,7 +46,7 @@ struct WddmResidencyControllerTest : ::testing::Test { void SetUp() { wddm = std::unique_ptr(static_cast(Wddm::createWddm())); - wddm->init(); + wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); residencyController = std::make_unique(*wddm, osContextId); wddm->getWddmInterface()->createMonitoredFence(*residencyController); } @@ -61,7 +62,7 @@ struct WddmResidencyControllerWithGdiTest : ::testing::Test { wddm = std::unique_ptr(static_cast(Wddm::createWddm())); gdi = new MockGdi(); wddm->gdi.reset(gdi); - wddm->init(); + wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); residencyController = std::make_unique(*wddm, osContextId); wddm->getWddmInterface()->createMonitoredFence(*residencyController); @@ -85,13 +86,14 @@ struct WddmResidencyControllerWithMockWddmTest : public WddmResidencyControllerT wddm = new ::testing::NiceMock(); wddm->gdi = std::make_unique(); - ASSERT_TRUE(wddm->init()); + auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]); + ASSERT_TRUE(wddm->init(preemptionMode)); executionEnvironment->osInterface = std::make_unique(); executionEnvironment->osInterface->get()->setWddm(wddm); memoryManager = std::make_unique(wddm, *executionEnvironment); - memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0]); + memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0], preemptionMode); osContext = memoryManager->getRegisteredOsContext(0); osContext->incRefInternal(); residencyController = &osContext->get()->getResidencyController(); @@ -113,7 +115,7 @@ struct WddmResidencyControllerWithGdiAndMemoryManagerTest : ::testing::Test { void SetUp() { wddm = static_cast(Wddm::createWddm()); - wddm->init(); + wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); gdi = new MockGdi(); wddm->gdi.reset(gdi); @@ -122,7 +124,7 @@ struct WddmResidencyControllerWithGdiAndMemoryManagerTest : ::testing::Test { executionEnvironment->osInterface->get()->setWddm(wddm); memoryManager = std::make_unique(wddm, *executionEnvironment); - memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0]); + memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); osContext = memoryManager->getRegisteredOsContext(0); osContext->incRefInternal(); @@ -148,7 +150,7 @@ TEST(WddmResidencyController, givenWddmResidencyControllerWhenItIsConstructedThe auto gdi = new MockGdi(); auto wddm = std::unique_ptr{static_cast(Wddm::createWddm())}; wddm->gdi.reset(gdi); - wddm->init(); + wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); std::memset(&gdi->getRegisterTrimNotificationArg(), 0, sizeof(D3DKMT_REGISTERTRIMNOTIFICATION)); MockWddmResidencyController residencyController{*wddm, 0u}; @@ -166,7 +168,7 @@ TEST(WddmResidencyController, givenWddmResidencyControllerWhenRegisterCallbackTh auto gdi = new MockGdi(); auto wddm = std::unique_ptr{static_cast(Wddm::createWddm())}; wddm->gdi.reset(gdi); - wddm->init(); + wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); std::memset(&gdi->getRegisterTrimNotificationArg(), 0, sizeof(D3DKMT_REGISTERTRIMNOTIFICATION));