From af46d88fc15c91c57c1163e87828fd4700bbdb9f Mon Sep 17 00:00:00 2001 From: "Dunajski, Bartosz" Date: Tue, 20 Nov 2018 13:58:15 +0100 Subject: [PATCH] Allow Device creating multiple CSRs [1/n] Change-Id: Ie5d8d89aa388c608d5464919059c28a054ac9b1e Signed-off-by: Dunajski, Bartosz --- runtime/device/device.cpp | 33 +++++++------ runtime/device/device.h | 4 +- .../execution_environment.cpp | 13 +++-- .../execution_environment.h | 8 +-- runtime/memory_manager/memory_manager.cpp | 2 +- unit_tests/aub_tests/fixtures/aub_fixture.h | 2 +- .../command_queue/enqueue_handler_tests.cpp | 3 +- ...and_stream_receiver_flush_task_3_tests.cpp | 3 +- .../command_stream_receiver_tests.cpp | 13 +++-- .../create_command_stream_receiver_tests.cpp | 12 ++--- unit_tests/device/device_tests.cpp | 10 ++-- .../execution_environment_tests.cpp | 49 ++++++++++--------- .../fixtures/memory_allocator_fixture.h | 2 +- .../fixtures/memory_manager_fixture.cpp | 3 +- unit_tests/memory_manager/surface_tests.cpp | 3 +- unit_tests/mocks/mock_aub_csr.h | 9 ++-- unit_tests/mocks/mock_device.cpp | 14 +++--- unit_tests/mocks/mock_device.h | 2 +- .../linux/drm_command_stream_tests.cpp | 3 +- .../linux/drm_memory_manager_tests.cpp | 6 ++- .../windows/device_command_stream_tests.cpp | 41 +++++++++------- .../windows/wddm_memory_manager_tests.cpp | 5 +- .../sharings/gl/gl_arb_sync_event_tests.cpp | 3 +- 23 files changed, 137 insertions(+), 106 deletions(-) diff --git a/runtime/device/device.cpp b/runtime/device/device.cpp index d88f297a6b..a1036d8d10 100644 --- a/runtime/device/device.cpp +++ b/runtime/device/device.cpp @@ -86,8 +86,8 @@ Device::~Device() { performanceCounters->shutdown(); } - if (commandStreamReceiver) { - commandStreamReceiver->flushBatchedSubmissions(); + for (auto &csr : commandStreamReceiver) { + csr->flushBatchedSubmissions(); } if (deviceInfo.sourceLevelDebuggerActive && executionEnvironment->sourceLevelDebugger) { @@ -107,27 +107,30 @@ Device::~Device() { } bool Device::createDeviceImpl(const HardwareInfo *pHwInfo, Device &outDevice) { + uint32_t deviceCsrIndex = 0; auto executionEnvironment = outDevice.executionEnvironment; executionEnvironment->initGmm(pHwInfo); - if (!executionEnvironment->initializeCommandStreamReceiver(pHwInfo, outDevice.getDeviceIndex())) { + if (!executionEnvironment->initializeCommandStreamReceiver(pHwInfo, outDevice.getDeviceIndex(), deviceCsrIndex)) { return false; } - executionEnvironment->initializeMemoryManager(outDevice.getEnabled64kbPages(), outDevice.getEnableLocalMemory(), outDevice.getDeviceIndex()); + executionEnvironment->initializeMemoryManager(outDevice.getEnabled64kbPages(), outDevice.getEnableLocalMemory(), + outDevice.getDeviceIndex(), deviceCsrIndex); outDevice.osContext = new OsContext(executionEnvironment->osInterface.get(), outDevice.getDeviceIndex()); executionEnvironment->memoryManager->registerOsContext(outDevice.osContext); - outDevice.commandStreamReceiver = executionEnvironment->commandStreamReceivers[outDevice.getDeviceIndex()].get(); - if (!outDevice.commandStreamReceiver->initializeTagAllocation()) { + outDevice.commandStreamReceiver.resize(1); + outDevice.commandStreamReceiver[deviceCsrIndex] = executionEnvironment->commandStreamReceivers[outDevice.getDeviceIndex()][deviceCsrIndex].get(); + if (!outDevice.commandStreamReceiver[deviceCsrIndex]->initializeTagAllocation()) { return false; } auto pDevice = &outDevice; if (!pDevice->osTime) { - pDevice->osTime = OSTime::create(outDevice.commandStreamReceiver->getOSInterface()); + pDevice->osTime = OSTime::create(outDevice.commandStreamReceiver[deviceCsrIndex]->getOSInterface()); } - pDevice->driverInfo.reset(DriverInfo::create(outDevice.commandStreamReceiver->getOSInterface())); - pDevice->tagAddress = reinterpret_cast(outDevice.commandStreamReceiver->getTagAllocation()->getUnderlyingBuffer()); + pDevice->driverInfo.reset(DriverInfo::create(outDevice.commandStreamReceiver[deviceCsrIndex]->getOSInterface())); + pDevice->tagAddress = reinterpret_cast(outDevice.commandStreamReceiver[deviceCsrIndex]->getTagAllocation()->getUnderlyingBuffer()); pDevice->initializeCaps(); @@ -139,8 +142,8 @@ bool Device::createDeviceImpl(const HardwareInfo *pHwInfo, Device &outDevice) { } uint32_t deviceHandle = 0; - if (outDevice.commandStreamReceiver->getOSInterface()) { - deviceHandle = outDevice.commandStreamReceiver->getOSInterface()->getDeviceHandle(); + if (outDevice.commandStreamReceiver[deviceCsrIndex]->getOSInterface()) { + deviceHandle = outDevice.commandStreamReceiver[deviceCsrIndex]->getOSInterface()->getDeviceHandle(); } if (pDevice->deviceInfo.sourceLevelDebuggerActive) { @@ -157,14 +160,14 @@ bool Device::createDeviceImpl(const HardwareInfo *pHwInfo, Device &outDevice) { if (!pDevice->preemptionAllocation) { return false; } - outDevice.commandStreamReceiver->setPreemptionCsrAllocation(pDevice->preemptionAllocation); + outDevice.commandStreamReceiver[deviceCsrIndex]->setPreemptionCsrAllocation(pDevice->preemptionAllocation); auto sipType = SipKernel::getSipKernelType(pHwInfo->pPlatform->eRenderCoreFamily, pDevice->isSourceLevelDebuggerActive()); initSipKernel(sipType, *pDevice); } if (DebugManager.flags.EnableExperimentalCommandBuffer.get() > 0) { - outDevice.commandStreamReceiver->setExperimentalCmdBuffer( - std::unique_ptr(new ExperimentalCommandBuffer(outDevice.commandStreamReceiver, pDevice->getDeviceInfo().profilingTimerResolution))); + outDevice.commandStreamReceiver[deviceCsrIndex]->setExperimentalCmdBuffer( + std::unique_ptr(new ExperimentalCommandBuffer(outDevice.commandStreamReceiver[deviceCsrIndex], pDevice->getDeviceInfo().profilingTimerResolution))); } return true; @@ -227,7 +230,7 @@ unique_ptr_if_unused Device::release() { bool Device::isSimulation() const { bool simulation = hwInfo.capabilityTable.isSimulation(hwInfo.pPlatform->usDeviceID); - if (commandStreamReceiver->getType() != CommandStreamReceiverType::CSR_HW) { + if (commandStreamReceiver[0]->getType() != CommandStreamReceiverType::CSR_HW) { simulation = true; } if (hwInfo.pSkuTable->ftrSimulationMode) { diff --git a/runtime/device/device.h b/runtime/device/device.h index 8672278941..51f900b4b2 100644 --- a/runtime/device/device.h +++ b/runtime/device/device.h @@ -165,7 +165,7 @@ class Device : public BaseObject<_cl_device_id> { EngineType engineType; ExecutionEnvironment *executionEnvironment = nullptr; uint32_t deviceIndex = 0u; - CommandStreamReceiver *commandStreamReceiver = nullptr; + std::vector commandStreamReceiver; }; template @@ -177,7 +177,7 @@ inline void Device::getCap(const void *&src, } inline CommandStreamReceiver &Device::getCommandStreamReceiver() { - return *this->commandStreamReceiver; + return *this->commandStreamReceiver[0]; } inline volatile uint32_t *Device::getTagAddress() const { diff --git a/runtime/execution_environment/execution_environment.cpp b/runtime/execution_environment/execution_environment.cpp index 561f82cfbf..9dee3f0b05 100644 --- a/runtime/execution_environment/execution_environment.cpp +++ b/runtime/execution_environment/execution_environment.cpp @@ -33,12 +33,15 @@ void ExecutionEnvironment::initGmm(const HardwareInfo *hwInfo) { gmmHelper.reset(new GmmHelper(hwInfo)); } } -bool ExecutionEnvironment::initializeCommandStreamReceiver(const HardwareInfo *pHwInfo, uint32_t deviceIndex) { +bool ExecutionEnvironment::initializeCommandStreamReceiver(const HardwareInfo *pHwInfo, uint32_t deviceIndex, uint32_t deviceCsrIndex) { if (deviceIndex + 1 > commandStreamReceivers.size()) { commandStreamReceivers.resize(deviceIndex + 1); } + if (deviceCsrIndex + 1 > commandStreamReceivers[deviceIndex].size()) { + commandStreamReceivers[deviceIndex].resize(deviceCsrIndex + 1); + } - if (this->commandStreamReceivers[deviceIndex]) { + if (this->commandStreamReceivers[deviceIndex][deviceCsrIndex]) { return true; } std::unique_ptr commandStreamReceiver(createCommandStream(pHwInfo, *this)); @@ -49,15 +52,15 @@ bool ExecutionEnvironment::initializeCommandStreamReceiver(const HardwareInfo *p commandStreamReceiver->createPageTableManager(); } commandStreamReceiver->setDeviceIndex(deviceIndex); - this->commandStreamReceivers[deviceIndex] = std::move(commandStreamReceiver); + this->commandStreamReceivers[deviceIndex][deviceCsrIndex] = std::move(commandStreamReceiver); return true; } -void ExecutionEnvironment::initializeMemoryManager(bool enable64KBpages, bool enableLocalMemory, uint32_t deviceIndex) { +void ExecutionEnvironment::initializeMemoryManager(bool enable64KBpages, bool enableLocalMemory, uint32_t deviceIndex, uint32_t deviceCsrIndex) { if (this->memoryManager) { return; } - memoryManager.reset(commandStreamReceivers[deviceIndex]->createMemoryManager(enable64KBpages, enableLocalMemory)); + memoryManager.reset(commandStreamReceivers[deviceIndex][deviceCsrIndex]->createMemoryManager(enable64KBpages, enableLocalMemory)); DEBUG_BREAK_IF(!this->memoryManager); } void ExecutionEnvironment::initSourceLevelDebugger(const HardwareInfo &hwInfo) { diff --git a/runtime/execution_environment/execution_environment.h b/runtime/execution_environment/execution_environment.h index 2f5b939818..06bd4be2d6 100644 --- a/runtime/execution_environment/execution_environment.h +++ b/runtime/execution_environment/execution_environment.h @@ -23,6 +23,8 @@ class BuiltIns; struct HardwareInfo; class OSInterface; +using CsrContainer = std::vector>; + class ExecutionEnvironment : public ReferenceTrackedObject { private: std::mutex mtx; @@ -37,8 +39,8 @@ class ExecutionEnvironment : public ReferenceTrackedObject MOCKABLE_VIRTUAL void initAubCenter(const HardwareInfo *hwInfo, bool localMemoryEnabled); void initGmm(const HardwareInfo *hwInfo); - bool initializeCommandStreamReceiver(const HardwareInfo *pHwInfo, uint32_t deviceIndex); - void initializeMemoryManager(bool enable64KBpages, bool enableLocalMemory, uint32_t deviceIndex); + bool initializeCommandStreamReceiver(const HardwareInfo *pHwInfo, uint32_t deviceIndex, uint32_t deviceCsrIndex); + void initializeMemoryManager(bool enable64KBpages, bool enableLocalMemory, uint32_t deviceIndex, uint32_t deviceCsrIndex); void initSourceLevelDebugger(const HardwareInfo &hwInfo); GmmHelper *getGmmHelper() const; @@ -48,7 +50,7 @@ class ExecutionEnvironment : public ReferenceTrackedObject std::unique_ptr osInterface; std::unique_ptr memoryManager; std::unique_ptr aubCenter; - std::vector> commandStreamReceivers; + std::vector commandStreamReceivers; std::unique_ptr builtins; std::unique_ptr compilerInterface; std::unique_ptr sourceLevelDebugger; diff --git a/runtime/memory_manager/memory_manager.cpp b/runtime/memory_manager/memory_manager.cpp index c1dd54f322..374b938bb6 100644 --- a/runtime/memory_manager/memory_manager.cpp +++ b/runtime/memory_manager/memory_manager.cpp @@ -307,7 +307,7 @@ GraphicsAllocation *MemoryManager::allocateGraphicsMemory(const AllocationData & } CommandStreamReceiver *MemoryManager::getCommandStreamReceiver(uint32_t contextId) { UNRECOVERABLE_IF(executionEnvironment.commandStreamReceivers.size() < 1); - return executionEnvironment.commandStreamReceivers[contextId].get(); + return executionEnvironment.commandStreamReceivers[contextId][0].get(); } } // namespace OCLRT diff --git a/unit_tests/aub_tests/fixtures/aub_fixture.h b/unit_tests/aub_tests/fixtures/aub_fixture.h index 18adb5e757..2a5576f5fc 100644 --- a/unit_tests/aub_tests/fixtures/aub_fixture.h +++ b/unit_tests/aub_tests/fixtures/aub_fixture.h @@ -44,7 +44,7 @@ class AUBFixture : public CommandQueueHwFixture { } executionEnvironment->commandStreamReceivers.resize(deviceIndex + 1); - executionEnvironment->commandStreamReceivers[deviceIndex] = std::unique_ptr(this->csr); + executionEnvironment->commandStreamReceivers[deviceIndex].push_back(std::unique_ptr(this->csr)); device.reset(MockDevice::create(&hwInfo, executionEnvironment, deviceIndex)); CommandQueueHwFixture::SetUp(AUBFixture::device.get(), cl_command_queue_properties(0)); diff --git a/unit_tests/command_queue/enqueue_handler_tests.cpp b/unit_tests/command_queue/enqueue_handler_tests.cpp index fc2311f236..d9b2694716 100644 --- a/unit_tests/command_queue/enqueue_handler_tests.cpp +++ b/unit_tests/command_queue/enqueue_handler_tests.cpp @@ -341,7 +341,8 @@ HWTEST_F(EnqueueHandlerTestBasic, givenEnqueueHandlerWhenCommandIsBlokingThenCom int32_t tag; auto executionEnvironment = new ExecutionEnvironment; auto mockCsr = new MockCsrBase(tag, *executionEnvironment); - executionEnvironment->commandStreamReceivers.push_back(std::unique_ptr(mockCsr)); + executionEnvironment->commandStreamReceivers.resize(1); + executionEnvironment->commandStreamReceivers[0].push_back(std::unique_ptr(mockCsr)); std::unique_ptr pDevice(MockDevice::createWithExecutionEnvironment(nullptr, executionEnvironment, 0u)); auto context = std::make_unique(pDevice.get()); MockKernelWithInternals kernelInternals(*pDevice, context.get()); diff --git a/unit_tests/command_stream/command_stream_receiver_flush_task_3_tests.cpp b/unit_tests/command_stream/command_stream_receiver_flush_task_3_tests.cpp index dc477e8d13..ce5768fe98 100644 --- a/unit_tests/command_stream/command_stream_receiver_flush_task_3_tests.cpp +++ b/unit_tests/command_stream/command_stream_receiver_flush_task_3_tests.cpp @@ -660,7 +660,8 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCsrInBatchingModeWhenTotalRes auto mockedMemoryManager = new MockedMemoryManager(executionEnvironment); executionEnvironment.memoryManager.reset(mockedMemoryManager); auto mockCsr = new MockCsrHw2(*platformDevices[0], executionEnvironment); - executionEnvironment.commandStreamReceivers.push_back(std::unique_ptr(mockCsr)); + executionEnvironment.commandStreamReceivers.resize(1); + executionEnvironment.commandStreamReceivers[0].push_back(std::unique_ptr(mockCsr)); mockCsr->initializeTagAllocation(); mockCsr->setPreemptionCsrAllocation(pDevice->getPreemptionAllocation()); mockCsr->overrideDispatchPolicy(DispatchMode::BatchedDispatch); diff --git a/unit_tests/command_stream/command_stream_receiver_tests.cpp b/unit_tests/command_stream/command_stream_receiver_tests.cpp index 5b3bd1d344..9208fbd59b 100644 --- a/unit_tests/command_stream/command_stream_receiver_tests.cpp +++ b/unit_tests/command_stream/command_stream_receiver_tests.cpp @@ -297,19 +297,21 @@ TEST(CommandStreamReceiverSimpleTest, givenCommandStreamReceiverWhenItIsDestroye auto mockGraphicsAllocation = new MockGraphicsAllocationWithDestructorTracing(nullptr, 0llu, 0llu, 1u); mockGraphicsAllocation->destructorCalled = &destructorCalled; ExecutionEnvironment executionEnvironment; - executionEnvironment.commandStreamReceivers.push_back(std::make_unique(executionEnvironment)); - auto csr = executionEnvironment.commandStreamReceivers[0].get(); + executionEnvironment.commandStreamReceivers.resize(1); + executionEnvironment.commandStreamReceivers[0].push_back(std::make_unique(executionEnvironment)); + auto csr = executionEnvironment.commandStreamReceivers[0][0].get(); executionEnvironment.memoryManager.reset(new OsAgnosticMemoryManager(false, false, executionEnvironment)); csr->setTagAllocation(mockGraphicsAllocation); EXPECT_FALSE(destructorCalled); - executionEnvironment.commandStreamReceivers[0].reset(nullptr); + executionEnvironment.commandStreamReceivers[0][0].reset(nullptr); EXPECT_TRUE(destructorCalled); } TEST(CommandStreamReceiverSimpleTest, givenCommandStreamReceiverWhenInitializeTagAllocationIsCalledThenTagAllocationIsBeingAllocated) { ExecutionEnvironment executionEnvironment; auto csr = new MockCommandStreamReceiver(executionEnvironment); - executionEnvironment.commandStreamReceivers.push_back(std::unique_ptr(csr)); + executionEnvironment.commandStreamReceivers.resize(1); + executionEnvironment.commandStreamReceivers[0].push_back(std::unique_ptr(csr)); executionEnvironment.memoryManager.reset(new OsAgnosticMemoryManager(false, false, executionEnvironment)); EXPECT_EQ(nullptr, csr->getTagAllocation()); EXPECT_TRUE(csr->getTagAddress() == nullptr); @@ -323,8 +325,9 @@ TEST(CommandStreamReceiverSimpleTest, givenNullHardwareDebugModeWhenInitializeTa DebugManagerStateRestore dbgRestore; DebugManager.flags.EnableNullHardware.set(true); ExecutionEnvironment executionEnvironment; + executionEnvironment.commandStreamReceivers.resize(1); auto csr = new MockCommandStreamReceiver(executionEnvironment); - executionEnvironment.commandStreamReceivers.push_back(std::unique_ptr(csr)); + executionEnvironment.commandStreamReceivers[0].push_back(std::unique_ptr(csr)); executionEnvironment.memoryManager.reset(new OsAgnosticMemoryManager(false, false, executionEnvironment)); EXPECT_EQ(nullptr, csr->getTagAllocation()); EXPECT_TRUE(csr->getTagAddress() == nullptr); diff --git a/unit_tests/command_stream/create_command_stream_receiver_tests.cpp b/unit_tests/command_stream/create_command_stream_receiver_tests.cpp index f6fe24e445..0de54d5402 100644 --- a/unit_tests/command_stream/create_command_stream_receiver_tests.cpp +++ b/unit_tests/command_stream/create_command_stream_receiver_tests.cpp @@ -42,16 +42,16 @@ HWTEST_P(CreateCommandStreamReceiverTest, givenCreateCommandStreamWhenCsrIsSetTo overrideCommandStreamReceiverCreation = true; DebugManager.flags.SetCommandStreamReceiver.set(csrType); - - executionEnvironment->commandStreamReceivers.push_back(std::unique_ptr(createCommandStream(hwInfo, - *executionEnvironment))); + executionEnvironment->commandStreamReceivers.resize(1); + executionEnvironment->commandStreamReceivers[0].push_back(std::unique_ptr(createCommandStream(hwInfo, + *executionEnvironment))); if (csrType < CommandStreamReceiverType::CSR_TYPES_NUM) { - EXPECT_NE(nullptr, executionEnvironment->commandStreamReceivers[0u].get()); - executionEnvironment->memoryManager.reset(executionEnvironment->commandStreamReceivers[0u]->createMemoryManager(false, false)); + EXPECT_NE(nullptr, executionEnvironment->commandStreamReceivers[0][0].get()); + executionEnvironment->memoryManager.reset(executionEnvironment->commandStreamReceivers[0][0]->createMemoryManager(false, false)); EXPECT_NE(nullptr, executionEnvironment->memoryManager.get()); } else { - EXPECT_EQ(nullptr, executionEnvironment->commandStreamReceivers[0u]); + EXPECT_EQ(nullptr, executionEnvironment->commandStreamReceivers[0][0]); EXPECT_EQ(nullptr, executionEnvironment->memoryManager.get()); } } diff --git a/unit_tests/device/device_tests.cpp b/unit_tests/device/device_tests.cpp index 1095dc27b5..9ea608a659 100644 --- a/unit_tests/device/device_tests.cpp +++ b/unit_tests/device/device_tests.cpp @@ -191,10 +191,12 @@ TEST(DeviceCreation, givenMultiDeviceWhenTheyAreCreatedThenEachDeviceHasSeperate auto device2 = std::unique_ptr(Device::create(nullptr, &executionEnvironment, 1u)); EXPECT_EQ(2u, executionEnvironment.commandStreamReceivers.size()); - EXPECT_NE(nullptr, executionEnvironment.commandStreamReceivers[0]); - EXPECT_NE(nullptr, executionEnvironment.commandStreamReceivers[1]); - EXPECT_EQ(&device->getCommandStreamReceiver(), executionEnvironment.commandStreamReceivers[0].get()); - EXPECT_EQ(&device2->getCommandStreamReceiver(), executionEnvironment.commandStreamReceivers[1].get()); + EXPECT_EQ(1u, executionEnvironment.commandStreamReceivers[0].size()); + EXPECT_EQ(1u, executionEnvironment.commandStreamReceivers[1].size()); + EXPECT_NE(nullptr, executionEnvironment.commandStreamReceivers[0][0]); + EXPECT_NE(nullptr, executionEnvironment.commandStreamReceivers[1][0]); + EXPECT_EQ(&device->getCommandStreamReceiver(), executionEnvironment.commandStreamReceivers[0][0].get()); + EXPECT_EQ(&device2->getCommandStreamReceiver(), executionEnvironment.commandStreamReceivers[1][0].get()); } TEST(DeviceCreation, givenFtrSimulationModeFlagTrueWhenNoOtherSimulationFlagsArePresentThenIsSimulationReturnsTrue) { diff --git a/unit_tests/execution_environment/execution_environment_tests.cpp b/unit_tests/execution_environment/execution_environment_tests.cpp index 6b3357251e..b6d364ee9f 100644 --- a/unit_tests/execution_environment/execution_environment_tests.cpp +++ b/unit_tests/execution_environment/execution_environment_tests.cpp @@ -74,7 +74,7 @@ TEST(ExecutionEnvironment, givenPlatformWhenItIsCreatedThenItCreatesCommandStrea Platform platform; auto executionEnvironment = platform.peekExecutionEnvironment(); platform.initialize(); - EXPECT_NE(nullptr, executionEnvironment->commandStreamReceivers[0u].get()); + EXPECT_NE(nullptr, executionEnvironment->commandStreamReceivers[0][0].get()); } TEST(ExecutionEnvironment, givenPlatformWhenItIsCreatedThenItCreatesMemoryManagerInExecutionEnvironment) { @@ -94,33 +94,33 @@ TEST(ExecutionEnvironment, givenDeviceWhenItIsDestroyedThenMemoryManagerIsStillA TEST(ExecutionEnvironment, givenExecutionEnvironmentWhenInitializeCommandStreamReceiverIsCalledThenItIsInitalized) { std::unique_ptr executionEnvironment(new ExecutionEnvironment); - executionEnvironment->initializeCommandStreamReceiver(platformDevices[0], 0u); - EXPECT_NE(nullptr, executionEnvironment->commandStreamReceivers[0u]); + executionEnvironment->initializeCommandStreamReceiver(platformDevices[0], 0, 0); + EXPECT_NE(nullptr, executionEnvironment->commandStreamReceivers[0][0]); } TEST(ExecutionEnvironment, givenExecutionEnvironmentWhenInitializeIsCalledWithDifferentDeviceIndexesThenInternalStorageIsResized) { std::unique_ptr executionEnvironment(new ExecutionEnvironment); EXPECT_EQ(0u, executionEnvironment->commandStreamReceivers.size()); - executionEnvironment->initializeCommandStreamReceiver(platformDevices[0], 0u); + executionEnvironment->initializeCommandStreamReceiver(platformDevices[0], 0, 0); EXPECT_EQ(1u, executionEnvironment->commandStreamReceivers.size()); - EXPECT_NE(nullptr, executionEnvironment->commandStreamReceivers[0u]); - executionEnvironment->initializeCommandStreamReceiver(platformDevices[0], 1u); + EXPECT_NE(nullptr, executionEnvironment->commandStreamReceivers[0][0]); + executionEnvironment->initializeCommandStreamReceiver(platformDevices[0], 1, 0); EXPECT_EQ(2u, executionEnvironment->commandStreamReceivers.size()); - EXPECT_NE(nullptr, executionEnvironment->commandStreamReceivers[1u]); + EXPECT_NE(nullptr, executionEnvironment->commandStreamReceivers[1][0]); } TEST(ExecutionEnvironment, givenExecutionEnvironmentWhenInitializeIsCalledMultipleTimesForTheSameIndexThenCommandStreamReceiverIsReused) { auto executionEnvironment = std::make_unique(); EXPECT_EQ(0u, executionEnvironment->commandStreamReceivers.size()); - executionEnvironment->initializeCommandStreamReceiver(platformDevices[0], 1u); + executionEnvironment->initializeCommandStreamReceiver(platformDevices[0], 0, 1); - auto currentCommandStreamReceiver = executionEnvironment->commandStreamReceivers[1u].get(); + auto currentCommandStreamReceiver = executionEnvironment->commandStreamReceivers[0][1].get(); - executionEnvironment->initializeCommandStreamReceiver(platformDevices[0], 1u); + executionEnvironment->initializeCommandStreamReceiver(platformDevices[0], 0, 1); - EXPECT_EQ(currentCommandStreamReceiver, executionEnvironment->commandStreamReceivers[1u].get()); - EXPECT_EQ(2u, executionEnvironment->commandStreamReceivers.size()); - EXPECT_EQ(nullptr, executionEnvironment->commandStreamReceivers[0u].get()); + EXPECT_EQ(currentCommandStreamReceiver, executionEnvironment->commandStreamReceivers[0][1].get()); + EXPECT_EQ(2u, executionEnvironment->commandStreamReceivers[0].size()); + EXPECT_EQ(nullptr, executionEnvironment->commandStreamReceivers[0][0].get()); } TEST(ExecutionEnvironment, givenExecutionEnvironmentWhenInitializeAubCenterIsCalledThenItIsInitalizedOnce) { @@ -141,15 +141,15 @@ TEST(ExecutionEnvironment, givenExecutionEnvironmentWhenInitializeAubCenterIsCal TEST(ExecutionEnvironment, givenExecutionEnvironmentWhenInitializeMemoryManagerIsCalledThenLocalMemorySupportedInMemoryManagerHasCorrectValue) { auto device = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(platformDevices[0])); auto executionEnvironment = device->getExecutionEnvironment(); - executionEnvironment->initializeCommandStreamReceiver(platformDevices[0], 0u); - executionEnvironment->initializeMemoryManager(false, device->getEnableLocalMemory(), 0u); + executionEnvironment->initializeCommandStreamReceiver(platformDevices[0], 0, 0); + executionEnvironment->initializeMemoryManager(false, device->getEnableLocalMemory(), 0, 0); EXPECT_EQ(device->getEnableLocalMemory(), executionEnvironment->memoryManager->isLocalMemorySupported()); } TEST(ExecutionEnvironment, givenExecutionEnvironmentWhenInitializeMemoryManagerIsCalledThenItIsInitalized) { auto executionEnvironment = std::make_unique(); - executionEnvironment->initializeCommandStreamReceiver(platformDevices[0], 0u); - executionEnvironment->initializeMemoryManager(false, false, 0u); + executionEnvironment->initializeCommandStreamReceiver(platformDevices[0], 0, 0); + executionEnvironment->initializeMemoryManager(false, false, 0, 0); EXPECT_NE(nullptr, executionEnvironment->memoryManager); } static_assert(sizeof(ExecutionEnvironment) == sizeof(std::vector>) + sizeof(std::mutex) + (is64bit ? 80 : 44), "New members detected in ExecutionEnvironment, please ensure that destruction sequence of objects is correct"); @@ -186,11 +186,12 @@ TEST(ExecutionEnvironment, givenExecutionEnvironmentWithVariousMembersWhenItIsDe }; auto executionEnvironment = std::make_unique(); + executionEnvironment->commandStreamReceivers.resize(1); executionEnvironment->gmmHelper = std::make_unique(destructorId, platformDevices[0]); executionEnvironment->osInterface = std::make_unique(destructorId); executionEnvironment->memoryManager = std::make_unique(destructorId); executionEnvironment->aubCenter = std::make_unique(destructorId); - executionEnvironment->commandStreamReceivers.push_back(std::make_unique(destructorId, *executionEnvironment)); + executionEnvironment->commandStreamReceivers[0].push_back(std::make_unique(destructorId, *executionEnvironment)); executionEnvironment->builtins = std::make_unique(destructorId); executionEnvironment->compilerInterface = std::make_unique(destructorId); executionEnvironment->sourceLevelDebugger = std::make_unique(destructorId); @@ -218,19 +219,19 @@ HWTEST_F(ExecutionEnvironmentHw, givenHwHelperInputWhenInitializingCsrThenCreate localHwInfo.capabilityTable.ftrRenderCompressedImages = false; ExecutionEnvironment executionEnvironment; - executionEnvironment.initializeCommandStreamReceiver(&localHwInfo, 0); - auto csr0 = static_cast *>(executionEnvironment.commandStreamReceivers[0].get()); + executionEnvironment.initializeCommandStreamReceiver(&localHwInfo, 0, 0); + auto csr0 = static_cast *>(executionEnvironment.commandStreamReceivers[0][0].get()); EXPECT_FALSE(csr0->createPageTableManagerCalled); localHwInfo.capabilityTable.ftrRenderCompressedBuffers = true; localHwInfo.capabilityTable.ftrRenderCompressedImages = false; - executionEnvironment.initializeCommandStreamReceiver(&localHwInfo, 1); - auto csr1 = static_cast *>(executionEnvironment.commandStreamReceivers[1].get()); + executionEnvironment.initializeCommandStreamReceiver(&localHwInfo, 1, 0); + auto csr1 = static_cast *>(executionEnvironment.commandStreamReceivers[1][0].get()); EXPECT_EQ(UnitTestHelper::isPageTableManagerSupported(localHwInfo), csr1->createPageTableManagerCalled); localHwInfo.capabilityTable.ftrRenderCompressedBuffers = false; localHwInfo.capabilityTable.ftrRenderCompressedImages = true; - executionEnvironment.initializeCommandStreamReceiver(&localHwInfo, 2); - auto csr2 = static_cast *>(executionEnvironment.commandStreamReceivers[2].get()); + executionEnvironment.initializeCommandStreamReceiver(&localHwInfo, 2, 0); + auto csr2 = static_cast *>(executionEnvironment.commandStreamReceivers[2][0].get()); EXPECT_EQ(UnitTestHelper::isPageTableManagerSupported(localHwInfo), csr2->createPageTableManagerCalled); } diff --git a/unit_tests/fixtures/memory_allocator_fixture.h b/unit_tests/fixtures/memory_allocator_fixture.h index 44f586bb50..a36436ef53 100644 --- a/unit_tests/fixtures/memory_allocator_fixture.h +++ b/unit_tests/fixtures/memory_allocator_fixture.h @@ -19,7 +19,7 @@ class MemoryAllocatorFixture : public MemoryManagementFixture { void SetUp() override { MemoryManagementFixture::SetUp(); executionEnvironment = std::make_unique(); - executionEnvironment->initializeCommandStreamReceiver(*platformDevices, 0u); + executionEnvironment->initializeCommandStreamReceiver(*platformDevices, 0, 0); memoryManager = new OsAgnosticMemoryManager(false, false, *executionEnvironment); executionEnvironment->memoryManager.reset(memoryManager); csr = memoryManager->getCommandStreamReceiver(0); diff --git a/unit_tests/fixtures/memory_manager_fixture.cpp b/unit_tests/fixtures/memory_manager_fixture.cpp index 4578fbcfc1..16ec58a049 100644 --- a/unit_tests/fixtures/memory_manager_fixture.cpp +++ b/unit_tests/fixtures/memory_manager_fixture.cpp @@ -16,7 +16,8 @@ void MemoryManagerWithCsrFixture::SetUp() { memoryManager = new MockMemoryManager(executionEnvironment); executionEnvironment.memoryManager.reset(memoryManager); csr->tagAddress = ¤tGpuTag; - executionEnvironment.commandStreamReceivers.push_back(std::unique_ptr(csr)); + executionEnvironment.commandStreamReceivers.resize(1); + executionEnvironment.commandStreamReceivers[0].push_back(std::unique_ptr(csr)); } void MemoryManagerWithCsrFixture::TearDown() { diff --git a/unit_tests/memory_manager/surface_tests.cpp b/unit_tests/memory_manager/surface_tests.cpp index 637958044b..7b290ed3d9 100644 --- a/unit_tests/memory_manager/surface_tests.cpp +++ b/unit_tests/memory_manager/surface_tests.cpp @@ -57,8 +57,9 @@ HWTEST_TYPED_TEST(SurfaceTest, GivenSurfaceWhenInterfaceIsUsedThenSurfaceBehaves int32_t execStamp; ExecutionEnvironment executionEnvironment; + executionEnvironment.commandStreamReceivers.resize(1); MockCsr *csr = new MockCsr(execStamp, executionEnvironment); - executionEnvironment.commandStreamReceivers.push_back(std::unique_ptr(csr)); + executionEnvironment.commandStreamReceivers[0].push_back(std::unique_ptr(csr)); executionEnvironment.memoryManager.reset(csr->createMemoryManager(false, false)); Surface *surface = createSurface::Create(this->data, diff --git a/unit_tests/mocks/mock_aub_csr.h b/unit_tests/mocks/mock_aub_csr.h index 14b67d2767..cb327fb9e5 100644 --- a/unit_tests/mocks/mock_aub_csr.h +++ b/unit_tests/mocks/mock_aub_csr.h @@ -105,7 +105,7 @@ struct AubExecutionEnvironment { GraphicsAllocation *commandBuffer = nullptr; template CsrType *getCsr() { - return static_cast(executionEnvironment->commandStreamReceivers[0u].get()); + return static_cast(executionEnvironment->commandStreamReceivers[0][0].get()); } ~AubExecutionEnvironment() { if (commandBuffer) { @@ -117,10 +117,11 @@ struct AubExecutionEnvironment { template std::unique_ptr getEnvironment(bool createTagAllocation, bool allocateCommandBuffer, bool standalone) { std::unique_ptr executionEnvironment(new ExecutionEnvironment); - executionEnvironment->commandStreamReceivers.push_back(std::make_unique(*platformDevices[0], "", standalone, *executionEnvironment)); - executionEnvironment->memoryManager.reset(executionEnvironment->commandStreamReceivers[0u]->createMemoryManager(false, false)); + executionEnvironment->commandStreamReceivers.resize(1); + executionEnvironment->commandStreamReceivers[0].push_back(std::make_unique(*platformDevices[0], "", standalone, *executionEnvironment)); + executionEnvironment->memoryManager.reset(executionEnvironment->commandStreamReceivers[0][0]->createMemoryManager(false, false)); if (createTagAllocation) { - executionEnvironment->commandStreamReceivers[0u]->initializeTagAllocation(); + executionEnvironment->commandStreamReceivers[0][0]->initializeTagAllocation(); } std::unique_ptr aubExecutionEnvironment(new AubExecutionEnvironment); diff --git a/unit_tests/mocks/mock_device.cpp b/unit_tests/mocks/mock_device.cpp index 0d37dfbd34..22533e3381 100644 --- a/unit_tests/mocks/mock_device.cpp +++ b/unit_tests/mocks/mock_device.cpp @@ -17,9 +17,9 @@ MockDevice::MockDevice(const HardwareInfo &hwInfo) : MockDevice(hwInfo, new ExecutionEnvironment, 0u) { CommandStreamReceiver *commandStreamReceiver = createCommandStream(&hwInfo, *this->executionEnvironment); executionEnvironment->commandStreamReceivers.resize(getDeviceIndex() + 1); - executionEnvironment->commandStreamReceivers[getDeviceIndex()].reset(commandStreamReceiver); + executionEnvironment->commandStreamReceivers[getDeviceIndex()].push_back(std::unique_ptr(commandStreamReceiver)); this->executionEnvironment->memoryManager = std::move(this->mockMemoryManager); - this->commandStreamReceiver = commandStreamReceiver; + this->commandStreamReceiver.push_back(commandStreamReceiver); } MockDevice::MockDevice(const HardwareInfo &hwInfo, ExecutionEnvironment *executionEnvironment, uint32_t deviceIndex) : Device(hwInfo, executionEnvironment, deviceIndex) { @@ -46,12 +46,12 @@ void MockDevice::injectMemoryManager(MemoryManager *memoryManager) { } void MockDevice::resetCommandStreamReceiver(CommandStreamReceiver *newCsr) { - executionEnvironment->commandStreamReceivers[getDeviceIndex()].reset(newCsr); - executionEnvironment->commandStreamReceivers[getDeviceIndex()]->initializeTagAllocation(); - executionEnvironment->commandStreamReceivers[getDeviceIndex()]->setPreemptionCsrAllocation(preemptionAllocation); - this->commandStreamReceiver = newCsr; + executionEnvironment->commandStreamReceivers[getDeviceIndex()][0].reset(newCsr); + executionEnvironment->commandStreamReceivers[getDeviceIndex()][0]->initializeTagAllocation(); + executionEnvironment->commandStreamReceivers[getDeviceIndex()][0]->setPreemptionCsrAllocation(preemptionAllocation); + this->commandStreamReceiver[0] = newCsr; UNRECOVERABLE_IF(getDeviceIndex() != 0u); - this->tagAddress = executionEnvironment->commandStreamReceivers[getDeviceIndex()]->getTagAddress(); + this->tagAddress = executionEnvironment->commandStreamReceivers[getDeviceIndex()][0]->getTagAddress(); } MockAlignedMallocManagerDevice::MockAlignedMallocManagerDevice(const HardwareInfo &hwInfo, ExecutionEnvironment *executionEnvironment, uint32_t deviceIndex) : MockDevice(hwInfo, executionEnvironment, deviceIndex) { diff --git a/unit_tests/mocks/mock_device.h b/unit_tests/mocks/mock_device.h index 295689a6a5..d950369864 100644 --- a/unit_tests/mocks/mock_device.h +++ b/unit_tests/mocks/mock_device.h @@ -99,7 +99,7 @@ class MockDevice : public Device { size_t alignment = 256 * MemoryConstants::kiloByte; bool uncacheable = getWaTable()->waCSRUncachable; this->preemptionAllocation = executionEnvironment->memoryManager->allocateGraphicsMemory(requiredSize, alignment, false, uncacheable); - this->commandStreamReceiver->setPreemptionCsrAllocation(preemptionAllocation); + this->commandStreamReceiver[0]->setPreemptionCsrAllocation(preemptionAllocation); } } } 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 03b4639944..e2732a72b0 100644 --- a/unit_tests/os_interface/linux/drm_command_stream_tests.cpp +++ b/unit_tests/os_interface/linux/drm_command_stream_tests.cpp @@ -43,7 +43,8 @@ class DrmCommandStreamFixture { csr = new DrmCommandStreamReceiver(*platformDevices[0], executionEnvironment, gemCloseWorkerMode::gemCloseWorkerActive); ASSERT_NE(nullptr, csr); - executionEnvironment.commandStreamReceivers.push_back(std::unique_ptr(csr)); + executionEnvironment.commandStreamReceivers.resize(1); + executionEnvironment.commandStreamReceivers[0].push_back(std::unique_ptr(csr)); // Memory manager creates pinBB with ioctl, expect one call EXPECT_CALL(*mock, ioctl(::testing::_, ::testing::_)) 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 bbd34150da..49f92d8851 100644 --- a/unit_tests/os_interface/linux/drm_memory_manager_tests.cpp +++ b/unit_tests/os_interface/linux/drm_memory_manager_tests.cpp @@ -1615,7 +1615,8 @@ TEST_F(DrmMemoryManagerTest, givenTwoGraphicsAllocationsThatShareTheSameBufferOb executionEnvironment->osInterface = std::make_unique(); executionEnvironment->osInterface->get()->setDrm(mock); auto testedCsr = new TestedDrmCommandStreamReceiver(*executionEnvironment); - executionEnvironment->commandStreamReceivers.push_back(std::unique_ptr(testedCsr)); + executionEnvironment->commandStreamReceivers.resize(1); + executionEnvironment->commandStreamReceivers[0].push_back(std::unique_ptr(testedCsr)); testedCsr->makeResident(*graphicsAllocation); testedCsr->makeResident(*graphicsAllocation2); @@ -1643,7 +1644,8 @@ TEST_F(DrmMemoryManagerTest, givenTwoGraphicsAllocationsThatDoesnShareTheSameBuf executionEnvironment->osInterface = std::make_unique(); executionEnvironment->osInterface->get()->setDrm(mock); auto testedCsr = new TestedDrmCommandStreamReceiver(*executionEnvironment); - executionEnvironment->commandStreamReceivers.push_back(std::unique_ptr(testedCsr)); + executionEnvironment->commandStreamReceivers.resize(1); + executionEnvironment->commandStreamReceivers[0].push_back(std::unique_ptr(testedCsr)); testedCsr->makeResident(*graphicsAllocation); testedCsr->makeResident(*graphicsAllocation2); 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 878846eace..dde42eef93 100644 --- a/unit_tests/os_interface/windows/device_command_stream_tests.cpp +++ b/unit_tests/os_interface/windows/device_command_stream_tests.cpp @@ -62,7 +62,8 @@ class WddmCommandStreamFixture { wddm = static_cast(executionEnvironment->osInterface->get()->getWddm()); csr = new WddmCommandStreamReceiver(*platformDevices[0], *executionEnvironment); - executionEnvironment->commandStreamReceivers.push_back(std::unique_ptr(csr)); + executionEnvironment->commandStreamReceivers.resize(1); + executionEnvironment->commandStreamReceivers[0].push_back(std::unique_ptr(csr)); memoryManager = new MockWddmMemoryManager(wddm, *executionEnvironment); executionEnvironment->memoryManager.reset(memoryManager); @@ -125,9 +126,11 @@ class WddmCommandStreamWithMockGdiFixture { wddm->gdi.reset(gdi); ASSERT_NE(wddm, nullptr); DebugManager.flags.CsrDispatchMode.set(static_cast(DispatchMode::ImmediateDispatch)); - executionEnvironment->commandStreamReceivers.push_back(std::make_unique>(*platformDevices[0], - *executionEnvironment)); - this->csr = static_cast *>(executionEnvironment->commandStreamReceivers[0].get()); + executionEnvironment->commandStreamReceivers.resize(1); + executionEnvironment->commandStreamReceivers[0] + .push_back(std::make_unique>(*platformDevices[0], + *executionEnvironment)); + this->csr = static_cast *>(executionEnvironment->commandStreamReceivers[0][0].get()); memoryManager = csr->createMemoryManager(false, false); ASSERT_NE(nullptr, memoryManager); executionEnvironment->memoryManager.reset(memoryManager); @@ -245,10 +248,11 @@ TEST(WddmPreemptionHeaderTests, givenWddmCommandStreamReceiverWhenPreemptionIsOf std::unique_ptr executionEnvironment = std::unique_ptr(getExecutionEnvironmentImpl(hwInfo)); hwInfo->capabilityTable.defaultPreemptionMode = PreemptionMode::Disabled; auto wddm = static_cast(executionEnvironment->osInterface->get()->getWddm()); - executionEnvironment->commandStreamReceivers.push_back(std::make_unique>(hwInfo[0], - *executionEnvironment)); - executionEnvironment->memoryManager.reset(executionEnvironment->commandStreamReceivers[0u]->createMemoryManager(false, false)); - executionEnvironment->commandStreamReceivers[0u]->overrideDispatchPolicy(DispatchMode::ImmediateDispatch); + executionEnvironment->commandStreamReceivers.resize(1); + executionEnvironment->commandStreamReceivers[0].push_back(std::make_unique>(hwInfo[0], + *executionEnvironment)); + executionEnvironment->memoryManager.reset(executionEnvironment->commandStreamReceivers[0][0]->createMemoryManager(false, false)); + executionEnvironment->commandStreamReceivers[0][0]->overrideDispatchPolicy(DispatchMode::ImmediateDispatch); auto commandBuffer = executionEnvironment->memoryManager->allocateGraphicsMemory(4096); LinearStream cs(commandBuffer); @@ -257,7 +261,8 @@ TEST(WddmPreemptionHeaderTests, givenWddmCommandStreamReceiverWhenPreemptionIsOf OsContext *osContext = new OsContext(executionEnvironment->osInterface.get(), 0u); osContext->incRefInternal(); executionEnvironment->memoryManager->registerOsContext(osContext); - executionEnvironment->commandStreamReceivers[0u]->flush(batchBuffer, EngineType::ENGINE_RCS, executionEnvironment->commandStreamReceivers[0u]->getResidencyAllocations(), *osContext); + executionEnvironment->commandStreamReceivers[0][0]->flush(batchBuffer, EngineType::ENGINE_RCS, + executionEnvironment->commandStreamReceivers[0][0]->getResidencyAllocations(), *osContext); auto commandHeader = wddm->submitResult.commandHeaderSubmitted; COMMAND_BUFFER_HEADER *pHeader = reinterpret_cast(commandHeader); @@ -271,10 +276,11 @@ TEST(WddmPreemptionHeaderTests, givenWddmCommandStreamReceiverWhenPreemptionIsOn std::unique_ptr executionEnvironment = std::unique_ptr(getExecutionEnvironmentImpl(hwInfo)); hwInfo->capabilityTable.defaultPreemptionMode = PreemptionMode::MidThread; auto wddm = static_cast(executionEnvironment->osInterface->get()->getWddm()); - executionEnvironment->commandStreamReceivers.push_back(std::make_unique>(hwInfo[0], - *executionEnvironment)); - executionEnvironment->memoryManager.reset(executionEnvironment->commandStreamReceivers[0u]->createMemoryManager(false, false)); - executionEnvironment->commandStreamReceivers[0u]->overrideDispatchPolicy(DispatchMode::ImmediateDispatch); + executionEnvironment->commandStreamReceivers.resize(1); + executionEnvironment->commandStreamReceivers[0].push_back(std::make_unique>(hwInfo[0], + *executionEnvironment)); + executionEnvironment->memoryManager.reset(executionEnvironment->commandStreamReceivers[0][0]->createMemoryManager(false, false)); + executionEnvironment->commandStreamReceivers[0][0]->overrideDispatchPolicy(DispatchMode::ImmediateDispatch); auto commandBuffer = executionEnvironment->memoryManager->allocateGraphicsMemory(4096); LinearStream cs(commandBuffer); @@ -283,7 +289,7 @@ TEST(WddmPreemptionHeaderTests, givenWddmCommandStreamReceiverWhenPreemptionIsOn OsContext *osContext = new OsContext(executionEnvironment->osInterface.get(), 0u); osContext->incRefInternal(); executionEnvironment->memoryManager->registerOsContext(osContext); - executionEnvironment->commandStreamReceivers[0u]->flush(batchBuffer, EngineType::ENGINE_RCS, executionEnvironment->commandStreamReceivers[0u]->getResidencyAllocations(), *osContext); + executionEnvironment->commandStreamReceivers[0][0]->flush(batchBuffer, EngineType::ENGINE_RCS, executionEnvironment->commandStreamReceivers[0][0]->getResidencyAllocations(), *osContext); auto commandHeader = wddm->submitResult.commandHeaderSubmitted; COMMAND_BUFFER_HEADER *pHeader = reinterpret_cast(commandHeader); @@ -882,8 +888,8 @@ HWTEST_F(WddmCsrCompressionTests, givenEnabledCompressionWhenFlushingThenInitTra auto mockWddmCsr = new MockWddmCsr(hwInfo[0], *executionEnvironment); mockWddmCsr->createPageTableManager(); mockWddmCsr->overrideDispatchPolicy(DispatchMode::BatchedDispatch); - - executionEnvironment->commandStreamReceivers.push_back(std::unique_ptr(mockWddmCsr)); + executionEnvironment->commandStreamReceivers.resize(1); + executionEnvironment->commandStreamReceivers[0].push_back(std::unique_ptr(mockWddmCsr)); auto mockMngr = reinterpret_cast(myMockWddm->getPageTableManager()); std::unique_ptr device(Device::create(hwInfo, executionEnvironment, 0u)); @@ -923,7 +929,8 @@ HWTEST_F(WddmCsrCompressionTests, givenDisabledCompressionWhenFlushingThenDontIn myMockWddm = static_cast(executionEnvironment->osInterface->get()->getWddm()); auto mockWddmCsr = new MockWddmCsr(hwInfo[0], *executionEnvironment); - executionEnvironment->commandStreamReceivers.push_back(std::unique_ptr(mockWddmCsr)); + executionEnvironment->commandStreamReceivers.resize(1); + executionEnvironment->commandStreamReceivers[0].push_back(std::unique_ptr(mockWddmCsr)); mockWddmCsr->overrideDispatchPolicy(DispatchMode::BatchedDispatch); std::unique_ptr device(Device::create(hwInfo, executionEnvironment, 0u)); 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 e18f510a7e..d921a4bd58 100644 --- a/unit_tests/os_interface/windows/wddm_memory_manager_tests.cpp +++ b/unit_tests/os_interface/windows/wddm_memory_manager_tests.cpp @@ -1428,9 +1428,10 @@ TEST(WddmMemoryManagerCleanupTest, givenUsedTagAllocationInWddmMemoryManagerWhen auto wddm = std::make_unique(); EXPECT_TRUE(wddm->init()); ExecutionEnvironment executionEnvironment; - executionEnvironment.commandStreamReceivers.push_back(std::unique_ptr(createCommandStream(*platformDevices, executionEnvironment))); + executionEnvironment.commandStreamReceivers.resize(1); + executionEnvironment.commandStreamReceivers[0].push_back(std::unique_ptr(createCommandStream(*platformDevices, executionEnvironment))); executionEnvironment.memoryManager = std::make_unique(false, false, wddm.get(), executionEnvironment); - EXPECT_EQ(executionEnvironment.commandStreamReceivers[0].get(), executionEnvironment.memoryManager->getCommandStreamReceiver(0)); + EXPECT_EQ(executionEnvironment.commandStreamReceivers[0][0].get(), executionEnvironment.memoryManager->getCommandStreamReceiver(0)); auto tagAllocator = executionEnvironment.memoryManager->obtainEventPerfCountAllocator(1); auto allocation = tagAllocator->getTag()->getGraphicsAllocation(); allocation->updateTaskCount(1, 0); diff --git a/unit_tests/sharings/gl/gl_arb_sync_event_tests.cpp b/unit_tests/sharings/gl/gl_arb_sync_event_tests.cpp index 3f2dbb25e8..30ed18a5b2 100644 --- a/unit_tests/sharings/gl/gl_arb_sync_event_tests.cpp +++ b/unit_tests/sharings/gl/gl_arb_sync_event_tests.cpp @@ -65,7 +65,8 @@ struct GlArbSyncEventTest : public ::testing::Test { void SetUp() override { executionEnvironment = new ExecutionEnvironment; auto mockCsr = new MockCommandStreamReceiver(*executionEnvironment); - executionEnvironment->commandStreamReceivers.push_back(std::unique_ptr(mockCsr)); + executionEnvironment->commandStreamReceivers.resize(1); + executionEnvironment->commandStreamReceivers[0].push_back(std::unique_ptr(mockCsr)); executionEnvironment->memoryManager = std::make_unique(false, false, *executionEnvironment); device.reset(MockDevice::create(nullptr, executionEnvironment, 0u)); ctx.reset(new MockContext);