diff --git a/runtime/command_stream/definitions/engine_node.h b/runtime/command_stream/definitions/engine_node.h index 80640a4876..c87a24125f 100644 --- a/runtime/command_stream/definitions/engine_node.h +++ b/runtime/command_stream/definitions/engine_node.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017-2018 Intel Corporation + * Copyright (C) 2017-2019 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -33,21 +33,13 @@ struct EngineInstanceT { int id; }; +constexpr EngineInstanceT lowPriorityGpgpuEngine{ENGINE_RCS, 1}; static constexpr std::array allEngineInstances = {{ {ENGINE_RCS, 0}, - {ENGINE_RCS, 1}, + lowPriorityGpgpuEngine, {ENGINE_BCS}, {ENGINE_VCS}, {ENGINE_VECS}, }}; -static constexpr std::array gpgpuEngineInstances = {{ - {ENGINE_RCS, 0}, - {ENGINE_RCS, 1}, -}}; - -static_assert(gpgpuEngineInstances[EngineInstanceConstants::lowPriorityGpgpuEngineIndex].type == EngineType::ENGINE_RCS && - gpgpuEngineInstances[EngineInstanceConstants::lowPriorityGpgpuEngineIndex].id == 1, - "{RCS,1} is low priority engine"); - } // namespace OCLRT diff --git a/runtime/device/device.cpp b/runtime/device/device.cpp index 3a1183a414..0c6f45ffe7 100644 --- a/runtime/device/device.cpp +++ b/runtime/device/device.cpp @@ -84,9 +84,7 @@ Device::~Device() { } for (auto &engine : engines) { - if (engine.commandStreamReceiver) { - engine.commandStreamReceiver->flushBatchedSubmissions(); - } + engine.commandStreamReceiver->flushBatchedSubmissions(); } if (deviceInfo.sourceLevelDebuggerActive && executionEnvironment->sourceLevelDebugger) { @@ -166,26 +164,27 @@ bool Device::createDeviceImpl(const HardwareInfo *pHwInfo, Device &outDevice) { bool Device::createEngines(const HardwareInfo *pHwInfo, Device &outDevice) { auto executionEnvironment = outDevice.executionEnvironment; auto defaultEngineType = getChosenEngineType(*pHwInfo); + auto &gpgpuEngines = HwHelper::get(pHwInfo->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances(); - for (uint32_t deviceCsrIndex = 0; deviceCsrIndex < gpgpuEngineInstances.size(); deviceCsrIndex++) { + for (uint32_t deviceCsrIndex = 0; deviceCsrIndex < gpgpuEngines.size(); deviceCsrIndex++) { if (!executionEnvironment->initializeCommandStreamReceiver(pHwInfo, outDevice.getDeviceIndex(), deviceCsrIndex)) { return false; } executionEnvironment->initializeMemoryManager(outDevice.getEnabled64kbPages(), outDevice.getEnableLocalMemory(), outDevice.getDeviceIndex(), deviceCsrIndex); - auto osContext = executionEnvironment->memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[deviceCsrIndex], outDevice.preemptionMode); + auto osContext = executionEnvironment->memoryManager->createAndRegisterOsContext(gpgpuEngines[deviceCsrIndex], outDevice.preemptionMode); auto commandStreamReceiver = executionEnvironment->commandStreamReceivers[outDevice.getDeviceIndex()][deviceCsrIndex].get(); commandStreamReceiver->setupContext(*osContext); if (!commandStreamReceiver->initializeTagAllocation()) { return false; } - if (gpgpuEngineInstances[deviceCsrIndex].type == defaultEngineType && gpgpuEngineInstances[deviceCsrIndex].id == 0) { + if (gpgpuEngines[deviceCsrIndex].type == defaultEngineType && gpgpuEngines[deviceCsrIndex].id == 0) { outDevice.defaultEngineIndex = deviceCsrIndex; } - outDevice.engines[deviceCsrIndex] = {commandStreamReceiver, osContext}; + outDevice.engines.push_back({commandStreamReceiver, osContext}); } return true; } @@ -271,9 +270,7 @@ bool Device::isSourceLevelDebuggerActive() const { void Device::initMaxPowerSavingMode() { for (auto &engine : engines) { - if (engine.commandStreamReceiver) { - engine.commandStreamReceiver->peekKmdNotifyHelper()->initMaxPowerSavingMode(); - } + engine.commandStreamReceiver->peekKmdNotifyHelper()->initMaxPowerSavingMode(); } } } // namespace OCLRT diff --git a/runtime/device/device.h b/runtime/device/device.h index 7889d30333..3fedb583dc 100644 --- a/runtime/device/device.h +++ b/runtime/device/device.h @@ -151,7 +151,7 @@ class Device : public BaseObject<_cl_device_id> { std::unique_ptr driverInfo; std::unique_ptr performanceCounters; - std::array engines = {{}}; + std::vector engines; void *slmWindowStartAddress = nullptr; diff --git a/runtime/execution_environment/execution_environment.cpp b/runtime/execution_environment/execution_environment.cpp index 939dab4979..28858910f3 100644 --- a/runtime/execution_environment/execution_environment.cpp +++ b/runtime/execution_environment/execution_environment.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Intel Corporation + * Copyright (C) 2018-2019 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -38,6 +38,9 @@ bool ExecutionEnvironment::initializeCommandStreamReceiver(const HardwareInfo *p commandStreamReceivers.resize(deviceIndex + 1); } + if (deviceCsrIndex + 1 > commandStreamReceivers[deviceIndex].size()) { + commandStreamReceivers[deviceIndex].resize(deviceCsrIndex + 1); + } if (this->commandStreamReceivers[deviceIndex][deviceCsrIndex]) { return true; } diff --git a/runtime/execution_environment/execution_environment.h b/runtime/execution_environment/execution_environment.h index d47e6df18c..b3713314e5 100644 --- a/runtime/execution_environment/execution_environment.h +++ b/runtime/execution_environment/execution_environment.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Intel Corporation + * Copyright (C) 2018-2019 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -24,7 +24,7 @@ class BuiltIns; struct HardwareInfo; class OSInterface; -using CsrContainer = std::vector, EngineInstanceConstants::numGpgpuEngineInstances>>; +using CsrContainer = std::vector>>; class ExecutionEnvironment : public ReferenceTrackedObject { private: diff --git a/runtime/helpers/hw_helper.h b/runtime/helpers/hw_helper.h index 81827a81a9..beced3fc21 100644 --- a/runtime/helpers/hw_helper.h +++ b/runtime/helpers/hw_helper.h @@ -1,12 +1,12 @@ /* - * Copyright (C) 2017-2018 Intel Corporation + * Copyright (C) 2017-2019 Intel Corporation * * SPDX-License-Identifier: MIT * */ #pragma once -#include "runtime/api/cl_types.h" +#include "CL/cl.h" #include "runtime/gen_common/aub_mapper.h" #include "runtime/gen_common/hw_cmds.h" #include "runtime/command_stream/linear_stream.h" @@ -54,6 +54,7 @@ class HwHelper { uint32_t surfaceType, bool forceNonAuxMode) = 0; virtual size_t getScratchSpaceOffsetFor64bit() = 0; + virtual const std::vector getGpgpuEngineInstances() const = 0; protected: HwHelper() = default; @@ -133,6 +134,8 @@ class HwHelperHw : public HwHelper { size_t getScratchSpaceOffsetFor64bit() override; + const std::vector getGpgpuEngineInstances() const override; + protected: HwHelperHw() = default; }; diff --git a/runtime/helpers/hw_helper_common.inl b/runtime/helpers/hw_helper_common.inl index d650690894..a466660b90 100644 --- a/runtime/helpers/hw_helper_common.inl +++ b/runtime/helpers/hw_helper_common.inl @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017-2018 Intel Corporation + * Copyright (C) 2017-2019 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -162,4 +162,11 @@ size_t HwHelperHw::getScratchSpaceOffsetFor64bit() { return 4096; } +template +const std::vector HwHelperHw::getGpgpuEngineInstances() const { + constexpr std::array gpgpuEngineInstances = {{{ENGINE_RCS, 0}, + lowPriorityGpgpuEngine}}; + return std::vector(gpgpuEngineInstances.begin(), gpgpuEngineInstances.end()); +}; + } // namespace OCLRT diff --git a/runtime/memory_manager/memory_manager.cpp b/runtime/memory_manager/memory_manager.cpp index a016346017..e34a3fb33f 100644 --- a/runtime/memory_manager/memory_manager.cpp +++ b/runtime/memory_manager/memory_manager.cpp @@ -145,14 +145,12 @@ void MemoryManager::checkGpuUsageAndDestroyGraphicsAllocations(GraphicsAllocatio } for (auto &deviceCsrs : getCommandStreamReceivers()) { for (auto &csr : deviceCsrs) { - if (csr) { - auto osContextId = csr->getOsContext().getContextId(); - auto allocationTaskCount = gfxAllocation->getTaskCount(osContextId); - if (gfxAllocation->isUsedByOsContext(osContextId) && - allocationTaskCount > *csr->getTagAddress()) { - csr->getInternalAllocationStorage()->storeAllocation(std::unique_ptr(gfxAllocation), TEMPORARY_ALLOCATION); - return; - } + auto osContextId = csr->getOsContext().getContextId(); + auto allocationTaskCount = gfxAllocation->getTaskCount(osContextId); + if (gfxAllocation->isUsedByOsContext(osContextId) && + allocationTaskCount > *csr->getTagAddress()) { + csr->getInternalAllocationStorage()->storeAllocation(std::unique_ptr(gfxAllocation), TEMPORARY_ALLOCATION); + return; } } } diff --git a/runtime/memory_manager/memory_manager.h b/runtime/memory_manager/memory_manager.h index bc81e01674..1ff536426c 100644 --- a/runtime/memory_manager/memory_manager.h +++ b/runtime/memory_manager/memory_manager.h @@ -28,7 +28,7 @@ struct ImageInfo; enum class PreemptionMode : uint32_t; -using CsrContainer = std::vector, EngineInstanceConstants::numGpgpuEngineInstances>>; +using CsrContainer = std::vector>>; enum AllocationUsage { TEMPORARY_ALLOCATION, diff --git a/runtime/memory_manager/residency.h b/runtime/memory_manager/residency.h index ff093bc921..3eeb853587 100644 --- a/runtime/memory_manager/residency.h +++ b/runtime/memory_manager/residency.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017-2018 Intel Corporation + * Copyright (C) 2017-2019 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -11,7 +11,7 @@ #include "engine_node.h" namespace OCLRT { -constexpr uint32_t maxOsContextCount = 4u * static_cast(gpgpuEngineInstances.size()); +constexpr uint32_t maxOsContextCount = 4u * static_cast(EngineInstanceConstants::numGpgpuEngineInstances); struct ResidencyData { ResidencyData() { diff --git a/runtime/os_interface/linux/os_context_linux.cpp b/runtime/os_interface/linux/os_context_linux.cpp index 3831f864fe..84bbdbf6bc 100644 --- a/runtime/os_interface/linux/os_context_linux.cpp +++ b/runtime/os_interface/linux/os_context_linux.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Intel Corporation + * Copyright (C) 2018-2019 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -26,8 +26,8 @@ OsContextLinux::OsContextImpl(Drm &drm, EngineInstanceT engineType) : drm(drm) { engineFlag = DrmEngineMapper::engineNodeMap(engineType.type); this->drmContextId = drm.createDrmContext(); if (drm.isPreemptionSupported() && - engineType.type == gpgpuEngineInstances[EngineInstanceConstants::lowPriorityGpgpuEngineIndex].type && - engineType.id == gpgpuEngineInstances[EngineInstanceConstants::lowPriorityGpgpuEngineIndex].id) { + engineType.type == lowPriorityGpgpuEngine.type && + engineType.id == lowPriorityGpgpuEngine.id) { drm.setLowPriorityContextParam(this->drmContextId); } } diff --git a/unit_tests/command_stream/aub_command_stream_receiver_1_tests.cpp b/unit_tests/command_stream/aub_command_stream_receiver_1_tests.cpp index 3c30cdd71b..58ae968638 100644 --- a/unit_tests/command_stream/aub_command_stream_receiver_1_tests.cpp +++ b/unit_tests/command_stream/aub_command_stream_receiver_1_tests.cpp @@ -193,7 +193,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWithAubMana } HWTEST_F(AubCommandStreamReceiverTests, givenAubCsrWhenOsContextIsSetThenCreateHardwareContext) { - OsContext osContext(nullptr, 0, gpgpuEngineInstances[0], PreemptionMode::Disabled); + OsContext osContext(nullptr, 0, HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances()[0], PreemptionMode::Disabled); std::string fileName = "file_name.aub"; MockAubManager *mockManager = new MockAubManager(); MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, fileName); @@ -281,8 +281,8 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenMultipl auto aubCsr1 = std::make_unique>(**platformDevices, "", true, executionEnvironment); auto aubCsr2 = std::make_unique>(**platformDevices, "", true, executionEnvironment); - auto engineType = gpgpuEngineInstances[0].type; - auto engineIndex = aubCsr1->getEngineIndex(gpgpuEngineInstances[0]); + auto engineType = HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances()[0].type; + auto engineIndex = aubCsr1->getEngineIndex(HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances()[0]); aubCsr1->initializeEngine(engineIndex); EXPECT_NE(0u, aubCsr1->engineInfoTable[engineType].ggttLRCA); diff --git a/unit_tests/command_stream/aub_command_stream_receiver_2_tests.cpp b/unit_tests/command_stream/aub_command_stream_receiver_2_tests.cpp index 485411840f..8ff1781ce9 100644 --- a/unit_tests/command_stream/aub_command_stream_receiver_2_tests.cpp +++ b/unit_tests/command_stream/aub_command_stream_receiver_2_tests.cpp @@ -700,7 +700,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenEngineI auto aubCsr = std::make_unique>(**platformDevices, "", true, executionEnvironment); EXPECT_NE(nullptr, aubCsr); - auto engineIndex = aubCsr->getEngineIndex(gpgpuEngineInstances[0]); + auto engineIndex = aubCsr->getEngineIndex(HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances()[0]); aubCsr->initializeEngine(engineIndex); EXPECT_NE(0u, aubCsr->handle); diff --git a/unit_tests/command_stream/aub_file_stream_tests.cpp b/unit_tests/command_stream/aub_file_stream_tests.cpp index 624f6c2c4d..6d93e22cfb 100644 --- a/unit_tests/command_stream/aub_file_stream_tests.cpp +++ b/unit_tests/command_stream/aub_file_stream_tests.cpp @@ -344,7 +344,7 @@ HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenInitializeEngineIs comments.push_back(std::string(str)); return true; })); - auto engineIndex = aubCsr->getEngineIndex(gpgpuEngineInstances[0]); + auto engineIndex = aubCsr->getEngineIndex(HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances()[0]); aubCsr->initializeEngine(engineIndex); #define QTR(a) #a 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 dd92597ea7..5070128484 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 @@ -663,7 +663,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCsrInBatchingModeWhenTotalRes executionEnvironment.memoryManager.reset(mockedMemoryManager); auto mockCsr = new MockCsrHw2(*platformDevices[0], executionEnvironment); executionEnvironment.commandStreamReceivers.resize(1); - executionEnvironment.commandStreamReceivers[0][0].reset(mockCsr); + 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 b781562405..ea78a95d19 100644 --- a/unit_tests/command_stream/command_stream_receiver_tests.cpp +++ b/unit_tests/command_stream/command_stream_receiver_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Intel Corporation + * Copyright (C) 2018-2019 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -331,7 +331,7 @@ TEST(CommandStreamReceiverSimpleTest, givenCommandStreamReceiverWhenItIsDestroye mockGraphicsAllocation->destructorCalled = &destructorCalled; ExecutionEnvironment executionEnvironment; executionEnvironment.commandStreamReceivers.resize(1); - executionEnvironment.commandStreamReceivers[0][0] = (std::make_unique(executionEnvironment)); + 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); @@ -344,7 +344,7 @@ TEST(CommandStreamReceiverSimpleTest, givenCommandStreamReceiverWhenInitializeTa ExecutionEnvironment executionEnvironment; auto csr = new MockCommandStreamReceiver(executionEnvironment); executionEnvironment.commandStreamReceivers.resize(1); - executionEnvironment.commandStreamReceivers[0][0].reset(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); @@ -360,7 +360,7 @@ TEST(CommandStreamReceiverSimpleTest, givenNullHardwareDebugModeWhenInitializeTa ExecutionEnvironment executionEnvironment; executionEnvironment.commandStreamReceivers.resize(1); auto csr = new MockCommandStreamReceiver(executionEnvironment); - executionEnvironment.commandStreamReceivers[0][0].reset(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/command_stream_receiver_with_aub_dump_tests.cpp b/unit_tests/command_stream/command_stream_receiver_with_aub_dump_tests.cpp index 51a289e251..5e84680eab 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 @@ -135,7 +135,7 @@ HWTEST_F(CommandStreamReceiverWithAubDumpSimpleTest, givenCsrWithAubDumpWhenSett ExecutionEnvironment executionEnvironment; CommandStreamReceiverWithAUBDump> csrWithAubDump(*platformDevices[0], executionEnvironment); - OsContext osContext(nullptr, 0, gpgpuEngineInstances[0], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); + OsContext osContext(nullptr, 0, HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances()[0], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); csrWithAubDump.setupContext(osContext); EXPECT_EQ(&osContext, &csrWithAubDump.getOsContext()); 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 0acf301197..de6126b204 100644 --- a/unit_tests/command_stream/create_command_stream_receiver_tests.cpp +++ b/unit_tests/command_stream/create_command_stream_receiver_tests.cpp @@ -44,8 +44,8 @@ HWTEST_P(CreateCommandStreamReceiverTest, givenCreateCommandStreamWhenCsrIsSetTo VariableBackup backup(&overrideCommandStreamReceiverCreation, true); DebugManager.flags.SetCommandStreamReceiver.set(csrType); executionEnvironment->commandStreamReceivers.resize(1); - executionEnvironment->commandStreamReceivers[0][0] = std::unique_ptr(createCommandStream(hwInfo, - *executionEnvironment)); + executionEnvironment->commandStreamReceivers[0].push_back(std::unique_ptr(createCommandStream(hwInfo, + *executionEnvironment))); if (csrType < CommandStreamReceiverType::CSR_TYPES_NUM) { EXPECT_NE(nullptr, executionEnvironment->commandStreamReceivers[0][0].get()); diff --git a/unit_tests/command_stream/tbx_command_stream_tests.cpp b/unit_tests/command_stream/tbx_command_stream_tests.cpp index 7f61bfc1a9..d4eda6680f 100644 --- a/unit_tests/command_stream/tbx_command_stream_tests.cpp +++ b/unit_tests/command_stream/tbx_command_stream_tests.cpp @@ -444,7 +444,7 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCsrWhenHardwareContextIsCreatedThenTbxSt } HWTEST_F(TbxCommandStreamTests, givenTbxCsrWhenOsContextIsSetThenCreateHardwareContext) { - OsContext osContext(nullptr, 0, gpgpuEngineInstances[0], PreemptionMode::Disabled); + OsContext osContext(nullptr, 0, HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances()[0], PreemptionMode::Disabled); std::string fileName = "file_name.aub"; MockAubManager *mockManager = new MockAubManager(); MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, fileName); diff --git a/unit_tests/device/device_tests.cpp b/unit_tests/device/device_tests.cpp index f75fa16f1b..072c945208 100644 --- a/unit_tests/device/device_tests.cpp +++ b/unit_tests/device/device_tests.cpp @@ -9,6 +9,7 @@ #include "runtime/helpers/options.h" #include "runtime/indirect_heap/indirect_heap.h" #include "runtime/os_interface/os_context.h" +#include "runtime/helpers/hw_helper.h" #include "test.h" #include "unit_tests/fixtures/device_fixture.h" #include "unit_tests/helpers/debug_manager_state_restore.h" @@ -45,7 +46,7 @@ TEST_F(DeviceTest, getSupportedClVersion) { } TEST_F(DeviceTest, getTagAddress) { - for (uint32_t i = 0; i < static_cast(gpgpuEngineInstances.size()); i++) { + for (uint32_t i = 0; i < static_cast(HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances().size()); i++) { auto tagAddress = pDevice->getEngine(i).commandStreamReceiver->getTagAddress(); ASSERT_NE(nullptr, const_cast(tagAddress)); EXPECT_EQ(initialHardwareTag, *tagAddress); @@ -151,22 +152,23 @@ TEST(DeviceCreation, givenDefaultHwCsrInDebugVarsWhenDeviceIsCreatedThenIsSimula TEST(DeviceCreation, givenDeviceWhenItIsCreatedThenOsContextIsRegistredInMemoryManager) { auto device = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); auto memoryManager = device->getMemoryManager(); - EXPECT_EQ(gpgpuEngineInstances.size(), memoryManager->getOsContextCount()); + EXPECT_EQ(HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances().size(), memoryManager->getOsContextCount()); } TEST(DeviceCreation, givenMultiDeviceWhenTheyAreCreatedThenEachOsContextHasUniqueId) { ExecutionEnvironment executionEnvironment; executionEnvironment.incRefInternal(); const size_t numDevices = 2; + const auto &numGpgpuEngines = static_cast(HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances().size()); auto device1 = std::unique_ptr(Device::create(nullptr, &executionEnvironment, 0u)); auto device2 = std::unique_ptr(Device::create(nullptr, &executionEnvironment, 1u)); - for (uint32_t i = 0; i < static_cast(gpgpuEngineInstances.size()); i++) { + for (uint32_t i = 0; i < numGpgpuEngines; i++) { EXPECT_EQ(i, device1->getEngine(i).osContext->getContextId()); - EXPECT_EQ(i + static_cast(gpgpuEngineInstances.size()), device2->getEngine(i).osContext->getContextId()); + EXPECT_EQ(i + numGpgpuEngines, device2->getEngine(i).osContext->getContextId()); } - EXPECT_EQ(gpgpuEngineInstances.size() * numDevices, executionEnvironment.memoryManager->getOsContextCount()); + EXPECT_EQ(numGpgpuEngines * numDevices, executionEnvironment.memoryManager->getOsContextCount()); } TEST(DeviceCreation, givenMultiDeviceWhenTheyAreCreatedThenEachDeviceHasSeperateDeviceIndex) { @@ -183,14 +185,15 @@ TEST(DeviceCreation, givenMultiDeviceWhenTheyAreCreatedThenEachDeviceHasSeperate ExecutionEnvironment executionEnvironment; executionEnvironment.incRefInternal(); const size_t numDevices = 2; + const auto &numGpgpuEngines = HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances().size(); auto device1 = std::unique_ptr(Device::create(nullptr, &executionEnvironment, 0u)); auto device2 = std::unique_ptr(Device::create(nullptr, &executionEnvironment, 1u)); EXPECT_EQ(numDevices, executionEnvironment.commandStreamReceivers.size()); - EXPECT_EQ(gpgpuEngineInstances.size(), executionEnvironment.commandStreamReceivers[0].size()); - EXPECT_EQ(gpgpuEngineInstances.size(), executionEnvironment.commandStreamReceivers[1].size()); + EXPECT_EQ(numGpgpuEngines, executionEnvironment.commandStreamReceivers[0].size()); + EXPECT_EQ(numGpgpuEngines, executionEnvironment.commandStreamReceivers[1].size()); - for (uint32_t i = 0; i < static_cast(gpgpuEngineInstances.size()); i++) { + for (uint32_t i = 0; i < static_cast(numGpgpuEngines); i++) { EXPECT_NE(nullptr, executionEnvironment.commandStreamReceivers[0][i]); EXPECT_NE(nullptr, executionEnvironment.commandStreamReceivers[1][i]); EXPECT_EQ(executionEnvironment.commandStreamReceivers[0][i].get(), device1->getEngine(i).commandStreamReceiver); diff --git a/unit_tests/execution_environment/execution_environment_tests.cpp b/unit_tests/execution_environment/execution_environment_tests.cpp index 72b520a913..017c2bd1fe 100644 --- a/unit_tests/execution_environment/execution_environment_tests.cpp +++ b/unit_tests/execution_environment/execution_environment_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Intel Corporation + * Copyright (C) 2018-2019 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -11,6 +11,7 @@ #include "runtime/device/device.h" #include "runtime/execution_environment/execution_environment.h" #include "runtime/gmm_helper/gmm_helper.h" +#include "runtime/helpers/hw_helper.h" #include "runtime/helpers/options.h" #include "runtime/memory_manager/os_agnostic_memory_manager.h" #include "runtime/os_interface/os_interface.h" @@ -121,7 +122,7 @@ TEST(ExecutionEnvironment, givenExecutionEnvironmentWhenInitializeIsCalledMultip executionEnvironment->initializeCommandStreamReceiver(platformDevices[0], 0, 1); EXPECT_EQ(currentCommandStreamReceiver, executionEnvironment->commandStreamReceivers[0][1].get()); - EXPECT_EQ(gpgpuEngineInstances.size(), executionEnvironment->commandStreamReceivers[0].size()); + EXPECT_EQ(2u, executionEnvironment->commandStreamReceivers[0].size()); EXPECT_EQ(nullptr, executionEnvironment->commandStreamReceivers[0][0].get()); } @@ -211,7 +212,7 @@ TEST(ExecutionEnvironment, givenExecutionEnvironmentWithVariousMembersWhenItIsDe executionEnvironment->osInterface = std::make_unique(destructorId); executionEnvironment->memoryManager = std::make_unique(destructorId); executionEnvironment->aubCenter = std::make_unique(destructorId); - executionEnvironment->commandStreamReceivers[0][0] = 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); diff --git a/unit_tests/fixtures/memory_allocator_fixture.h b/unit_tests/fixtures/memory_allocator_fixture.h index a1f9b7cb0c..4f03c90a94 100644 --- a/unit_tests/fixtures/memory_allocator_fixture.h +++ b/unit_tests/fixtures/memory_allocator_fixture.h @@ -24,7 +24,7 @@ class MemoryAllocatorFixture : public MemoryManagementFixture { memoryManager = new OsAgnosticMemoryManager(false, false, *executionEnvironment); executionEnvironment->memoryManager.reset(memoryManager); csr = memoryManager->getDefaultCommandStreamReceiver(0); - csr->setupContext(*memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]))); + csr->setupContext(*memoryManager->createAndRegisterOsContext(HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances()[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 83df397cdf..f2a30f13eb 100644 --- a/unit_tests/fixtures/memory_manager_fixture.cpp +++ b/unit_tests/fixtures/memory_manager_fixture.cpp @@ -19,9 +19,8 @@ void MemoryManagerWithCsrFixture::SetUp() { executionEnvironment.memoryManager.reset(memoryManager); csr->tagAddress = ¤tGpuTag; executionEnvironment.commandStreamReceivers.resize(1); - executionEnvironment.commandStreamReceivers[0][0].reset(csr); - - csr->setupContext(*memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]))); + executionEnvironment.commandStreamReceivers[0].push_back(std::unique_ptr(csr)); + csr->setupContext(*memoryManager->createAndRegisterOsContext(HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances()[0], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]))); } void MemoryManagerWithCsrFixture::TearDown() { diff --git a/unit_tests/gen10/hw_helper_tests_gen10.cpp b/unit_tests/gen10/hw_helper_tests_gen10.cpp index b5d93d8488..6c85896b67 100644 --- a/unit_tests/gen10/hw_helper_tests_gen10.cpp +++ b/unit_tests/gen10/hw_helper_tests_gen10.cpp @@ -1,20 +1,21 @@ /* - * Copyright (C) 2017-2018 Intel Corporation + * Copyright (C) 2017-2019 Intel Corporation * * SPDX-License-Identifier: MIT * */ +#include "unit_tests/helpers/get_gpgpu_engines_tests.inl" #include "unit_tests/helpers/hw_helper_tests.h" -typedef HwHelperTest HwHelperTestCnl; +using HwHelperTestGen10 = HwHelperTest; -GEN10TEST_F(HwHelperTestCnl, getMaxBarriersPerSliceReturnsCorrectSize) { +GEN10TEST_F(HwHelperTestGen10, getMaxBarriersPerSliceReturnsCorrectSize) { auto &helper = HwHelper::get(renderCoreFamily); EXPECT_EQ(32u, helper.getMaxBarrierRegisterPerSlice()); } -GEN10TEST_F(HwHelperTestCnl, whenCnlRevIdForStepCThenSetCapabilityCoherencyFlagFalse) { +GEN10TEST_F(HwHelperTestGen10, whenCnlRevIdForStepCThenSetCapabilityCoherencyFlagFalse) { auto &helper = HwHelper::get(renderCoreFamily); bool coherency = true; @@ -26,7 +27,7 @@ GEN10TEST_F(HwHelperTestCnl, whenCnlRevIdForStepCThenSetCapabilityCoherencyFlagF EXPECT_FALSE(coherency); } -GEN10TEST_F(HwHelperTestCnl, whenCnlRevIdForStepDThenSetCapabilityCoherencyFlagTrue) { +GEN10TEST_F(HwHelperTestGen10, whenCnlRevIdForStepDThenSetCapabilityCoherencyFlagTrue) { auto &helper = HwHelper::get(renderCoreFamily); bool coherency = false; @@ -38,7 +39,7 @@ GEN10TEST_F(HwHelperTestCnl, whenCnlRevIdForStepDThenSetCapabilityCoherencyFlagT EXPECT_TRUE(coherency); } -GEN10TEST_F(HwHelperTestCnl, setupPreemptionRegisters) { +GEN10TEST_F(HwHelperTestGen10, setupPreemptionRegisters) { auto &helper = HwHelper::get(renderCoreFamily); bool preemption = false; @@ -52,21 +53,26 @@ GEN10TEST_F(HwHelperTestCnl, setupPreemptionRegisters) { EXPECT_TRUE(hwInfoHelper.hwInfo.capabilityTable.whitelistedRegisters.csChicken1_0x2580); } -GEN10TEST_F(HwHelperTestCnl, adjustDefaultEngineType) { +GEN10TEST_F(HwHelperTestGen10, adjustDefaultEngineType) { auto engineType = hwInfoHelper.hwInfo.capabilityTable.defaultEngineType; auto &helper = HwHelper::get(renderCoreFamily); helper.adjustDefaultEngineType(&hwInfoHelper.hwInfo); EXPECT_EQ(engineType, hwInfoHelper.hwInfo.capabilityTable.defaultEngineType); } -GEN10TEST_F(HwHelperTestCnl, givenGen10PlatformWhenSetupHardwareCapabilitiesIsCalledThenDefaultImplementationIsUsed) { +GEN10TEST_F(HwHelperTestGen10, givenGen10PlatformWhenSetupHardwareCapabilitiesIsCalledThenDefaultImplementationIsUsed) { auto &helper = HwHelper::get(renderCoreFamily); // Test default method implementation testDefaultImplementationOfSetupHardwareCapabilities(helper, hwInfoHelper.hwInfo); } -GEN10TEST_F(HwHelperTestCnl, whenGetConfigureAddressSpaceModeThenReturnZero) { +GEN10TEST_F(HwHelperTestGen10, whenGetConfigureAddressSpaceModeThenReturnZero) { auto &helper = HwHelper::get(renderCoreFamily); EXPECT_EQ(0u, helper.getConfigureAddressSpaceMode()); } + +GEN10TEST_F(HwHelperTestGen10, whenGetGpgpuEnginesThenReturnTwoRcsEngines) { + whenGetGpgpuEnginesThenReturnTwoRcsEngines(); + EXPECT_EQ(2u, pDevice->getExecutionEnvironment()->commandStreamReceivers[0].size()); +} diff --git a/unit_tests/gen8/hw_helper_tests_gen8.cpp b/unit_tests/gen8/hw_helper_tests_gen8.cpp index e4449117f6..9fd665d711 100644 --- a/unit_tests/gen8/hw_helper_tests_gen8.cpp +++ b/unit_tests/gen8/hw_helper_tests_gen8.cpp @@ -1,22 +1,23 @@ /* - * Copyright (C) 2017-2018 Intel Corporation + * Copyright (C) 2017-2019 Intel Corporation * * SPDX-License-Identifier: MIT * */ -#include "unit_tests/helpers/hw_helper_tests.h" #include "runtime/memory_manager/memory_constants.h" +#include "unit_tests/helpers/get_gpgpu_engines_tests.inl" +#include "unit_tests/helpers/hw_helper_tests.h" -typedef HwHelperTest HwHelperTestBdw; +using HwHelperTestGen8 = HwHelperTest; -GEN8TEST_F(HwHelperTestBdw, getMaxBarriersPerSliceReturnsCorrectSize) { +GEN8TEST_F(HwHelperTestGen8, getMaxBarriersPerSliceReturnsCorrectSize) { auto &helper = HwHelper::get(renderCoreFamily); EXPECT_EQ(16u, helper.getMaxBarrierRegisterPerSlice()); } -GEN8TEST_F(HwHelperTestBdw, setCapabilityCoherencyFlag) { +GEN8TEST_F(HwHelperTestGen8, setCapabilityCoherencyFlag) { auto &helper = HwHelper::get(renderCoreFamily); bool coherency = false; @@ -24,7 +25,7 @@ GEN8TEST_F(HwHelperTestBdw, setCapabilityCoherencyFlag) { EXPECT_TRUE(coherency); } -GEN8TEST_F(HwHelperTestBdw, setupPreemptionRegisters) { +GEN8TEST_F(HwHelperTestGen8, setupPreemptionRegisters) { auto &helper = HwHelper::get(renderCoreFamily); bool preemption = false; @@ -36,14 +37,14 @@ GEN8TEST_F(HwHelperTestBdw, setupPreemptionRegisters) { EXPECT_FALSE(preemption); } -GEN8TEST_F(HwHelperTestBdw, adjustDefaultEngineType) { +GEN8TEST_F(HwHelperTestGen8, adjustDefaultEngineType) { auto engineType = hwInfoHelper.hwInfo.capabilityTable.defaultEngineType; auto &helper = HwHelper::get(renderCoreFamily); helper.adjustDefaultEngineType(&hwInfoHelper.hwInfo); EXPECT_EQ(engineType, hwInfoHelper.hwInfo.capabilityTable.defaultEngineType); } -GEN8TEST_F(HwHelperTestBdw, givenGen8PlatformWhenSetupHardwareCapabilitiesIsCalledThenSpecificImplementationIsUsed) { +GEN8TEST_F(HwHelperTestGen8, givenGen8PlatformWhenSetupHardwareCapabilitiesIsCalledThenSpecificImplementationIsUsed) { auto &helper = HwHelper::get(renderCoreFamily); HardwareCapabilities hwCaps = {0}; helper.setupHardwareCapabilities(&hwCaps, hwInfoHelper.hwInfo); @@ -54,7 +55,12 @@ GEN8TEST_F(HwHelperTestBdw, givenGen8PlatformWhenSetupHardwareCapabilitiesIsCall EXPECT_FALSE(hwCaps.isStatelesToStatefullWithOffsetSupported); } -GEN8TEST_F(HwHelperTestBdw, whenGetConfigureAddressSpaceModeThenReturnZero) { +GEN8TEST_F(HwHelperTestGen8, whenGetConfigureAddressSpaceModeThenReturnZero) { auto &helper = HwHelper::get(renderCoreFamily); EXPECT_EQ(0u, helper.getConfigureAddressSpaceMode()); } + +GEN8TEST_F(HwHelperTestGen8, whenGetGpgpuEnginesThenReturnTwoRcsEngines) { + whenGetGpgpuEnginesThenReturnTwoRcsEngines(); + EXPECT_EQ(2u, pDevice->getExecutionEnvironment()->commandStreamReceivers[0].size()); +} diff --git a/unit_tests/gen9/hw_helper_tests_gen9.cpp b/unit_tests/gen9/hw_helper_tests_gen9.cpp index 685babad81..58dae1c55d 100644 --- a/unit_tests/gen9/hw_helper_tests_gen9.cpp +++ b/unit_tests/gen9/hw_helper_tests_gen9.cpp @@ -1,20 +1,21 @@ /* - * Copyright (C) 2017-2018 Intel Corporation + * Copyright (C) 2017-2019 Intel Corporation * * SPDX-License-Identifier: MIT * */ +#include "unit_tests/helpers/get_gpgpu_engines_tests.inl" #include "unit_tests/helpers/hw_helper_tests.h" -typedef HwHelperTest HwHelperTestSkl; +using HwHelperTestGen9 = HwHelperTest; -GEN9TEST_F(HwHelperTestSkl, getMaxBarriersPerSliceReturnsCorrectSize) { +GEN9TEST_F(HwHelperTestGen9, getMaxBarriersPerSliceReturnsCorrectSize) { auto &helper = HwHelper::get(renderCoreFamily); EXPECT_EQ(32u, helper.getMaxBarrierRegisterPerSlice()); } -GEN9TEST_F(HwHelperTestSkl, setCapabilityCoherencyFlag) { +GEN9TEST_F(HwHelperTestGen9, setCapabilityCoherencyFlag) { auto &helper = HwHelper::get(renderCoreFamily); bool coherency = false; @@ -22,7 +23,7 @@ GEN9TEST_F(HwHelperTestSkl, setCapabilityCoherencyFlag) { EXPECT_TRUE(coherency); } -GEN9TEST_F(HwHelperTestSkl, setupPreemptionRegisters) { +GEN9TEST_F(HwHelperTestGen9, setupPreemptionRegisters) { auto &helper = HwHelper::get(renderCoreFamily); bool preemption = false; @@ -36,28 +37,33 @@ GEN9TEST_F(HwHelperTestSkl, setupPreemptionRegisters) { EXPECT_TRUE(hwInfoHelper.hwInfo.capabilityTable.whitelistedRegisters.csChicken1_0x2580); } -GEN9TEST_F(HwHelperTestSkl, adjustDefaultEngineType) { +GEN9TEST_F(HwHelperTestGen9, adjustDefaultEngineType) { auto engineType = hwInfoHelper.hwInfo.capabilityTable.defaultEngineType; auto &helper = HwHelper::get(renderCoreFamily); helper.adjustDefaultEngineType(&hwInfoHelper.hwInfo); EXPECT_EQ(engineType, hwInfoHelper.hwInfo.capabilityTable.defaultEngineType); } -GEN9TEST_F(HwHelperTestSkl, givenGen9PlatformWhenSetupHardwareCapabilitiesIsCalledThenDefaultImplementationIsUsed) { +GEN9TEST_F(HwHelperTestGen9, givenGen9PlatformWhenSetupHardwareCapabilitiesIsCalledThenDefaultImplementationIsUsed) { auto &helper = HwHelper::get(renderCoreFamily); // Test default method implementation testDefaultImplementationOfSetupHardwareCapabilities(helper, hwInfoHelper.hwInfo); } -GEN9TEST_F(HwHelperTestSkl, givenDebuggingActiveWhenSipKernelTypeIsQueriedThenDbgCsrLocalTypeIsReturned) { +GEN9TEST_F(HwHelperTestGen9, givenDebuggingActiveWhenSipKernelTypeIsQueriedThenDbgCsrLocalTypeIsReturned) { auto &helper = HwHelper::get(renderCoreFamily); auto sipType = helper.getSipKernelType(true); EXPECT_EQ(SipKernelType::DbgCsrLocal, sipType); } -GEN9TEST_F(HwHelperTestSkl, whenGetConfigureAddressSpaceModeThenReturnZero) { +GEN9TEST_F(HwHelperTestGen9, whenGetConfigureAddressSpaceModeThenReturnZero) { auto &helper = HwHelper::get(renderCoreFamily); EXPECT_EQ(0u, helper.getConfigureAddressSpaceMode()); } + +GEN9TEST_F(HwHelperTestGen9, whenGetGpgpuEnginesThenReturnTwoRcsEngines) { + whenGetGpgpuEnginesThenReturnTwoRcsEngines(); + EXPECT_EQ(2u, pDevice->getExecutionEnvironment()->commandStreamReceivers[0].size()); +} diff --git a/unit_tests/helpers/CMakeLists.txt b/unit_tests/helpers/CMakeLists.txt index cec385ccd6..86c32d8519 100644 --- a/unit_tests/helpers/CMakeLists.txt +++ b/unit_tests/helpers/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2017-2018 Intel Corporation +# Copyright (C) 2017-2019 Intel Corporation # # SPDX-License-Identifier: MIT # @@ -20,6 +20,7 @@ set(IGDRCL_SRCS_tests_helpers ${CMAKE_CURRENT_SOURCE_DIR}/extendable_enum_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/file_io_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/flush_stamp_tests.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/get_gpgpu_engines_tests.inl ${CMAKE_CURRENT_SOURCE_DIR}/get_info_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/gtest_helpers.h ${CMAKE_CURRENT_SOURCE_DIR}/hash_tests.cpp diff --git a/unit_tests/helpers/get_gpgpu_engines_tests.inl b/unit_tests/helpers/get_gpgpu_engines_tests.inl new file mode 100644 index 0000000000..74c3cf25a1 --- /dev/null +++ b/unit_tests/helpers/get_gpgpu_engines_tests.inl @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2019 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "runtime/helpers/hw_helper.h" +#include "test.h" + +using namespace OCLRT; + +template +void whenGetGpgpuEnginesThenReturnTwoRcsEngines() { + auto &hwHelper = HwHelperHw::get(); + auto &gpgpuEngines = hwHelper.getGpgpuEngineInstances(); + EXPECT_EQ(2u, gpgpuEngines.size()); + int numRcsEngines = 0; + for (auto &engine : gpgpuEngines) { + if (ENGINE_RCS == engine.type) { + EXPECT_EQ(numRcsEngines, engine.id); + numRcsEngines++; + } + EXPECT_EQ(ENGINE_RCS, engine.type); + } + EXPECT_EQ(2, numRcsEngines); + EXPECT_EQ(gpgpuEngines[EngineInstanceConstants::lowPriorityGpgpuEngineIndex].type, lowPriorityGpgpuEngine.type); + EXPECT_EQ(gpgpuEngines[EngineInstanceConstants::lowPriorityGpgpuEngineIndex].id, lowPriorityGpgpuEngine.id); +} diff --git a/unit_tests/memory_manager/deferrable_allocation_deletion_tests.cpp b/unit_tests/memory_manager/deferrable_allocation_deletion_tests.cpp index 891cc78605..4deda9e2d1 100644 --- a/unit_tests/memory_manager/deferrable_allocation_deletion_tests.cpp +++ b/unit_tests/memory_manager/deferrable_allocation_deletion_tests.cpp @@ -58,7 +58,6 @@ struct DeferrableAllocationDeletionTest : ::testing::Test { }; TEST_F(DeferrableAllocationDeletionTest, givenDeferrableAllocationWhenApplyThenWaitForEachTaskCount) { - EXPECT_EQ(gpgpuEngineInstances.size(), memoryManager->getOsContextCount()); auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); allocation->updateTaskCount(1u, device1ContextId); *hwTag = 0u; @@ -81,7 +80,6 @@ TEST_F(DeferrableAllocationDeletionTest, givenDeferrableAllocationWhenApplyThenW HWTEST_F(DeferrableAllocationDeletionTest, givenAllocationUsedByTwoOsContextsWhenApplyDeletionThenWaitForBothContextsAndFlushNotReadyCsr) { std::unique_ptr device2(Device::create(nullptr, device1->getExecutionEnvironment(), 1u)); auto device2ContextId = device2->getDefaultEngine().osContext->getContextId(); - EXPECT_EQ(gpgpuEngineInstances.size() * 2, memoryManager->getOsContextCount()); auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); *hwTag = 0u; *device2->getDefaultEngine().commandStreamReceiver->getTagAddress() = 1u; @@ -102,7 +100,6 @@ HWTEST_F(DeferrableAllocationDeletionTest, givenAllocationUsedByTwoOsContextsWhe *hwTag = 1u; } TEST_F(DeferrableAllocationDeletionTest, givenNotUsedAllocationWhenApplyDeletionThenDontWait) { - EXPECT_EQ(gpgpuEngineInstances.size(), memoryManager->getOsContextCount()); auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); EXPECT_FALSE(allocation->isUsed()); EXPECT_EQ(0u, memoryManager->freeGraphicsMemoryCalled); diff --git a/unit_tests/memory_manager/memory_manager_tests.cpp b/unit_tests/memory_manager/memory_manager_tests.cpp index 803ed63a5e..e325a45d9d 100644 --- a/unit_tests/memory_manager/memory_manager_tests.cpp +++ b/unit_tests/memory_manager/memory_manager_tests.cpp @@ -196,7 +196,7 @@ TEST_F(MemoryAllocatorTest, allocateSystemAligned) { TEST_F(MemoryAllocatorTest, allocateGraphics) { unsigned int alignment = 4096; - memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); + memoryManager->createAndRegisterOsContext(HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances()[0], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); ASSERT_NE(nullptr, allocation); @@ -1253,7 +1253,7 @@ TEST_F(MemoryManagerWithCsrTest, givenAllocationThatWasUsedAndIsCompletedWhenche } TEST_F(MemoryManagerWithCsrTest, givenAllocationThatWasUsedAndIsNotCompletedWhencheckGpuUsageAndDestroyGraphicsAllocationsIsCalledThenItIsAddedToTemporaryAllocationList) { - memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); + memoryManager->createAndRegisterOsContext(HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances()[0], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); auto usedAllocationAndNotGpuCompleted = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); auto tagAddress = csr->getTagAddress(); @@ -1504,7 +1504,7 @@ TEST(GraphicsAllocation, givenSharedHandleBasedConstructorWhenGraphicsAllocation TEST(ResidencyDataTest, givenOsContextWhenItIsRegisteredToMemoryManagerThenRefCountIncreases) { ExecutionEnvironment executionEnvironment; MockMemoryManager memoryManager(false, false, executionEnvironment); - memoryManager.createAndRegisterOsContext(gpgpuEngineInstances[0], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); + memoryManager.createAndRegisterOsContext(HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances()[0], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); EXPECT_EQ(1u, memoryManager.getOsContextCount()); EXPECT_EQ(1, memoryManager.registeredOsContexts[0]->getRefInternalCount()); } @@ -1512,8 +1512,8 @@ TEST(ResidencyDataTest, givenOsContextWhenItIsRegisteredToMemoryManagerThenRefCo TEST(ResidencyDataTest, givenTwoOsContextsWhenTheyAreRegistredFromHigherToLowerThenProperSizeIsReturned) { ExecutionEnvironment executionEnvironment; MockMemoryManager memoryManager(false, false, executionEnvironment); - memoryManager.createAndRegisterOsContext(gpgpuEngineInstances[0], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); - memoryManager.createAndRegisterOsContext(gpgpuEngineInstances[1], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); + memoryManager.createAndRegisterOsContext(HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances()[0], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); + memoryManager.createAndRegisterOsContext(HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances()[1], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); EXPECT_EQ(2u, memoryManager.getOsContextCount()); EXPECT_EQ(1, memoryManager.registeredOsContexts[0]->getRefInternalCount()); EXPECT_EQ(1, memoryManager.registeredOsContexts[1]->getRefInternalCount()); @@ -1526,8 +1526,8 @@ TEST(ResidencyDataTest, givenResidencyDataWhenUpdateCompletionDataIsCalledThenIt MockResidencyData residency; - OsContext osContext(nullptr, 0u, gpgpuEngineInstances[0], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); - OsContext osContext2(nullptr, 1u, gpgpuEngineInstances[1], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); + OsContext osContext(nullptr, 0u, HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances()[0], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); + OsContext osContext2(nullptr, 1u, HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances()[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 c48414de96..6b840cf72e 100644 --- a/unit_tests/memory_manager/surface_tests.cpp +++ b/unit_tests/memory_manager/surface_tests.cpp @@ -60,9 +60,9 @@ HWTEST_TYPED_TEST(SurfaceTest, GivenSurfaceWhenInterfaceIsUsedThenSurfaceBehaves ExecutionEnvironment executionEnvironment; executionEnvironment.commandStreamReceivers.resize(1); MockCsr *csr = new MockCsr(execStamp, executionEnvironment); - executionEnvironment.commandStreamReceivers[0][0].reset(csr); + executionEnvironment.commandStreamReceivers[0].push_back(std::unique_ptr(csr)); executionEnvironment.memoryManager.reset(csr->createMemoryManager(false, false)); - csr->setupContext(*executionEnvironment.memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]))); + csr->setupContext(*executionEnvironment.memoryManager->createAndRegisterOsContext(HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances()[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 b2c6984e4f..606dfdc8a0 100644 --- a/unit_tests/mocks/mock_aub_csr.h +++ b/unit_tests/mocks/mock_aub_csr.h @@ -149,7 +149,7 @@ std::unique_ptr getEnvironment(bool createTagAllocation executionEnvironment->aubCenter.reset(new AubCenter()); executionEnvironment->commandStreamReceivers.resize(1); - executionEnvironment->commandStreamReceivers[0][0] = std::make_unique(*platformDevices[0], "", standalone, *executionEnvironment); + 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[0][0]->initializeTagAllocation(); diff --git a/unit_tests/mocks/mock_device.cpp b/unit_tests/mocks/mock_device.cpp index 43b7a1e10d..791f1f5180 100644 --- a/unit_tests/mocks/mock_device.cpp +++ b/unit_tests/mocks/mock_device.cpp @@ -17,8 +17,10 @@ MockDevice::MockDevice(const HardwareInfo &hwInfo) : MockDevice(hwInfo, new ExecutionEnvironment, 0u) { CommandStreamReceiver *commandStreamReceiver = createCommandStream(&hwInfo, *this->executionEnvironment); executionEnvironment->commandStreamReceivers.resize(getDeviceIndex() + 1); + executionEnvironment->commandStreamReceivers[getDeviceIndex()].resize(defaultEngineIndex + 1); executionEnvironment->commandStreamReceivers[getDeviceIndex()][defaultEngineIndex].reset(commandStreamReceiver); this->executionEnvironment->memoryManager = std::move(this->mockMemoryManager); + this->engines.resize(defaultEngineIndex + 1); this->engines[defaultEngineIndex] = {commandStreamReceiver, nullptr}; } MockDevice::MockDevice(const HardwareInfo &hwInfo, ExecutionEnvironment *executionEnvironment, uint32_t deviceIndex) diff --git a/unit_tests/mocks/mock_tbx_csr.h b/unit_tests/mocks/mock_tbx_csr.h index 7f110cc8bf..6f9bd90a71 100644 --- a/unit_tests/mocks/mock_tbx_csr.h +++ b/unit_tests/mocks/mock_tbx_csr.h @@ -87,7 +87,7 @@ std::unique_ptr getEnvironment(bool createTagAllocation executionEnvironment->aubCenter.reset(new AubCenter()); executionEnvironment->commandStreamReceivers.resize(1); - executionEnvironment->commandStreamReceivers[0][0] = std::make_unique(*platformDevices[0], *executionEnvironment); + executionEnvironment->commandStreamReceivers[0].push_back(std::make_unique(*platformDevices[0], *executionEnvironment)); executionEnvironment->memoryManager.reset(executionEnvironment->commandStreamReceivers[0][0]->createMemoryManager(false, false)); if (createTagAllocation) { executionEnvironment->commandStreamReceivers[0][0]->initializeTagAllocation(); diff --git a/unit_tests/os_interface/linux/device_command_stream_fixture.h b/unit_tests/os_interface/linux/device_command_stream_fixture.h index e02d4338e4..2533866325 100644 --- a/unit_tests/os_interface/linux/device_command_stream_fixture.h +++ b/unit_tests/os_interface/linux/device_command_stream_fixture.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017-2018 Intel Corporation + * Copyright (C) 2017-2019 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -12,6 +12,7 @@ #include "gtest/gtest.h" #include "engine_node.h" #include "runtime/helpers/aligned_memory.h" +#include "runtime/helpers/hw_helper.h" #include "runtime/os_interface/linux/drm_memory_manager.h" #include "runtime/os_interface/linux/drm_neo.h" #include "unit_tests/helpers/gtest_helpers.h" @@ -270,7 +271,7 @@ class DrmMockCustom : public Drm { DrmMockCustom() : Drm(mockFd) { reset(); - ioctl_expected.contextCreate = OCLRT::EngineInstanceConstants::numGpgpuEngineInstances; + ioctl_expected.contextCreate = static_cast(OCLRT::HwHelper::get(OCLRT::platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances().size()); ioctl_expected.contextDestroy = ioctl_expected.contextCreate.load(); } int getErrno() 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 80ce1574de..8add89cba6 100644 --- a/unit_tests/os_interface/linux/drm_command_stream_tests.cpp +++ b/unit_tests/os_interface/linux/drm_command_stream_tests.cpp @@ -41,13 +41,13 @@ class DrmCommandStreamFixture { executionEnvironment.osInterface = std::make_unique(); executionEnvironment.osInterface->get()->setDrm(mock.get()); - osContext = std::make_unique(executionEnvironment.osInterface.get(), 0u, gpgpuEngineInstances[0], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); + osContext = std::make_unique(executionEnvironment.osInterface.get(), 0u, HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances()[0], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); csr = new DrmCommandStreamReceiver(*platformDevices[0], executionEnvironment, gemCloseWorkerMode::gemCloseWorkerActive); ASSERT_NE(nullptr, csr); executionEnvironment.commandStreamReceivers.resize(1); - executionEnvironment.commandStreamReceivers[0][0].reset(csr); + executionEnvironment.commandStreamReceivers[0].push_back(std::unique_ptr(csr)); csr->setupContext(*osContext); // Memory manager creates pinBB with ioctl, expect one call @@ -254,7 +254,7 @@ TEST_F(DrmCommandStreamTest, givenDrmContextIdWhenFlushingThenSetIdToAllExecBuff .RetiresOnSaturation(); osContext = std::make_unique(executionEnvironment.osInterface.get(), 1, - gpgpuEngineInstances[0], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); + HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances()[0], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); csr->setupContext(*osContext); auto &cs = csr->getCS(); 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 6d96b53276..69165b4d32 100644 --- a/unit_tests/os_interface/linux/drm_memory_manager_tests.cpp +++ b/unit_tests/os_interface/linux/drm_memory_manager_tests.cpp @@ -570,7 +570,7 @@ TEST_F(DrmMemoryManagerTest, getMinimumSystemSharedMemory) { mock->ioctl_expected.contextGetParam = 2; EXPECT_EQ(hostMemorySize, systemSharedMemorySize); mock->testIoctls(); - mock->ioctl_expected.contextDestroy = OCLRT::EngineInstanceConstants::numGpgpuEngineInstances; + mock->ioctl_expected.contextDestroy = static_cast(memoryManager->getCommandStreamReceivers()[0].size()); } TEST_F(DrmMemoryManagerTest, BoWaitFailure) { @@ -1298,7 +1298,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenTiledImageIsBeingCreatedAn injectFailures(method); mock->reset(); - mock->ioctl_expected.contextDestroy = OCLRT::EngineInstanceConstants::numGpgpuEngineInstances; + mock->ioctl_expected.contextDestroy = static_cast(memoryManager->getCommandStreamReceivers()[0].size()); } TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenTiledImageIsBeingCreatedFromHostPtrThenallocateGraphicsMemoryForImageIsUsed) { @@ -1561,7 +1561,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerAndOsHandleWhenAllocationFails injectFailures(method); mock->reset(); - mock->ioctl_expected.contextDestroy = OCLRT::EngineInstanceConstants::numGpgpuEngineInstances; + mock->ioctl_expected.contextDestroy = static_cast(memoryManager->getCommandStreamReceivers()[0].size()); } TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerAndThreeOsHandlesWhenReuseCreatesAreCalledThenGraphicsAllocationsAreReturned) { diff --git a/unit_tests/os_interface/linux/drm_tests.cpp b/unit_tests/os_interface/linux/drm_tests.cpp index a3b12bd1db..905102e849 100644 --- a/unit_tests/os_interface/linux/drm_tests.cpp +++ b/unit_tests/os_interface/linux/drm_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017-2018 Intel Corporation + * Copyright (C) 2017-2019 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -146,6 +146,8 @@ TEST(DrmTest, GivenDrmWhenAskedForContextThatFailsThenFalseIsReturned) { delete pDrm; } +constexpr EngineInstanceT defaultEngine{ENGINE_RCS, 0}; + TEST(DrmTest, givenDrmWhenOsContextIsCreatedThenCreateAndDestroyNewDrmOsContext) { DrmMock drmMock; uint32_t drmContextId1 = 123; @@ -153,13 +155,13 @@ TEST(DrmTest, givenDrmWhenOsContextIsCreatedThenCreateAndDestroyNewDrmOsContext) { drmMock.StoredCtxId = drmContextId1; - OsContextLinux osContext1(drmMock, gpgpuEngineInstances[0]); + OsContextLinux osContext1(drmMock, defaultEngine); EXPECT_EQ(drmContextId1, osContext1.getDrmContextId()); EXPECT_EQ(0u, drmMock.receivedDestroyContextId); { drmMock.StoredCtxId = drmContextId2; - OsContextLinux osContext2(drmMock, gpgpuEngineInstances[1]); + OsContextLinux osContext2(drmMock, defaultEngine); EXPECT_EQ(drmContextId2, osContext2.getDrmContextId()); EXPECT_EQ(0u, drmMock.receivedDestroyContextId); } @@ -175,16 +177,16 @@ TEST(DrmTest, givenDrmPreemptionEnabledAndLowPriorityEngineWhenCreatingOsContext drmMock.StoredCtxId = 123; drmMock.preemptionSupported = false; - OsContextLinux osContext1(drmMock, gpgpuEngineInstances[0]); - OsContextLinux osContext2(drmMock, gpgpuEngineInstances[EngineInstanceConstants::lowPriorityGpgpuEngineIndex]); + OsContextLinux osContext1(drmMock, defaultEngine); + OsContextLinux osContext2(drmMock, lowPriorityGpgpuEngine); EXPECT_EQ(0u, drmMock.receivedContextParamRequestCount); drmMock.preemptionSupported = true; - OsContextLinux osContext3(drmMock, gpgpuEngineInstances[0]); + OsContextLinux osContext3(drmMock, defaultEngine); EXPECT_EQ(0u, drmMock.receivedContextParamRequestCount); - OsContextLinux osContext4(drmMock, gpgpuEngineInstances[EngineInstanceConstants::lowPriorityGpgpuEngineIndex]); + OsContextLinux osContext4(drmMock, lowPriorityGpgpuEngine); EXPECT_EQ(1u, drmMock.receivedContextParamRequestCount); EXPECT_EQ(drmMock.StoredCtxId, drmMock.receivedContextParamRequest.ctx_id); EXPECT_EQ(static_cast(I915_CONTEXT_PARAM_PRIORITY), drmMock.receivedContextParamRequest.param); 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 8b8e734db5..52e6087556 100644 --- a/unit_tests/os_interface/linux/os_interface_linux_tests.cpp +++ b/unit_tests/os_interface/linux/os_interface_linux_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017-2018 Intel Corporation + * Copyright (C) 2017-2019 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -27,7 +27,7 @@ TEST(OsContextTest, givenDrmWhenOsContextIsCreatedThenImplIsAvailable) { OSInterface osInterface; osInterface.get()->setDrm(&drmMock); - auto osContext = std::make_unique(&osInterface, 0u, gpgpuEngineInstances[0], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); + auto osContext = std::make_unique(&osInterface, 0u, HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances()[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 67fefbdf18..5a5c31a095 100644 --- a/unit_tests/os_interface/windows/device_command_stream_tests.cpp +++ b/unit_tests/os_interface/windows/device_command_stream_tests.cpp @@ -245,11 +245,11 @@ TEST(WddmPreemptionHeaderTests, givenWddmCommandStreamReceiverWhenPreemptionIsOf hwInfo->capabilityTable.defaultPreemptionMode = PreemptionMode::Disabled; auto wddm = static_cast(executionEnvironment->osInterface->get()->getWddm()); executionEnvironment->commandStreamReceivers.resize(1); - executionEnvironment->commandStreamReceivers[0][0] = - std::make_unique>(hwInfo[0], *executionEnvironment); + 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); - OsContext osContext(executionEnvironment->osInterface.get(), 0u, gpgpuEngineInstances[0], PreemptionHelper::getDefaultPreemptionMode(*hwInfo)); + OsContext osContext(executionEnvironment->osInterface.get(), 0u, HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances()[0], PreemptionHelper::getDefaultPreemptionMode(*hwInfo)); executionEnvironment->commandStreamReceivers[0][0]->setupContext(osContext); auto commandBuffer = executionEnvironment->memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); @@ -270,11 +270,11 @@ TEST(WddmPreemptionHeaderTests, givenWddmCommandStreamReceiverWhenPreemptionIsOn hwInfo->capabilityTable.defaultPreemptionMode = PreemptionMode::MidThread; auto wddm = static_cast(executionEnvironment->osInterface->get()->getWddm()); executionEnvironment->commandStreamReceivers.resize(1); - executionEnvironment->commandStreamReceivers[0][0] = std::make_unique>(hwInfo[0], - *executionEnvironment); + 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); - OsContext osContext(executionEnvironment->osInterface.get(), 0u, gpgpuEngineInstances[0], PreemptionHelper::getDefaultPreemptionMode(*hwInfo)); + OsContext osContext(executionEnvironment->osInterface.get(), 0u, HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances()[0], PreemptionHelper::getDefaultPreemptionMode(*hwInfo)); executionEnvironment->commandStreamReceivers[0][0]->setupContext(osContext); auto commandBuffer = executionEnvironment->memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); 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 9991d5f583..c9468e67fd 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 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Intel Corporation + * Copyright (C) 2018-2019 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -324,7 +324,7 @@ TEST_F(GlArbSyncEventOsTest, GivenCallToSignalArbSyncObjectWhenSignalSynchroniza FailSignalSyncObjectMock::reset(); auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]); wddm->init(preemptionMode); - OsContext osContext(&osInterface, 0u, gpgpuEngineInstances[0], preemptionMode); + OsContext osContext(&osInterface, 0u, HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances()[0], preemptionMode); CL_GL_SYNC_INFO syncInfo = {}; syncInfo.serverSynchronizationObject = 0x5cU; @@ -383,7 +383,7 @@ TEST_F(GlArbSyncEventOsTest, GivenCallToSignalArbSyncObjectWhenSignalSynchroniza FailSignalSyncObjectMock::reset(); auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]); wddm->init(preemptionMode); - OsContext osContext(&osInterface, 0u, gpgpuEngineInstances[0], preemptionMode); + OsContext osContext(&osInterface, 0u, HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances()[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 6310b8743e..5834bc5773 100644 --- a/unit_tests/os_interface/windows/os_interface_win_tests.cpp +++ b/unit_tests/os_interface/windows/os_interface_win_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017-2018 Intel Corporation + * Copyright (C) 2017-2019 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -29,7 +29,7 @@ TEST(OsContextTest, givenWddmWhenCreateOsContextBeforeInitWddmThenOsContextIsNot auto wddm = new WddmMock; OSInterface osInterface; osInterface.get()->setWddm(wddm); - EXPECT_THROW(auto osContext = std::make_unique(&osInterface, 0u, gpgpuEngineInstances[0], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])), std::exception); + EXPECT_THROW(auto osContext = std::make_unique(&osInterface, 0u, HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances()[0], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])), std::exception); } TEST(OsContextTest, givenWddmWhenCreateOsContextAfterInitWddmThenOsContextIsInitializedAndTrimCallbackIsRegistered) { @@ -39,7 +39,7 @@ TEST(OsContextTest, givenWddmWhenCreateOsContextAfterInitWddmThenOsContextIsInit auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]); wddm->init(preemptionMode); EXPECT_EQ(0u, wddm->registerTrimCallbackResult.called); - auto osContext = std::make_unique(&osInterface, 0u, gpgpuEngineInstances[0], preemptionMode); + auto osContext = std::make_unique(&osInterface, 0u, HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances()[0], preemptionMode); EXPECT_NE(nullptr, osContext->get()); EXPECT_TRUE(osContext->get()->isInitialized()); EXPECT_EQ(osContext->get()->getWddm(), wddm); @@ -48,6 +48,6 @@ TEST(OsContextTest, givenWddmWhenCreateOsContextAfterInitWddmThenOsContextIsInit TEST(OsContextTest, whenCreateOsContextWithoutOsInterfaceThenOsContextImplIsNotAvailable) { auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]); - auto osContext = std::make_unique(nullptr, 0u, gpgpuEngineInstances[0], preemptionMode); + auto osContext = std::make_unique(nullptr, 0u, HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances()[0], preemptionMode); EXPECT_EQ(nullptr, osContext->get()); } diff --git a/unit_tests/os_interface/windows/wddm20_tests.cpp b/unit_tests/os_interface/windows/wddm20_tests.cpp index dcb51994a4..ee1a63599e 100644 --- a/unit_tests/os_interface/windows/wddm20_tests.cpp +++ b/unit_tests/os_interface/windows/wddm20_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017-2018 Intel Corporation + * Copyright (C) 2017-2019 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -551,7 +551,7 @@ TEST_F(Wddm20WithMockGdiDllTestsWithoutWddmInit, givenUseNoRingFlushesKmdModeDeb TEST_F(Wddm20WithMockGdiDllTestsWithoutWddmInit, givenEngineTypeWhenCreatingContextThenPassCorrectNodeOrdinal) { init(); auto createContextParams = this->getCreateContextDataFcn(); - UINT expected = WddmEngineMapper::engineNodeMap(gpgpuEngineInstances[0].type); + UINT expected = WddmEngineMapper::engineNodeMap(HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances()[0].type); EXPECT_EQ(expected, createContextParams->NodeOrdinal); } diff --git a/unit_tests/os_interface/windows/wddm23_tests.cpp b/unit_tests/os_interface/windows/wddm23_tests.cpp index cf8358532e..2ff0a35511 100644 --- a/unit_tests/os_interface/windows/wddm23_tests.cpp +++ b/unit_tests/os_interface/windows/wddm23_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Intel Corporation + * Copyright (C) 2018-2019 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -37,7 +37,7 @@ struct Wddm23TestsWithoutWddmInit : public ::testing::Test, GdiDllFixture, publi void init() { auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]); EXPECT_TRUE(wddm->init(preemptionMode)); - osContext = std::make_unique(osInterface.get(), 0u, gpgpuEngineInstances[0], preemptionMode); + osContext = std::make_unique(osInterface.get(), 0u, HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances()[0], preemptionMode); osContextWin = osContext->get(); } diff --git a/unit_tests/os_interface/windows/wddm_fixture.h b/unit_tests/os_interface/windows/wddm_fixture.h index 5308232b0c..ea6caa29ee 100644 --- a/unit_tests/os_interface/windows/wddm_fixture.h +++ b/unit_tests/os_interface/windows/wddm_fixture.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017-2018 Intel Corporation + * Copyright (C) 2017-2019 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -28,7 +28,7 @@ struct WddmFixture : public GmmEnvironmentFixture { wddm->gdi.reset(gdi); auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]); wddm->init(preemptionMode); - osContext = std::make_unique(osInterface.get(), 0u, gpgpuEngineInstances[0], preemptionMode); + osContext = std::make_unique(osInterface.get(), 0u, HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances()[0], preemptionMode); osContextWin = osContext->get(); ASSERT_TRUE(wddm->isInitialized()); } @@ -57,7 +57,7 @@ struct WddmFixtureWithMockGdiDll : public GmmEnvironmentFixture, public GdiDllFi void init() { auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]); EXPECT_TRUE(wddm->init(preemptionMode)); - osContext = std::make_unique(osInterface.get(), 0u, gpgpuEngineInstances[0], preemptionMode); + osContext = std::make_unique(osInterface.get(), 0u, HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances()[0], preemptionMode); osContextWin = osContext->get(); ASSERT_TRUE(wddm->isInitialized()); } 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 70ead1c621..57553fd4ad 100644 --- a/unit_tests/os_interface/windows/wddm_memory_manager_tests.cpp +++ b/unit_tests/os_interface/windows/wddm_memory_manager_tests.cpp @@ -64,9 +64,11 @@ TEST(WddmMemoryManager, NonAssignable) { EXPECT_FALSE(std::is_copy_assignable::value); } +constexpr EngineInstanceT defaultRcsEngine{ENGINE_RCS, 0}; + TEST(WddmAllocationTest, givenAllocationIsTrimCandidateInOneOsContextWhenGettingTrimCandidatePositionThenReturnItsPositionAndUnusedPositionInOtherContexts) { WddmAllocation allocation{nullptr, 0, nullptr, MemoryPool::MemoryNull, 3u, false}; - OsContext osContext(nullptr, 1u, gpgpuEngineInstances[0], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); + OsContext osContext(nullptr, 1u, defaultRcsEngine, PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); allocation.setTrimCandidateListPosition(osContext.getContextId(), 700u); EXPECT_EQ(trimListUnusedPosition, allocation.getTrimCandidateListPosition(0u)); EXPECT_EQ(700u, allocation.getTrimCandidateListPosition(1u)); @@ -1225,16 +1227,16 @@ TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWithNoRegisteredOsContextsWh } TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWithRegisteredOsContextWhenCallingIsMemoryBudgetExhaustedThenReturnFalse) { - 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->createAndRegisterOsContext(defaultRcsEngine, PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); + memoryManager->createAndRegisterOsContext(defaultRcsEngine, PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); + memoryManager->createAndRegisterOsContext(defaultRcsEngine, PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); EXPECT_FALSE(memoryManager->isMemoryBudgetExhausted()); } TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWithRegisteredOsContextWithExhaustedMemoryBudgetWhenCallingIsMemoryBudgetExhaustedThenReturnTrue) { - 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->createAndRegisterOsContext(defaultRcsEngine, PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); + memoryManager->createAndRegisterOsContext(defaultRcsEngine, PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); + memoryManager->createAndRegisterOsContext(defaultRcsEngine, PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); memoryManager->getRegisteredOsContext(1)->get()->getResidencyController().setMemoryBudgetExhausted(); EXPECT_TRUE(memoryManager->isMemoryBudgetExhausted()); } @@ -1463,10 +1465,10 @@ TEST(WddmMemoryManagerCleanupTest, givenUsedTagAllocationInWddmMemoryManagerWhen executionEnvironment.osInterface = std::make_unique(); executionEnvironment.osInterface->get()->setWddm(wddm); executionEnvironment.commandStreamReceivers.resize(1); - executionEnvironment.commandStreamReceivers[0][0] = std::unique_ptr(csr); + executionEnvironment.commandStreamReceivers[0].push_back(std::unique_ptr(csr)); executionEnvironment.memoryManager = std::make_unique(false, false, wddm, executionEnvironment); - csr->setupContext(*executionEnvironment.memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0], preemptionMode)); + csr->setupContext(*executionEnvironment.memoryManager->createAndRegisterOsContext(defaultRcsEngine, 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 ea2934e89a..fe8887d3b4 100644 --- a/unit_tests/os_interface/windows/wddm_memory_manager_tests.h +++ b/unit_tests/os_interface/windows/wddm_memory_manager_tests.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017-2018 Intel Corporation + * Copyright (C) 2017-2019 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -56,7 +56,7 @@ class MockWddmMemoryManagerFixture : public GmmEnvironmentFixture { executionEnvironment.osInterface->get()->setWddm(wddm); memoryManager = std::make_unique(wddm, executionEnvironment); - memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); + memoryManager->createAndRegisterOsContext(HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances()[0], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); osContext = memoryManager->getRegisteredOsContext(0); osContext->incRefInternal(); @@ -121,7 +121,7 @@ class WddmMemoryManagerFixtureWithGmockWddm : public GmmEnvironmentFixture { memoryManager = new (std::nothrow) MockWddmMemoryManager(wddm, executionEnvironment); //assert we have memory manager ASSERT_NE(nullptr, memoryManager); - memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0], preemptionMode); + memoryManager->createAndRegisterOsContext(HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances()[0], preemptionMode); osContext = memoryManager->getRegisteredOsContext(0); osContext->incRefInternal(); diff --git a/unit_tests/os_interface/windows/wddm_preemption_tests.cpp b/unit_tests/os_interface/windows/wddm_preemption_tests.cpp index eceb9c98b7..1b7400e66f 100644 --- a/unit_tests/os_interface/windows/wddm_preemption_tests.cpp +++ b/unit_tests/os_interface/windows/wddm_preemption_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Intel Corporation + * Copyright (C) 2018-2019 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -35,7 +35,7 @@ class WddmPreemptionTests : public Test { regReader->forceRetValue = forceReturnPreemptionRegKeyValue; auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(hwInfoTest); wddm->init(preemptionMode); - osContext = std::make_unique(osInterface.get(), 0u, gpgpuEngineInstances[0], preemptionMode); + osContext = std::make_unique(osInterface.get(), 0u, HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances()[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 3aecfc7918..03847c9d4a 100644 --- a/unit_tests/os_interface/windows/wddm_residency_controller_tests.cpp +++ b/unit_tests/os_interface/windows/wddm_residency_controller_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Intel Corporation + * Copyright (C) 2018-2019 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -94,7 +94,7 @@ struct WddmResidencyControllerWithMockWddmTest : public WddmResidencyControllerT executionEnvironment->osInterface->get()->setWddm(wddm); memoryManager = std::make_unique(wddm, *executionEnvironment); - memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0], preemptionMode); + memoryManager->createAndRegisterOsContext(HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances()[0], preemptionMode); osContext = memoryManager->getRegisteredOsContext(0); osContext->incRefInternal(); residencyController = &osContext->get()->getResidencyController(); @@ -125,7 +125,7 @@ struct WddmResidencyControllerWithGdiAndMemoryManagerTest : ::testing::Test { executionEnvironment->osInterface->get()->setWddm(wddm); memoryManager = std::make_unique(wddm, *executionEnvironment); - memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[0], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); + memoryManager->createAndRegisterOsContext(HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances()[0], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])); osContext = memoryManager->getRegisteredOsContext(0); osContext->incRefInternal(); diff --git a/unit_tests/preemption/preemption_tests.cpp b/unit_tests/preemption/preemption_tests.cpp index 9da369a393..b5db46dde2 100644 --- a/unit_tests/preemption/preemption_tests.cpp +++ b/unit_tests/preemption/preemption_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Intel Corporation + * Copyright (C) 2018-2019 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -468,7 +468,7 @@ HWTEST_F(MidThreadPreemptionTests, givenMidThreadPreemptionWhenFailingOnCsrSurfa FailingMemoryManager(ExecutionEnvironment &executionEnvironment) : OsAgnosticMemoryManager(false, false, executionEnvironment) {} GraphicsAllocation *allocateGraphicsMemoryWithAlignment(const AllocationData &allocationData) override { - if (++allocateGraphicsMemoryCount > gpgpuEngineInstances.size()) { + if (++allocateGraphicsMemoryCount > HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances().size()) { return nullptr; } return OsAgnosticMemoryManager::allocateGraphicsMemoryWithAlignment(allocationData); diff --git a/unit_tests/scenarios/windows/enqueue_read_write_buffer_scenarios_windows_tests.cpp b/unit_tests/scenarios/windows/enqueue_read_write_buffer_scenarios_windows_tests.cpp index d91f3d9961..02a1e19448 100644 --- a/unit_tests/scenarios/windows/enqueue_read_write_buffer_scenarios_windows_tests.cpp +++ b/unit_tests/scenarios/windows/enqueue_read_write_buffer_scenarios_windows_tests.cpp @@ -39,7 +39,7 @@ struct EnqueueBufferWindowsTest : public HardwareParse, auto wddmCsr = new WddmCommandStreamReceiver(*hwInfo, *executionEnvironment); executionEnvironment->commandStreamReceivers.resize(1); - executionEnvironment->commandStreamReceivers[0][0].reset(wddmCsr); + executionEnvironment->commandStreamReceivers[0].push_back(std::unique_ptr(wddmCsr)); memoryManager = new MockWddmMemoryManager(executionEnvironment->osInterface->get()->getWddm(), *executionEnvironment); executionEnvironment->memoryManager.reset(memoryManager); diff --git a/unit_tests/source_level_debugger/source_level_debugger_csr_tests.cpp b/unit_tests/source_level_debugger/source_level_debugger_csr_tests.cpp index 015d0a72cc..3c7860d009 100644 --- a/unit_tests/source_level_debugger/source_level_debugger_csr_tests.cpp +++ b/unit_tests/source_level_debugger/source_level_debugger_csr_tests.cpp @@ -31,7 +31,7 @@ class CommandStreamReceiverWithActiveDebuggerTest : public ::testing::Test { auto mockCsr = new MockCsrHw2(*platformDevices[0], *executionEnvironment); executionEnvironment->commandStreamReceivers.resize(1); - executionEnvironment->commandStreamReceivers[0][0].reset(mockCsr); + executionEnvironment->commandStreamReceivers[0].push_back(std::unique_ptr(mockCsr)); auto mockMemoryManager = new MockMemoryManager(*executionEnvironment); executionEnvironment->memoryManager.reset(mockMemoryManager);