diff --git a/runtime/command_stream/command_stream_receiver.cpp b/runtime/command_stream/command_stream_receiver.cpp index 0aef3a1d52..0f177d973b 100644 --- a/runtime/command_stream/command_stream_receiver.cpp +++ b/runtime/command_stream/command_stream_receiver.cpp @@ -360,9 +360,6 @@ void CommandStreamReceiver::setExperimentalCmdBuffer(std::unique_ptrallocateGraphicsMemory(sizeof(uint32_t)); if (!tagAllocation) { return false; diff --git a/runtime/device/device.cpp b/runtime/device/device.cpp index c0a6cdc1a9..a6f42ad8c3 100644 --- a/runtime/device/device.cpp +++ b/runtime/device/device.cpp @@ -103,8 +103,8 @@ Device::~Device() { performanceCounters->shutdown(); } - if (executionEnvironment->commandStreamReceiver) { - executionEnvironment->commandStreamReceiver->flushBatchedSubmissions(); + if (commandStreamReceiver) { + commandStreamReceiver->flushBatchedSubmissions(); } if (deviceInfo.sourceLevelDebuggerActive && executionEnvironment->sourceLevelDebugger) { @@ -126,15 +126,15 @@ Device::~Device() { bool Device::createDeviceImpl(const HardwareInfo *pHwInfo, Device &outDevice) { auto executionEnvironment = outDevice.executionEnvironment; executionEnvironment->initGmm(pHwInfo); - if (!executionEnvironment->initializeCommandStreamReceiver(pHwInfo)) { + if (!executionEnvironment->initializeCommandStreamReceiver(pHwInfo, outDevice.getDeviceIndex())) { return false; } - executionEnvironment->initializeMemoryManager(outDevice.getEnabled64kbPages(), outDevice.getHardwareCapabilities().localMemorySupported); + executionEnvironment->initializeMemoryManager(outDevice.getEnabled64kbPages(), outDevice.getHardwareCapabilities().localMemorySupported, outDevice.getDeviceIndex()); outDevice.osContext = new OsContext(executionEnvironment->osInterface.get()); executionEnvironment->memoryManager->registerOsContext(outDevice.osContext); - outDevice.commandStreamReceiver = executionEnvironment->commandStreamReceiver.get(); + outDevice.commandStreamReceiver = executionEnvironment->commandStreamReceivers[outDevice.getDeviceIndex()].get(); if (!outDevice.commandStreamReceiver->initializeTagAllocation()) { return false; } @@ -246,7 +246,7 @@ unique_ptr_if_unused Device::release() { bool Device::isSimulation() const { bool simulation = hwInfo.capabilityTable.isSimulation(hwInfo.pPlatform->usDeviceID); - if (executionEnvironment->commandStreamReceiver->getType() != CommandStreamReceiverType::CSR_HW) { + if (commandStreamReceiver->getType() != CommandStreamReceiverType::CSR_HW) { simulation = true; } if (hwInfo.pSkuTable->ftrSimulationMode) { diff --git a/runtime/execution_environment/execution_environment.cpp b/runtime/execution_environment/execution_environment.cpp index 729c58659d..29a77632bd 100644 --- a/runtime/execution_environment/execution_environment.cpp +++ b/runtime/execution_environment/execution_environment.cpp @@ -41,29 +41,32 @@ void ExecutionEnvironment::initGmm(const HardwareInfo *hwInfo) { gmmHelper.reset(new GmmHelper(hwInfo)); } } -bool ExecutionEnvironment::initializeCommandStreamReceiver(const HardwareInfo *pHwInfo) { - if (this->commandStreamReceiver) { +bool ExecutionEnvironment::initializeCommandStreamReceiver(const HardwareInfo *pHwInfo, uint32_t deviceIndex) { + if (deviceIndex + 1 > commandStreamReceivers.size()) { + commandStreamReceivers.resize(deviceIndex + 1); + } + + if (this->commandStreamReceivers[deviceIndex]) { return true; } - CommandStreamReceiver *commandStreamReceiver = createCommandStream(pHwInfo, *this); + std::unique_ptr commandStreamReceiver(createCommandStream(pHwInfo, *this)); if (!commandStreamReceiver) { return false; } if (pHwInfo->capabilityTable.ftrRenderCompressedBuffers || pHwInfo->capabilityTable.ftrRenderCompressedImages) { commandStreamReceiver->createPageTableManager(); } - this->commandStreamReceiver.reset(commandStreamReceiver); + this->commandStreamReceivers[deviceIndex] = std::move(commandStreamReceiver); return true; } -void ExecutionEnvironment::initializeMemoryManager(bool enable64KBpages, bool enableLocalMemory) { +void ExecutionEnvironment::initializeMemoryManager(bool enable64KBpages, bool enableLocalMemory, uint32_t deviceIndex) { if (this->memoryManager) { - commandStreamReceiver->setMemoryManager(this->memoryManager.get()); + commandStreamReceivers[deviceIndex]->setMemoryManager(this->memoryManager.get()); return; } - memoryManager.reset(commandStreamReceiver->createMemoryManager(enable64KBpages, enableLocalMemory)); - commandStreamReceiver->setMemoryManager(memoryManager.get()); - + memoryManager.reset(commandStreamReceivers[deviceIndex]->createMemoryManager(enable64KBpages, enableLocalMemory)); + commandStreamReceivers[deviceIndex]->setMemoryManager(memoryManager.get()); 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 1cc1840759..0e3fcf61be 100644 --- a/runtime/execution_environment/execution_environment.h +++ b/runtime/execution_environment/execution_environment.h @@ -24,6 +24,7 @@ #include "runtime/utilities/reference_tracked_object.h" #include +#include namespace OCLRT { class GmmHelper; @@ -48,8 +49,8 @@ class ExecutionEnvironment : public ReferenceTrackedObject ~ExecutionEnvironment() override; void initGmm(const HardwareInfo *hwInfo); - bool initializeCommandStreamReceiver(const HardwareInfo *pHwInfo); - void initializeMemoryManager(bool enable64KBpages, bool enableLocalMemory); + bool initializeCommandStreamReceiver(const HardwareInfo *pHwInfo, uint32_t deviceIndex); + void initializeMemoryManager(bool enable64KBpages, bool enableLocalMemory, uint32_t deviceIndex); void initSourceLevelDebugger(const HardwareInfo &hwInfo); GmmHelper *getGmmHelper() const; @@ -58,7 +59,7 @@ class ExecutionEnvironment : public ReferenceTrackedObject std::unique_ptr osInterface; std::unique_ptr memoryManager; - std::unique_ptr commandStreamReceiver; + std::vector> commandStreamReceivers; std::unique_ptr builtins; std::unique_ptr compilerInterface; std::unique_ptr sourceLevelDebugger; diff --git a/unit_tests/command_stream/aub_command_stream_receiver_tests.cpp b/unit_tests/command_stream/aub_command_stream_receiver_tests.cpp index c8a32c36c6..bf0f2567bf 100644 --- a/unit_tests/command_stream/aub_command_stream_receiver_tests.cpp +++ b/unit_tests/command_stream/aub_command_stream_receiver_tests.cpp @@ -124,7 +124,7 @@ struct AubExecutionEnvironment { GraphicsAllocation *commandBuffer = nullptr; template CsrType *getCsr() { - return static_cast(executionEnvironment->commandStreamReceiver.get()); + return static_cast(executionEnvironment->commandStreamReceivers[0u].get()); } ~AubExecutionEnvironment() { if (commandBuffer) { @@ -136,11 +136,11 @@ struct AubExecutionEnvironment { template std::unique_ptr getEnvironment(bool createTagAllocation, bool allocateCommandBuffer, bool standalone) { std::unique_ptr executionEnvironment(new ExecutionEnvironment); - executionEnvironment->commandStreamReceiver.reset(new CsrType(*platformDevices[0], "", standalone, *executionEnvironment)); - executionEnvironment->memoryManager.reset(executionEnvironment->commandStreamReceiver->createMemoryManager(false, false)); - executionEnvironment->commandStreamReceiver->setMemoryManager(executionEnvironment->memoryManager.get()); + executionEnvironment->commandStreamReceivers.push_back(std::make_unique(*platformDevices[0], "", standalone, *executionEnvironment)); + executionEnvironment->memoryManager.reset(executionEnvironment->commandStreamReceivers[0u]->createMemoryManager(false, false)); + executionEnvironment->commandStreamReceivers[0u]->setMemoryManager(executionEnvironment->memoryManager.get()); if (createTagAllocation) { - executionEnvironment->commandStreamReceiver->initializeTagAllocation(); + executionEnvironment->commandStreamReceivers[0u]->initializeTagAllocation(); } std::unique_ptr aubExecutionEnvironment(new AubExecutionEnvironment); 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 fb0ca77342..3a864c8010 100644 --- a/unit_tests/command_stream/create_command_stream_receiver_tests.cpp +++ b/unit_tests/command_stream/create_command_stream_receiver_tests.cpp @@ -56,13 +56,13 @@ HWTEST_P(CreateCommandStreamReceiverTest, givenCreateCommandStreamWhenCsrIsSetTo overrideCommandStreamReceiverCreation = true; DebugManager.flags.SetCommandStreamReceiver.set(csrType); ExecutionEnvironment executionEnvironment; - executionEnvironment.commandStreamReceiver.reset(createCommandStream(&hwInfo, executionEnvironment)); + executionEnvironment.commandStreamReceivers.push_back(std::unique_ptr(createCommandStream(&hwInfo, executionEnvironment))); if (csrType < CommandStreamReceiverType::CSR_TYPES_NUM) { - EXPECT_NE(nullptr, executionEnvironment.commandStreamReceiver.get()); - executionEnvironment.memoryManager.reset(executionEnvironment.commandStreamReceiver->createMemoryManager(false, false)); + EXPECT_NE(nullptr, executionEnvironment.commandStreamReceivers[0u].get()); + executionEnvironment.memoryManager.reset(executionEnvironment.commandStreamReceivers[0u]->createMemoryManager(false, false)); EXPECT_NE(nullptr, executionEnvironment.memoryManager.get()); } else { - EXPECT_EQ(nullptr, executionEnvironment.commandStreamReceiver.get()); + EXPECT_EQ(nullptr, executionEnvironment.commandStreamReceivers[0u]); EXPECT_EQ(nullptr, executionEnvironment.memoryManager.get()); } } diff --git a/unit_tests/device/device_tests.cpp b/unit_tests/device/device_tests.cpp index 5aaa22ac8f..b3e4402ff6 100644 --- a/unit_tests/device/device_tests.cpp +++ b/unit_tests/device/device_tests.cpp @@ -199,6 +199,19 @@ TEST(DeviceCreation, givenMultiDeviceWhenTheyAreCreatedThenEachDeviceHasSeperate EXPECT_EQ(1u, device2->getDeviceIndex()); } +TEST(DeviceCreation, givenMultiDeviceWhenTheyAreCreatedThenEachDeviceHasSeperateCommandStreamReceiver) { + ExecutionEnvironment executionEnvironment; + executionEnvironment.incRefInternal(); + auto device = std::unique_ptr(Device::create(nullptr, &executionEnvironment, 0u)); + 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()); +} + TEST(DeviceCreation, givenFtrSimulationModeFlagTrueWhenNoOtherSimulationFlagsArePresentThenIsSimulationReturnsTrue) { FeatureTable skuTable = *platformDevices[0]->pSkuTable; skuTable.ftrSimulationMode = true; diff --git a/unit_tests/execution_environment/execution_environment_tests.cpp b/unit_tests/execution_environment/execution_environment_tests.cpp index a3e287c2d6..dcbde01d76 100644 --- a/unit_tests/execution_environment/execution_environment_tests.cpp +++ b/unit_tests/execution_environment/execution_environment_tests.cpp @@ -85,7 +85,7 @@ TEST(ExecutionEnvironment, givenPlatformWhenItIsCreatedThenItCreatesCommandStrea Platform platform; auto executionEnvironment = platform.peekExecutionEnvironment(); platform.initialize(); - EXPECT_NE(nullptr, executionEnvironment->commandStreamReceiver); + EXPECT_NE(nullptr, executionEnvironment->commandStreamReceivers[0u].get()); } TEST(ExecutionEnvironment, givenPlatformWhenItIsCreatedThenItCreatesMemoryManagerInExecutionEnvironment) { @@ -105,18 +105,42 @@ TEST(ExecutionEnvironment, givenDeviceWhenItIsDestroyedThenMemoryManagerIsStillA TEST(ExecutionEnvironment, givenExecutionEnvironmentWhenInitializeCommandStreamReceiverIsCalledThenItIsInitalized) { std::unique_ptr executionEnvironment(new ExecutionEnvironment); - executionEnvironment->initializeCommandStreamReceiver(platformDevices[0]); - EXPECT_NE(nullptr, executionEnvironment->commandStreamReceiver); + executionEnvironment->initializeCommandStreamReceiver(platformDevices[0], 0u); + EXPECT_NE(nullptr, executionEnvironment->commandStreamReceivers[0u]); +} + +TEST(ExecutionEnvironment, givenExecutionEnvironmentWhenInitializeIsCalledWithDifferentDeviceIndexesThenInternalStorageIsResized) { + std::unique_ptr executionEnvironment(new ExecutionEnvironment); + EXPECT_EQ(0u, executionEnvironment->commandStreamReceivers.size()); + executionEnvironment->initializeCommandStreamReceiver(platformDevices[0], 0u); + EXPECT_EQ(1u, executionEnvironment->commandStreamReceivers.size()); + EXPECT_NE(nullptr, executionEnvironment->commandStreamReceivers[0u]); + executionEnvironment->initializeCommandStreamReceiver(platformDevices[0], 1u); + EXPECT_EQ(2u, executionEnvironment->commandStreamReceivers.size()); + EXPECT_NE(nullptr, executionEnvironment->commandStreamReceivers[1u]); +} + +TEST(ExecutionEnvironment, givenExecutionEnvironmentWhenInitializeIsCalledMultipleTimesForTheSameIndexThenCommandStreamReceiverIsReused) { + auto executionEnvironment = std::make_unique(); + EXPECT_EQ(0u, executionEnvironment->commandStreamReceivers.size()); + executionEnvironment->initializeCommandStreamReceiver(platformDevices[0], 1u); + + auto currentCommandStreamReceiver = executionEnvironment->commandStreamReceivers[1u].get(); + + executionEnvironment->initializeCommandStreamReceiver(platformDevices[0], 1u); + + EXPECT_EQ(currentCommandStreamReceiver, executionEnvironment->commandStreamReceivers[1u].get()); + EXPECT_EQ(2u, executionEnvironment->commandStreamReceivers.size()); + EXPECT_EQ(nullptr, executionEnvironment->commandStreamReceivers[0u].get()); } TEST(ExecutionEnvironment, givenExecutionEnvironmentWhenInitializeMemoryManagerIsCalledThenItIsInitalized) { - std::unique_ptr executionEnvironment(new ExecutionEnvironment); - executionEnvironment->initializeCommandStreamReceiver(platformDevices[0]); - executionEnvironment->initializeMemoryManager(false, false); + auto executionEnvironment = std::make_unique(); + executionEnvironment->initializeCommandStreamReceiver(platformDevices[0], 0u); + executionEnvironment->initializeMemoryManager(false, false, 0u); EXPECT_NE(nullptr, executionEnvironment->memoryManager); } - -static_assert(sizeof(ExecutionEnvironment) == sizeof(std::mutex) + (is64bit ? 80 : 44), "New members detected in ExecutionEnvironment, please ensure that destruction sequence of objects is correct"); +static_assert(sizeof(ExecutionEnvironment) == sizeof(std::vector>) + sizeof(std::mutex) + (is64bit ? 72 : 40), "New members detected in ExecutionEnvironment, please ensure that destruction sequence of objects is correct"); TEST(ExecutionEnvironment, givenExecutionEnvironmentWithVariousMembersWhenItIsDestroyedThenDeleteSequenceIsSpecified) { uint32_t destructorId = 0u; @@ -150,7 +174,7 @@ TEST(ExecutionEnvironment, givenExecutionEnvironmentWithVariousMembersWhenItIsDe executionEnvironment->gmmHelper = std::make_unique(destructorId, platformDevices[0]); executionEnvironment->osInterface = std::make_unique(destructorId); executionEnvironment->memoryManager = std::make_unique(destructorId); - executionEnvironment->commandStreamReceiver = std::make_unique(destructorId); + executionEnvironment->commandStreamReceivers.push_back(std::make_unique(destructorId)); executionEnvironment->builtins = std::make_unique(destructorId); executionEnvironment->compilerInterface = std::make_unique(destructorId); executionEnvironment->sourceLevelDebugger = std::make_unique(destructorId); @@ -166,7 +190,7 @@ TEST(ExecutionEnvironment, givenMultipleDevicesWhenTheyAreCreatedTheyAllReuseThe auto memoryManager = device->getMemoryManager(); std::unique_ptr device2(Device::create(nullptr, executionEnvironment, 1u)); - EXPECT_EQ(&commandStreamReceiver, &device->getCommandStreamReceiver()); + EXPECT_NE(&commandStreamReceiver, &device2->getCommandStreamReceiver()); EXPECT_EQ(memoryManager, device2->getMemoryManager()); } @@ -176,8 +200,8 @@ HWTEST_F(ExecutionEnvironmentHw, givenExecutionEnvironmentWhenCommandStreamRecei ExecutionEnvironment executionEnvironment; HardwareInfo localHwInfo = *platformDevices[0]; localHwInfo.capabilityTable.ftrRenderCompressedBuffers = true; - executionEnvironment.initializeCommandStreamReceiver(&localHwInfo); - auto csr = static_cast *>(executionEnvironment.commandStreamReceiver.get()); + executionEnvironment.initializeCommandStreamReceiver(&localHwInfo, 0u); + auto csr = static_cast *>(executionEnvironment.commandStreamReceivers[0u].get()); ASSERT_NE(nullptr, csr); EXPECT_TRUE(csr->createPageTableManagerCalled); } @@ -186,9 +210,9 @@ HWTEST_F(ExecutionEnvironmentHw, givenExecutionEnvironmentWhenCommandStreamRecei ExecutionEnvironment executionEnvironment; HardwareInfo localHwInfo = *platformDevices[0]; localHwInfo.capabilityTable.ftrRenderCompressedImages = true; - executionEnvironment.initializeCommandStreamReceiver(&localHwInfo); - EXPECT_NE(nullptr, executionEnvironment.commandStreamReceiver); - auto csr = static_cast *>(executionEnvironment.commandStreamReceiver.get()); + executionEnvironment.initializeCommandStreamReceiver(&localHwInfo, 0u); + EXPECT_NE(nullptr, executionEnvironment.commandStreamReceivers[0]); + auto csr = static_cast *>(executionEnvironment.commandStreamReceivers[0u].get()); ASSERT_NE(nullptr, csr); EXPECT_TRUE(csr->createPageTableManagerCalled); } diff --git a/unit_tests/mocks/mock_device.cpp b/unit_tests/mocks/mock_device.cpp index 0bfa561e7e..5a38c9db63 100644 --- a/unit_tests/mocks/mock_device.cpp +++ b/unit_tests/mocks/mock_device.cpp @@ -33,7 +33,8 @@ using namespace OCLRT; MockDevice::MockDevice(const HardwareInfo &hwInfo) : MockDevice(hwInfo, new ExecutionEnvironment, 0u) { CommandStreamReceiver *commandStreamReceiver = createCommandStream(&hwInfo, *this->executionEnvironment); - executionEnvironment->commandStreamReceiver.reset(commandStreamReceiver); + executionEnvironment->commandStreamReceivers.resize(getDeviceIndex() + 1); + executionEnvironment->commandStreamReceivers[getDeviceIndex()].reset(commandStreamReceiver); commandStreamReceiver->setMemoryManager(this->mockMemoryManager.get()); this->executionEnvironment->memoryManager = std::move(this->mockMemoryManager); this->commandStreamReceiver = commandStreamReceiver; @@ -47,8 +48,10 @@ OCLRT::MockDevice::MockDevice(const HardwareInfo &hwInfo, ExecutionEnvironment * void MockDevice::setMemoryManager(MemoryManager *memoryManager) { executionEnvironment->memoryManager.reset(memoryManager); - if (executionEnvironment->commandStreamReceiver) { - executionEnvironment->commandStreamReceiver->setMemoryManager(memoryManager); + for (auto &commandStreamReceiver : executionEnvironment->commandStreamReceivers) { + if (commandStreamReceiver) { + commandStreamReceiver->setMemoryManager(memoryManager); + } } } @@ -65,19 +68,19 @@ bool MockDevice::hasDriverInfo() { }; void MockDevice::injectMemoryManager(MockMemoryManager *memoryManager) { - memoryManager->setCommandStreamReceiver(executionEnvironment->commandStreamReceiver.get()); - executionEnvironment->commandStreamReceiver->setMemoryManager(memoryManager); + memoryManager->setCommandStreamReceiver(executionEnvironment->commandStreamReceivers[getDeviceIndex()].get()); + executionEnvironment->commandStreamReceivers[getDeviceIndex()]->setMemoryManager(memoryManager); setMemoryManager(memoryManager); } void MockDevice::resetCommandStreamReceiver(CommandStreamReceiver *newCsr) { - executionEnvironment->commandStreamReceiver.reset(newCsr); - executionEnvironment->commandStreamReceiver->setMemoryManager(executionEnvironment->memoryManager.get()); - executionEnvironment->commandStreamReceiver->initializeTagAllocation(); - executionEnvironment->commandStreamReceiver->setPreemptionCsrAllocation(preemptionAllocation); - executionEnvironment->memoryManager->csr = executionEnvironment->commandStreamReceiver.get(); + executionEnvironment->commandStreamReceivers[getDeviceIndex()].reset(newCsr); + executionEnvironment->commandStreamReceivers[getDeviceIndex()]->setMemoryManager(executionEnvironment->memoryManager.get()); + executionEnvironment->commandStreamReceivers[getDeviceIndex()]->initializeTagAllocation(); + executionEnvironment->commandStreamReceivers[getDeviceIndex()]->setPreemptionCsrAllocation(preemptionAllocation); + executionEnvironment->memoryManager->csr = executionEnvironment->commandStreamReceivers[getDeviceIndex()].get(); this->commandStreamReceiver = newCsr; - this->tagAddress = executionEnvironment->commandStreamReceiver->getTagAddress(); + this->tagAddress = executionEnvironment->commandStreamReceivers[getDeviceIndex()]->getTagAddress(); } OCLRT::FailMemoryManager::FailMemoryManager() : MockMemoryManager() { diff --git a/unit_tests/mocks/mock_device.h b/unit_tests/mocks/mock_device.h index d174f313dd..102ea5736f 100644 --- a/unit_tests/mocks/mock_device.h +++ b/unit_tests/mocks/mock_device.h @@ -121,7 +121,7 @@ class MockDevice : public Device { size_t alignment = 256 * MemoryConstants::kiloByte; bool uncacheable = getWaTable()->waCSRUncachable; this->preemptionAllocation = executionEnvironment->memoryManager->allocateGraphicsMemory(requiredSize, alignment, false, uncacheable); - executionEnvironment->commandStreamReceiver->setPreemptionCsrAllocation(preemptionAllocation); + this->commandStreamReceiver->setPreemptionCsrAllocation(preemptionAllocation); } } } 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 18b4885ca8..ea4767d37d 100644 --- a/unit_tests/os_interface/windows/device_command_stream_tests.cpp +++ b/unit_tests/os_interface/windows/device_command_stream_tests.cpp @@ -146,9 +146,9 @@ class WddmCommandStreamWithMockGdiFixture { executionEnvironment->osInterface = std::make_unique(); executionEnvironment->osInterface->get()->setWddm(wddm); DebugManager.flags.CsrDispatchMode.set(static_cast(DispatchMode::ImmediateDispatch)); - executionEnvironment->commandStreamReceiver = std::make_unique>(*platformDevices[0], - *executionEnvironment); - this->csr = static_cast *>(executionEnvironment->commandStreamReceiver.get()); + executionEnvironment->commandStreamReceivers.push_back(std::make_unique>(*platformDevices[0], + *executionEnvironment)); + this->csr = static_cast *>(executionEnvironment->commandStreamReceivers[0].get()); memManager = csr->createMemoryManager(false, false); ASSERT_NE(nullptr, memManager); executionEnvironment->memoryManager.reset(memManager); @@ -269,11 +269,11 @@ TEST(WddmPreemptionHeaderTests, givenWddmCommandStreamReceiverWhenPreemptionIsOf ExecutionEnvironment executionEnvironment; executionEnvironment.osInterface = std::make_unique(); executionEnvironment.osInterface->get()->setWddm(wddm); - executionEnvironment.commandStreamReceiver = std::make_unique>(localHwInfo, - executionEnvironment); - executionEnvironment.memoryManager.reset(executionEnvironment.commandStreamReceiver->createMemoryManager(false, false)); + executionEnvironment.commandStreamReceivers.push_back(std::make_unique>(localHwInfo, + executionEnvironment)); + executionEnvironment.memoryManager.reset(executionEnvironment.commandStreamReceivers[0u]->createMemoryManager(false, false)); - executionEnvironment.commandStreamReceiver->overrideDispatchPolicy(DispatchMode::ImmediateDispatch); + executionEnvironment.commandStreamReceivers[0u]->overrideDispatchPolicy(DispatchMode::ImmediateDispatch); auto commandBuffer = executionEnvironment.memoryManager->allocateGraphicsMemory(4096); LinearStream cs(commandBuffer); @@ -281,7 +281,7 @@ TEST(WddmPreemptionHeaderTests, givenWddmCommandStreamReceiverWhenPreemptionIsOf BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; OsContext *osContext = new OsContext(executionEnvironment.osInterface.get()); osContext->incRefInternal(); - executionEnvironment.commandStreamReceiver->flush(batchBuffer, EngineType::ENGINE_RCS, &executionEnvironment.commandStreamReceiver->getResidencyAllocations(), *osContext); + executionEnvironment.commandStreamReceivers[0u]->flush(batchBuffer, EngineType::ENGINE_RCS, &executionEnvironment.commandStreamReceivers[0u]->getResidencyAllocations(), *osContext); auto commandHeader = wddm->submitResult.commandHeaderSubmitted; COMMAND_BUFFER_HEADER *pHeader = reinterpret_cast(commandHeader); @@ -297,10 +297,10 @@ TEST(WddmPreemptionHeaderTests, givenWddmCommandStreamReceiverWhenPreemptionIsOn ExecutionEnvironment executionEnvironment; executionEnvironment.osInterface = std::make_unique(); executionEnvironment.osInterface->get()->setWddm(wddm); - executionEnvironment.commandStreamReceiver = std::make_unique>(localHwInfo, - executionEnvironment); - executionEnvironment.memoryManager.reset(executionEnvironment.commandStreamReceiver->createMemoryManager(false, false)); - executionEnvironment.commandStreamReceiver->overrideDispatchPolicy(DispatchMode::ImmediateDispatch); + executionEnvironment.commandStreamReceivers.push_back(std::make_unique>(localHwInfo, + executionEnvironment)); + executionEnvironment.memoryManager.reset(executionEnvironment.commandStreamReceivers[0u]->createMemoryManager(false, false)); + executionEnvironment.commandStreamReceivers[0u]->overrideDispatchPolicy(DispatchMode::ImmediateDispatch); auto commandBuffer = executionEnvironment.memoryManager->allocateGraphicsMemory(4096); LinearStream cs(commandBuffer); @@ -308,7 +308,7 @@ TEST(WddmPreemptionHeaderTests, givenWddmCommandStreamReceiverWhenPreemptionIsOn BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; OsContext *osContext = new OsContext(executionEnvironment.osInterface.get()); osContext->incRefInternal(); - executionEnvironment.commandStreamReceiver->flush(batchBuffer, EngineType::ENGINE_RCS, &executionEnvironment.commandStreamReceiver->getResidencyAllocations(), *osContext); + executionEnvironment.commandStreamReceivers[0u]->flush(batchBuffer, EngineType::ENGINE_RCS, &executionEnvironment.commandStreamReceivers[0u]->getResidencyAllocations(), *osContext); auto commandHeader = wddm->submitResult.commandHeaderSubmitted; COMMAND_BUFFER_HEADER *pHeader = reinterpret_cast(commandHeader); @@ -934,7 +934,7 @@ HWTEST_F(WddmCsrCompressionTests, givenEnabledCompressionWhenFlushingThenInitTra mockWddmCsr->createPageTableManager(); mockWddmCsr->overrideDispatchPolicy(DispatchMode::BatchedDispatch); - executionEnvironment->commandStreamReceiver.reset(mockWddmCsr); + executionEnvironment->commandStreamReceivers.push_back(std::unique_ptr(mockWddmCsr)); auto mockMngr = reinterpret_cast(myMockWddm->getPageTableManager()); std::unique_ptr device(Device::create(platformDevices[0], executionEnvironment, 0u)); @@ -975,7 +975,7 @@ HWTEST_F(WddmCsrCompressionTests, givenDisabledCompressionWhenFlushingThenDontIn executionEnvironment->osInterface = std::make_unique(); executionEnvironment->osInterface->get()->setWddm(myMockWddm); auto mockWddmCsr = new MockWddmCsr(hwInfo, *executionEnvironment); - executionEnvironment->commandStreamReceiver.reset(mockWddmCsr); + executionEnvironment->commandStreamReceivers.push_back(std::unique_ptr(mockWddmCsr)); mockWddmCsr->overrideDispatchPolicy(DispatchMode::BatchedDispatch); std::unique_ptr device(Device::create(platformDevices[0], executionEnvironment, 0u));