From b8d19ccfb5d6f896c9f5560344a8deb458da84fe Mon Sep 17 00:00:00 2001 From: Kacper Nowak Date: Fri, 5 Apr 2024 02:02:14 +0000 Subject: [PATCH] refactor: Move logic for querying maxMemoryFillPatternSize to product helper Signed-off-by: Kacper Nowak --- level_zero/core/source/cmdlist/cmdlist_hw.inl | 2 +- level_zero/core/source/device/device_imp.cpp | 14 ++++++++------ .../unit_tests/sources/cmdlist/test_cmdlist_4.cpp | 6 +++--- .../test/unit_tests/sources/memory/test_memory.cpp | 12 ++++++------ shared/source/os_interface/product_helper.h | 1 + shared/source/os_interface/product_helper.inl | 5 +++++ .../os_interface/product_helper_before_gen12lp.inl | 7 ++++++- shared/source/os_interface/product_helper_hw.h | 1 + 8 files changed, 31 insertions(+), 17 deletions(-) diff --git a/level_zero/core/source/cmdlist/cmdlist_hw.inl b/level_zero/core/source/cmdlist/cmdlist_hw.inl index f138ba0ab0..473b38fa20 100644 --- a/level_zero/core/source/cmdlist/cmdlist_hw.inl +++ b/level_zero/core/source/cmdlist/cmdlist_hw.inl @@ -235,7 +235,7 @@ ze_result_t CommandListCoreFamily::initialize(Device *device, NEO this->dummyBlitWa.rootDeviceEnvironment = &(neoDevice->getRootDeviceEnvironmentRef()); this->dispatchCmdListBatchBufferAsPrimary = L0GfxCoreHelper::dispatchCmdListBatchBufferAsPrimary(rootDeviceEnvironment, !isImmediateType()); this->useOnlyGlobalTimestamps = gfxCoreHelper.useOnlyGlobalTimestamps(); - this->maxFillPaternSizeForCopyEngine = gfxCoreHelper.getMaxFillPaternSizeForCopyEngine(); + this->maxFillPaternSizeForCopyEngine = productHelper.getMaxFillPaternSizeForCopyEngine(); this->heaplessModeEnabled = compilerProductHelper.isHeaplessModeEnabled(); this->heaplessStateInitEnabled = compilerProductHelper.isHeaplessStateInitEnabled(); this->requiredStreamState.initSupport(rootDeviceEnvironment); diff --git a/level_zero/core/source/device/device_imp.cpp b/level_zero/core/source/device/device_imp.cpp index 8ee9696c7e..f69230b70e 100644 --- a/level_zero/core/source/device/device_imp.cpp +++ b/level_zero/core/source/device/device_imp.cpp @@ -375,13 +375,14 @@ uint32_t DeviceImp::getCopyQueueGroupsFromSubDevice(uint32_t numberOfSubDeviceCo return numSubDeviceCopyEngineGroups; } - auto &gfxCoreHelper = this->neoDevice->getRootDeviceEnvironment().getHelper(); - auto &l0GfxCoreHelper = this->neoDevice->getRootDeviceEnvironment().getHelper(); + auto &rootDeviceEnv = this->neoDevice->getRootDeviceEnvironment(); + auto &l0GfxCoreHelper = rootDeviceEnv.getHelper(); + auto &productHelper = rootDeviceEnv.getHelper(); uint32_t subDeviceQueueGroupsIter = 0; for (; subDeviceQueueGroupsIter < std::min(numSubDeviceCopyEngineGroups, numberOfSubDeviceCopyEngineGroupsRequested); subDeviceQueueGroupsIter++) { pCommandQueueGroupProperties[subDeviceQueueGroupsIter].flags = ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COPY; - pCommandQueueGroupProperties[subDeviceQueueGroupsIter].maxMemoryFillPatternSize = gfxCoreHelper.getMaxFillPaternSizeForCopyEngine(); + pCommandQueueGroupProperties[subDeviceQueueGroupsIter].maxMemoryFillPatternSize = productHelper.getMaxFillPaternSizeForCopyEngine(); l0GfxCoreHelper.setAdditionalGroupProperty(pCommandQueueGroupProperties[subDeviceQueueGroupsIter], this->subDeviceCopyEngineGroups[subDeviceQueueGroupsIter]); pCommandQueueGroupProperties[subDeviceQueueGroupsIter].numQueues = static_cast(this->subDeviceCopyEngineGroups[subDeviceQueueGroupsIter].engines.size()); @@ -408,8 +409,9 @@ ze_result_t DeviceImp::getCommandQueueGroupProperties(uint32_t *pCount, return ZE_RESULT_SUCCESS; } - auto &gfxCoreHelper = this->neoDevice->getRootDeviceEnvironment().getHelper(); - auto &l0GfxCoreHelper = this->neoDevice->getRootDeviceEnvironment().getHelper(); + auto &rootDeviceEnv = this->neoDevice->getRootDeviceEnvironment(); + auto &l0GfxCoreHelper = rootDeviceEnv.getHelper(); + auto &productHelper = rootDeviceEnv.getHelper(); *pCount = std::min(totalEngineGroups, *pCount); for (uint32_t i = 0; i < std::min(numEngineGroups, *pCount); i++) { @@ -428,7 +430,7 @@ ze_result_t DeviceImp::getCommandQueueGroupProperties(uint32_t *pCount, } if (engineGroups[i].engineGroupType == NEO::EngineGroupType::copy) { pCommandQueueGroupProperties[i].flags = ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COPY; - pCommandQueueGroupProperties[i].maxMemoryFillPatternSize = gfxCoreHelper.getMaxFillPaternSizeForCopyEngine(); + pCommandQueueGroupProperties[i].maxMemoryFillPatternSize = productHelper.getMaxFillPaternSizeForCopyEngine(); } l0GfxCoreHelper.setAdditionalGroupProperty(pCommandQueueGroupProperties[i], engineGroups[i]); pCommandQueueGroupProperties[i].numQueues = static_cast(engineGroups[i].engines.size()); diff --git a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_4.cpp b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_4.cpp index e9ca3ee087..fbe91597f8 100644 --- a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_4.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_4.cpp @@ -914,7 +914,7 @@ HWTEST2_F(HostPointerManagerCommandListTest, auto ret = hostDriverHandle->importExternalPointer(heapPointer, MemoryConstants::pageSize); EXPECT_EQ(ZE_RESULT_SUCCESS, ret); - int pattern = 1; + char pattern = 'a'; ret = commandList->appendMemoryFill(heapPointer, reinterpret_cast(&pattern), sizeof(pattern), 64u, nullptr, 0, nullptr, false); EXPECT_EQ(ZE_RESULT_SUCCESS, ret); @@ -1091,7 +1091,7 @@ HWTEST2_F(HostPointerManagerCommandListTest, givenCommandListWhenMemoryFillWithS auto ret = hostDriverHandle->importExternalPointer(heapPointer, MemoryConstants::pageSize); EXPECT_EQ(ZE_RESULT_SUCCESS, ret); - int one = 1; + char pattern = 'a'; size_t size = 16; ze_event_pool_desc_t eventPoolDesc = {}; @@ -1109,7 +1109,7 @@ HWTEST2_F(HostPointerManagerCommandListTest, givenCommandListWhenMemoryFillWithS auto event1 = std::unique_ptr(L0::Event::create(eventPool.get(), &eventDesc, device)); events.push_back(event1.get()); - result = commandList->appendMemoryFill(heapPointer, reinterpret_cast(&one), sizeof(one), size, + result = commandList->appendMemoryFill(heapPointer, reinterpret_cast(&pattern), sizeof(pattern), size, events[0], 1, &events[1], false); EXPECT_EQ(ZE_RESULT_SUCCESS, result); diff --git a/level_zero/core/test/unit_tests/sources/memory/test_memory.cpp b/level_zero/core/test/unit_tests/sources/memory/test_memory.cpp index 38049c57bc..e6fb0da13f 100644 --- a/level_zero/core/test/unit_tests/sources/memory/test_memory.cpp +++ b/level_zero/core/test/unit_tests/sources/memory/test_memory.cpp @@ -4180,7 +4180,7 @@ HWTEST2_F(MultipleDevicePeerAllocationTest, auto commandList = std::make_unique<::L0::ult::CommandListCoreFamily>(); commandList->initialize(device1, NEO::EngineGroupType::renderCompute, 0u); - uint32_t pattern = 1; + char pattern = 'a'; result = commandList->appendBlitFill(ptr, &pattern, sizeof(pattern), size, nullptr, 0, nullptr, false); EXPECT_EQ(result, ZE_RESULT_ERROR_INVALID_ARGUMENT); @@ -4206,7 +4206,7 @@ HWTEST2_F(MultipleDevicePeerAllocationTest, auto commandList = std::make_unique<::L0::ult::CommandListCoreFamily>(); commandList->initialize(device0, NEO::EngineGroupType::renderCompute, 0u); - uint32_t pattern = 1; + char pattern = 'a'; result = commandList->appendBlitFill(ptr, &pattern, sizeof(pattern), size, nullptr, 0, nullptr, false); EXPECT_EQ(result, ZE_RESULT_SUCCESS); @@ -4233,7 +4233,7 @@ HWTEST2_F(MultipleDevicePeerAllocationTest, auto commandList = std::make_unique<::L0::ult::CommandListCoreFamily>(); commandList->initialize(device1, NEO::EngineGroupType::renderCompute, 0u); - uint32_t pattern = 1; + char pattern = 'a'; result = commandList->appendBlitFill(ptr, &pattern, sizeof(pattern), size, nullptr, 0, nullptr, false); EXPECT_EQ(result, ZE_RESULT_SUCCESS); @@ -4264,7 +4264,7 @@ HWTEST2_F(MultipleDevicePeerAllocationTest, auto commandList = std::make_unique<::L0::ult::CommandListCoreFamily>(); commandList->initialize(device1, NEO::EngineGroupType::renderCompute, 0u); - uint32_t pattern = 1; + char pattern = 'a'; result = commandList->appendBlitFill(ptr, &pattern, sizeof(pattern), size, nullptr, 0, nullptr, false); EXPECT_EQ(result, ZE_RESULT_SUCCESS); @@ -4291,7 +4291,7 @@ HWTEST2_F(MultipleDevicePeerAllocationTest, auto commandList = std::make_unique<::L0::ult::CommandListCoreFamily>(); commandList->initialize(device0, NEO::EngineGroupType::renderCompute, 0u); - uint32_t pattern = 1; + char pattern = 'a'; result = commandList->appendBlitFill(ptr, &pattern, sizeof(pattern), size, nullptr, 0, nullptr, false); EXPECT_EQ(result, ZE_RESULT_SUCCESS); @@ -4310,7 +4310,7 @@ HWTEST2_F(MultipleDevicePeerAllocationTest, auto commandList = std::make_unique<::L0::ult::CommandListCoreFamily>(); commandList->initialize(device0, NEO::EngineGroupType::renderCompute, 0u); - uint32_t pattern = 1; + char pattern = 'a'; ze_result_t result = commandList->appendBlitFill(ptr, &pattern, sizeof(pattern), size, nullptr, 0, nullptr, false); EXPECT_EQ(result, ZE_RESULT_ERROR_INVALID_ARGUMENT); diff --git a/shared/source/os_interface/product_helper.h b/shared/source/os_interface/product_helper.h index 14ba31ff75..59f0366228 100644 --- a/shared/source/os_interface/product_helper.h +++ b/shared/source/os_interface/product_helper.h @@ -227,6 +227,7 @@ class ProductHelper { virtual bool isNewCoherencyModelSupported() const = 0; virtual const std::vector getSupportedLocalDispatchSizes() const = 0; virtual bool supportReadOnlyAllocations() const = 0; + virtual size_t getMaxFillPaternSizeForCopyEngine() const = 0; virtual ~ProductHelper() = default; diff --git a/shared/source/os_interface/product_helper.inl b/shared/source/os_interface/product_helper.inl index 83904ddcca..a456fcc42f 100644 --- a/shared/source/os_interface/product_helper.inl +++ b/shared/source/os_interface/product_helper.inl @@ -850,4 +850,9 @@ template const std::vector ProductHelperHw::getSupportedLocalDispatchSizes() const { return {}; } + +template +size_t ProductHelperHw::getMaxFillPaternSizeForCopyEngine() const { + return 4 * sizeof(uint32_t); +} } // namespace NEO diff --git a/shared/source/os_interface/product_helper_before_gen12lp.inl b/shared/source/os_interface/product_helper_before_gen12lp.inl index f5bd695b1c..9f531a4518 100644 --- a/shared/source/os_interface/product_helper_before_gen12lp.inl +++ b/shared/source/os_interface/product_helper_before_gen12lp.inl @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2023 Intel Corporation + * Copyright (C) 2019-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -13,4 +13,9 @@ template <> void ProductHelperHw::adjustSamplerState(void *sampler, const HardwareInfo &hwInfo) const { } +template <> +size_t ProductHelperHw::getMaxFillPaternSizeForCopyEngine() const { + return sizeof(uint32_t); +} + } // namespace NEO diff --git a/shared/source/os_interface/product_helper_hw.h b/shared/source/os_interface/product_helper_hw.h index c21bb8d636..dcf4a950f4 100644 --- a/shared/source/os_interface/product_helper_hw.h +++ b/shared/source/os_interface/product_helper_hw.h @@ -172,6 +172,7 @@ class ProductHelperHw : public ProductHelper { bool isNewCoherencyModelSupported() const override; bool supportReadOnlyAllocations() const override; const std::vector getSupportedLocalDispatchSizes() const override; + size_t getMaxFillPaternSizeForCopyEngine() const override; ~ProductHelperHw() override = default;