From 8b513580543a9e1f868409e13aa78878c95f14c0 Mon Sep 17 00:00:00 2001 From: Jitendra Sharma Date: Fri, 3 Dec 2021 17:48:12 +0000 Subject: [PATCH] In level zero create single tag allocation for csr Multi tag allocation is useful only in openCL to ensure cross root device synchronization based on tag address. It is not required in level zero. Futher multi tag allocation is causing instability in sysman device reset. So, for level zero instead of multi tag allocation create single tag allocation. Related-To: LOCI-2651 Signed-off-by: Jitendra Sharma --- .../command_stream_receiver.cpp | 13 ++++--- .../api_specific_config_shared_tests.cpp | 4 ++- .../command_stream_receiver_tests.cpp | 35 +++++++++++++++++++ 3 files changed, 47 insertions(+), 5 deletions(-) diff --git a/shared/source/command_stream/command_stream_receiver.cpp b/shared/source/command_stream/command_stream_receiver.cpp index 7b57b3ced2..f068567342 100644 --- a/shared/source/command_stream/command_stream_receiver.cpp +++ b/shared/source/command_stream/command_stream_receiver.cpp @@ -16,6 +16,7 @@ #include "shared/source/direct_submission/direct_submission_controller.h" #include "shared/source/execution_environment/root_device_environment.h" #include "shared/source/gmm_helper/page_table_mngr.h" +#include "shared/source/helpers/api_specific_config.h" #include "shared/source/helpers/array_count.h" #include "shared/source/helpers/cache_policy.h" #include "shared/source/helpers/flush_stamp.h" @@ -330,10 +331,14 @@ void CommandStreamReceiver::setTagAllocation(GraphicsAllocation *allocation) { MultiGraphicsAllocation &CommandStreamReceiver::createTagsMultiAllocation() { std::vector rootDeviceIndices; - for (auto index = 0u; index < this->executionEnvironment.rootDeviceEnvironments.size(); index++) { - if (this->executionEnvironment.rootDeviceEnvironments[index].get()->getHardwareInfo()->platform.eProductFamily == - this->executionEnvironment.rootDeviceEnvironments[this->rootDeviceIndex].get()->getHardwareInfo()->platform.eProductFamily) { - rootDeviceIndices.push_back(index); + if (ApiSpecificConfig::getApiType() == ApiSpecificConfig::L0) { + rootDeviceIndices.push_back(rootDeviceIndex); + } else { + for (auto index = 0u; index < this->executionEnvironment.rootDeviceEnvironments.size(); index++) { + if (this->executionEnvironment.rootDeviceEnvironments[index].get()->getHardwareInfo()->platform.eProductFamily == + this->executionEnvironment.rootDeviceEnvironments[this->rootDeviceIndex].get()->getHardwareInfo()->platform.eProductFamily) { + rootDeviceIndices.push_back(index); + } } } diff --git a/shared/test/common/helpers/api_specific_config_shared_tests.cpp b/shared/test/common/helpers/api_specific_config_shared_tests.cpp index ce71e04690..9c17e0dc67 100644 --- a/shared/test/common/helpers/api_specific_config_shared_tests.cpp +++ b/shared/test/common/helpers/api_specific_config_shared_tests.cpp @@ -9,6 +9,7 @@ #include "shared/source/helpers/api_specific_config.h" namespace NEO { +ApiSpecificConfig::ApiType apiTypeForUlts = ApiSpecificConfig::OCL; bool ApiSpecificConfig::isStatelessCompressionSupported() { return ApiSpecificConfig::ApiType::OCL == ApiSpecificConfig::getApiType(); } @@ -22,8 +23,9 @@ bool ApiSpecificConfig::getBindlessConfiguration() { return false; } } + ApiSpecificConfig::ApiType ApiSpecificConfig::getApiType() { - return ApiSpecificConfig::OCL; + return apiTypeForUlts; } uint64_t ApiSpecificConfig::getReducedMaxAllocSize(uint64_t maxAllocSize) { diff --git a/shared/test/unit_test/command_stream/command_stream_receiver_tests.cpp b/shared/test/unit_test/command_stream/command_stream_receiver_tests.cpp index 427c157147..75110de5e2 100644 --- a/shared/test/unit_test/command_stream/command_stream_receiver_tests.cpp +++ b/shared/test/unit_test/command_stream/command_stream_receiver_tests.cpp @@ -8,6 +8,7 @@ #include "shared/source/command_container/implicit_scaling.h" #include "shared/source/command_stream/command_stream_receiver_simulated_hw.h" #include "shared/source/gmm_helper/page_table_mngr.h" +#include "shared/source/helpers/api_specific_config.h" #include "shared/source/memory_manager/internal_allocation_storage.h" #include "shared/source/memory_manager/surface.h" #include "shared/source/os_interface/device_factory.h" @@ -30,6 +31,9 @@ #include "gmock/gmock.h" +namespace NEO { +extern ApiSpecificConfig::ApiType apiTypeForUlts; +} // namespace NEO using namespace NEO; struct CommandStreamReceiverTest : public DeviceFixture, @@ -796,6 +800,37 @@ HWTEST_F(CommandStreamReceiverTest, givenUltCommandStreamReceiverWhenAddAubComme EXPECT_TRUE(csr.addAubCommentCalled); } +TEST(CommandStreamReceiverSimpleTest, givenCommandStreamReceiverWhenInitializeTagAllocationForOpenCLThenMultiTagAllocationIsBeingAllocated) { + VariableBackup backup(&apiTypeForUlts, ApiSpecificConfig::OCL); + uint32_t numRootDevices = 10u; + UltDeviceFactory deviceFactory{numRootDevices, 0}; + EXPECT_NE(nullptr, deviceFactory.rootDevices[0]->commandStreamReceivers[0]->getTagAllocation()); + EXPECT_EQ(GraphicsAllocation::AllocationType::TAG_BUFFER, deviceFactory.rootDevices[0]->commandStreamReceivers[0]->getTagAllocation()->getAllocationType()); + EXPECT_TRUE(deviceFactory.rootDevices[0]->commandStreamReceivers[0]->getTagAddress() != nullptr); + EXPECT_EQ(*deviceFactory.rootDevices[0]->commandStreamReceivers[0]->getTagAddress(), initialHardwareTag); + auto tagsMultiAllocation = deviceFactory.rootDevices[0]->commandStreamReceivers[0]->getTagsMultiAllocation(); + auto graphicsAllocation0 = tagsMultiAllocation->getGraphicsAllocation(0); + EXPECT_EQ(tagsMultiAllocation->getGraphicsAllocations().size(), numRootDevices); + + for (auto graphicsAllocation : tagsMultiAllocation->getGraphicsAllocations()) { + if (graphicsAllocation != graphicsAllocation0) { + EXPECT_EQ(graphicsAllocation->getUnderlyingBuffer(), graphicsAllocation0->getUnderlyingBuffer()); + } + } +} + +TEST(CommandStreamReceiverSimpleTest, givenCommandStreamReceiverWhenInitializeTagAllocationForLevelZeroThenSingleTagAllocationIsBeingAllocated) { + VariableBackup backup(&apiTypeForUlts, ApiSpecificConfig::L0); + uint32_t numRootDevices = 10u; + UltDeviceFactory deviceFactory{numRootDevices, 0}; + EXPECT_NE(nullptr, deviceFactory.rootDevices[0]->commandStreamReceivers[0]->getTagAllocation()); + EXPECT_EQ(GraphicsAllocation::AllocationType::TAG_BUFFER, deviceFactory.rootDevices[0]->commandStreamReceivers[0]->getTagAllocation()->getAllocationType()); + EXPECT_TRUE(deviceFactory.rootDevices[0]->commandStreamReceivers[0]->getTagAddress() != nullptr); + EXPECT_EQ(*deviceFactory.rootDevices[0]->commandStreamReceivers[0]->getTagAddress(), initialHardwareTag); + auto tagsMultiAllocation = deviceFactory.rootDevices[0]->commandStreamReceivers[0]->getTagsMultiAllocation(); + EXPECT_EQ(tagsMultiAllocation->getGraphicsAllocations().size(), 1u); +} + TEST(CommandStreamReceiverSimpleTest, givenCommandStreamReceiverWhenItIsDestroyedThenItDestroysTagAllocation) { struct MockGraphicsAllocationWithDestructorTracing : public MockGraphicsAllocation { using MockGraphicsAllocation::MockGraphicsAllocation;