diff --git a/opencl/test/unit_test/aub_tests/command_stream/aub_command_stream_fixture.cpp b/opencl/test/unit_test/aub_tests/command_stream/aub_command_stream_fixture.cpp index ce3a4c72d3..b96c3731bb 100644 --- a/opencl/test/unit_test/aub_tests/command_stream/aub_command_stream_fixture.cpp +++ b/opencl/test/unit_test/aub_tests/command_stream/aub_command_stream_fixture.cpp @@ -18,6 +18,7 @@ #include "opencl/source/command_queue/command_queue.h" #include "opencl/source/command_stream/tbx_command_stream_receiver.h" +#include "opencl/test/unit_test/aub_tests/fixtures/aub_fixture.h" #include "gtest/gtest.h" @@ -34,14 +35,10 @@ void AUBCommandStreamFixture::SetUp(CommandQueue *pCmdQ) { auto engineType = pCmdQ->getGpgpuCommandStreamReceiver().getOsContext().getEngineType(); strfilename << testInfo->test_case_name() << "_" << testInfo->name() << "_" << hwHelper.getCsTraits(engineType).name; - if (testMode == TestMode::AubTestsWithTbx) { - pCommandStreamReceiver = TbxCommandStreamReceiver::create(strfilename.str(), true, *device.executionEnvironment, device.getRootDeviceIndex(), device.getDeviceBitfield()); - } else { - pCommandStreamReceiver = AUBCommandStreamReceiver::create(strfilename.str(), true, *device.executionEnvironment, device.getRootDeviceIndex(), device.getDeviceBitfield()); - } + pCommandStreamReceiver = AUBFixture::prepareComputeEngine(device, strfilename.str()); ASSERT_NE(nullptr, pCommandStreamReceiver); - device.resetCommandStreamReceiver(pCommandStreamReceiver); + AUBFixture::prepareCopyEngines(device, strfilename.str()); CommandStreamFixture::SetUp(pCmdQ); diff --git a/opencl/test/unit_test/aub_tests/fixtures/aub_fixture.h b/opencl/test/unit_test/aub_tests/fixtures/aub_fixture.h index 9795f8616f..8a6f001bb6 100644 --- a/opencl/test/unit_test/aub_tests/fixtures/aub_fixture.h +++ b/opencl/test/unit_test/aub_tests/fixtures/aub_fixture.h @@ -30,6 +30,30 @@ namespace NEO { class AUBFixture : public CommandQueueHwFixture { public: + static CommandStreamReceiver *prepareComputeEngine(MockDevice &device, const std::string &filename) { + CommandStreamReceiver *pCommandStreamReceiver = nullptr; + if (testMode == TestMode::AubTestsWithTbx) { + pCommandStreamReceiver = TbxCommandStreamReceiver::create(filename, true, *device.executionEnvironment, device.getRootDeviceIndex(), device.getDeviceBitfield()); + } else { + pCommandStreamReceiver = AUBCommandStreamReceiver::create(filename, true, *device.executionEnvironment, device.getRootDeviceIndex(), device.getDeviceBitfield()); + } + device.resetCommandStreamReceiver(pCommandStreamReceiver); + return pCommandStreamReceiver; + } + static void prepareCopyEngines(MockDevice &device, const std::string &filename) { + for (auto i = 0u; i < device.engines.size(); i++) { + if (EngineHelpers::isBcs(device.engines[i].getEngineType())) { + CommandStreamReceiver *pBcsCommandStreamReceiver = nullptr; + if (testMode == TestMode::AubTestsWithTbx) { + pBcsCommandStreamReceiver = TbxCommandStreamReceiver::create(filename, true, *device.executionEnvironment, device.getRootDeviceIndex(), device.getDeviceBitfield()); + } else { + pBcsCommandStreamReceiver = AUBCommandStreamReceiver::create(filename, true, *device.executionEnvironment, device.getRootDeviceIndex(), device.getDeviceBitfield()); + } + device.resetCommandStreamReceiver(pBcsCommandStreamReceiver, i); + } + } + } + void SetUp(const HardwareInfo *hardwareInfo) { const HardwareInfo &hwInfo = hardwareInfo ? *hardwareInfo : *defaultHwInfo; @@ -45,15 +69,12 @@ class AUBFixture : public CommandQueueHwFixture { executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(&hwInfo); executionEnvironment->rootDeviceEnvironments[0]->memoryOperationsInterface = std::make_unique(); - device = std::make_unique(MockDevice::create(executionEnvironment, rootDeviceIndex)); + auto pDevice = MockDevice::create(executionEnvironment, rootDeviceIndex); + device = std::make_unique(pDevice); - if (testMode == TestMode::AubTestsWithTbx) { - this->csr = TbxCommandStreamReceiver::create(strfilename.str(), true, *executionEnvironment, 0, device->getDeviceBitfield()); - } else { - this->csr = AUBCommandStreamReceiver::create(strfilename.str(), true, *executionEnvironment, 0, device->getDeviceBitfield()); - } + this->csr = prepareComputeEngine(*pDevice, strfilename.str()); - device->resetCommandStreamReceiver(this->csr); + prepareCopyEngines(*pDevice, strfilename.str()); CommandQueueHwFixture::SetUp(AUBFixture::device.get(), cl_command_queue_properties(0)); } diff --git a/opencl/test/unit_test/helpers/hw_helper_tests.cpp b/opencl/test/unit_test/helpers/hw_helper_tests.cpp index 48789a0f90..6ddf599438 100644 --- a/opencl/test/unit_test/helpers/hw_helper_tests.cpp +++ b/opencl/test/unit_test/helpers/hw_helper_tests.cpp @@ -937,13 +937,15 @@ HWTEST_F(HwHelperTest, givenDefaultHwHelperHwWhenMinimalSIMDSizeIsQueriedThen8Is EXPECT_EQ(8u, helper.getMinimalSIMDSize()); } -HWTEST_F(HwHelperTest, whenGettingIsBlitCopyRequiredForLocalMemoryThenCorrectValuesAreReturned) { +HWTEST_F(HwHelperTest, givenLockableAllocationWhenGettingIsBlitCopyRequiredForLocalMemoryThenCorrectValuesAreReturned) { DebugManagerStateRestore restore{}; auto &helper = HwHelper::get(renderCoreFamily); HardwareInfo hwInfo = *defaultHwInfo; hwInfo.capabilityTable.blitterOperationsSupported = true; MockGraphicsAllocation graphicsAllocation; + graphicsAllocation.setAllocationType(GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY); + EXPECT_TRUE(GraphicsAllocation::isLockable(graphicsAllocation.getAllocationType())); graphicsAllocation.overrideMemoryPool(MemoryPool::LocalMemory); auto expectedDefaultValue = (helper.getLocalMemoryAccessMode(hwInfo) == LocalMemoryAccessMode::CpuAccessDisallowed); @@ -957,7 +959,36 @@ HWTEST_F(HwHelperTest, whenGettingIsBlitCopyRequiredForLocalMemoryThenCorrectVal DebugManager.flags.ForceLocalMemoryAccessMode.set(3); EXPECT_TRUE(helper.isBlitCopyRequiredForLocalMemory(hwInfo, graphicsAllocation)); hwInfo.capabilityTable.blitterOperationsSupported = false; + EXPECT_TRUE(helper.isBlitCopyRequiredForLocalMemory(hwInfo, graphicsAllocation)); + + graphicsAllocation.overrideMemoryPool(MemoryPool::System64KBPages); EXPECT_FALSE(helper.isBlitCopyRequiredForLocalMemory(hwInfo, graphicsAllocation)); + hwInfo.capabilityTable.blitterOperationsSupported = true; + EXPECT_FALSE(helper.isBlitCopyRequiredForLocalMemory(hwInfo, graphicsAllocation)); +} + +HWTEST_F(HwHelperTest, givenNotLockableAllocationWhenGettingIsBlitCopyRequiredForLocalMemoryThenCorrectValuesAreReturned) { + DebugManagerStateRestore restore{}; + auto &helper = HwHelper::get(renderCoreFamily); + HardwareInfo hwInfo = *defaultHwInfo; + hwInfo.capabilityTable.blitterOperationsSupported = true; + + MockGraphicsAllocation graphicsAllocation; + graphicsAllocation.setAllocationType(GraphicsAllocation::AllocationType::SVM_GPU); + EXPECT_FALSE(GraphicsAllocation::isLockable(graphicsAllocation.getAllocationType())); + graphicsAllocation.overrideMemoryPool(MemoryPool::LocalMemory); + + EXPECT_TRUE(helper.isBlitCopyRequiredForLocalMemory(hwInfo, graphicsAllocation)); + + DebugManager.flags.ForceLocalMemoryAccessMode.set(0); + EXPECT_TRUE(helper.isBlitCopyRequiredForLocalMemory(hwInfo, graphicsAllocation)); + DebugManager.flags.ForceLocalMemoryAccessMode.set(1); + EXPECT_TRUE(helper.isBlitCopyRequiredForLocalMemory(hwInfo, graphicsAllocation)); + + DebugManager.flags.ForceLocalMemoryAccessMode.set(3); + EXPECT_TRUE(helper.isBlitCopyRequiredForLocalMemory(hwInfo, graphicsAllocation)); + hwInfo.capabilityTable.blitterOperationsSupported = false; + EXPECT_TRUE(helper.isBlitCopyRequiredForLocalMemory(hwInfo, graphicsAllocation)); graphicsAllocation.overrideMemoryPool(MemoryPool::System64KBPages); EXPECT_FALSE(helper.isBlitCopyRequiredForLocalMemory(hwInfo, graphicsAllocation)); @@ -999,6 +1030,7 @@ HWTEST2_F(HwHelperTest, givenDefaultHwHelperHwWhenGettingIsBlitCopyRequiredForLo auto &helper = HwHelper::get(renderCoreFamily); MockGraphicsAllocation graphicsAllocation; graphicsAllocation.overrideMemoryPool(MemoryPool::LocalMemory); + graphicsAllocation.setAllocationType(GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY); EXPECT_FALSE(helper.isBlitCopyRequiredForLocalMemory(*defaultHwInfo, graphicsAllocation)); } diff --git a/opencl/test/unit_test/memory_manager/graphics_allocation_tests.cpp b/opencl/test/unit_test/memory_manager/graphics_allocation_tests.cpp index ecbe361f16..9c1d4f1ea9 100644 --- a/opencl/test/unit_test/memory_manager/graphics_allocation_tests.cpp +++ b/opencl/test/unit_test/memory_manager/graphics_allocation_tests.cpp @@ -179,8 +179,8 @@ TEST(GraphicsAllocationTest, whenAllocationTypeIsGpuTimestampDeviceBufferThenAll EXPECT_TRUE(GraphicsAllocation::isLockable(GraphicsAllocation::AllocationType::GPU_TIMESTAMP_DEVICE_BUFFER)); } -TEST(GraphicsAllocationTest, whenAllocationTypeIsSvmGpuThenAllocationIsLockable) { - EXPECT_TRUE(GraphicsAllocation::isLockable(GraphicsAllocation::AllocationType::SVM_GPU)); +TEST(GraphicsAllocationTest, whenAllocationTypeIsSvmGpuThenAllocationIsNotLockable) { + EXPECT_FALSE(GraphicsAllocation::isLockable(GraphicsAllocation::AllocationType::SVM_GPU)); } TEST(GraphicsAllocationTest, whenAllocationTypeIsSharedResourceCopyThenAllocationIsLockable) { diff --git a/shared/source/device/device.cpp b/shared/source/device/device.cpp index ea1aae5698..aaf5fb25ad 100644 --- a/shared/source/device/device.cpp +++ b/shared/source/device/device.cpp @@ -439,18 +439,24 @@ size_t Device::getIndexOfNonEmptyEngineGroup(EngineGroupType engineGroupType) co return result; } -EngineControl &Device::getEngine(aub_stream::EngineType engineType, EngineUsage engineUsage) { +EngineControl *Device::tryGetEngine(aub_stream::EngineType engineType, EngineUsage engineUsage) { for (auto &engine : engines) { if (engine.osContext->getEngineType() == engineType && engine.osContext->isLowPriority() == (engineUsage == EngineUsage::LowPriority) && engine.osContext->isInternalEngine() == (engineUsage == EngineUsage::Internal)) { - return engine; + return &engine; } } if (DebugManager.flags.OverrideInvalidEngineWithDefault.get()) { - return engines[0]; + return &engines[0]; } - UNRECOVERABLE_IF(true); + return nullptr; +} + +EngineControl &Device::getEngine(aub_stream::EngineType engineType, EngineUsage engineUsage) { + auto engine = tryGetEngine(engineType, engineUsage); + UNRECOVERABLE_IF(!engine); + return *engine; } EngineControl &Device::getEngine(uint32_t index) { diff --git a/shared/source/device/device.h b/shared/source/device/device.h index a4691a1fa1..c51447d553 100644 --- a/shared/source/device/device.h +++ b/shared/source/device/device.h @@ -49,6 +49,7 @@ class Device : public ReferenceTrackedObject { bool getHostTimer(uint64_t *hostTimestamp) const; const HardwareInfo &getHardwareInfo() const; const DeviceInfo &getDeviceInfo() const; + EngineControl *tryGetEngine(aub_stream::EngineType engineType, EngineUsage engineUsage); EngineControl &getEngine(aub_stream::EngineType engineType, EngineUsage engineUsage); std::vector> &getEngineGroups() { return this->engineGroups; diff --git a/shared/source/helpers/hw_helper_base.inl b/shared/source/helpers/hw_helper_base.inl index d641ac75c2..735cc6a1fa 100644 --- a/shared/source/helpers/hw_helper_base.inl +++ b/shared/source/helpers/hw_helper_base.inl @@ -452,8 +452,7 @@ inline bool HwHelperHw::allowRenderCompression(const HardwareInfo &hw template inline bool HwHelperHw::isBlitCopyRequiredForLocalMemory(const HardwareInfo &hwInfo, const GraphicsAllocation &allocation) const { return allocation.isAllocatedInLocalMemoryPool() && - (getLocalMemoryAccessMode(hwInfo) == LocalMemoryAccessMode::CpuAccessDisallowed) && - hwInfo.capabilityTable.blitterOperationsSupported; + (getLocalMemoryAccessMode(hwInfo) == LocalMemoryAccessMode::CpuAccessDisallowed || !GraphicsAllocation::isLockable(allocation.getAllocationType())); } template diff --git a/shared/source/memory_manager/graphics_allocation.h b/shared/source/memory_manager/graphics_allocation.h index 0c6aa6c272..34b0c99cfe 100644 --- a/shared/source/memory_manager/graphics_allocation.h +++ b/shared/source/memory_manager/graphics_allocation.h @@ -236,7 +236,6 @@ class GraphicsAllocation : public IDNode { isIsaAllocationType(allocationType) || allocationType == AllocationType::BUFFER_HOST_MEMORY || allocationType == AllocationType::GPU_TIMESTAMP_DEVICE_BUFFER || - allocationType == AllocationType::SVM_GPU || allocationType == AllocationType::SHARED_RESOURCE_COPY; }