diff --git a/shared/source/aub/aub_helper.cpp b/shared/source/aub/aub_helper.cpp index 036e846f44..f0aa56faf0 100644 --- a/shared/source/aub/aub_helper.cpp +++ b/shared/source/aub/aub_helper.cpp @@ -40,6 +40,7 @@ bool AubHelper::isOneTimeAubWritableAllocationType(const AllocationType &type) { case AllocationType::assertBuffer: case AllocationType::tagBuffer: case AllocationType::syncDispatchToken: + case AllocationType::hostFunction: return true; case AllocationType::bufferHostMemory: return NEO::debugManager.isTbxPageFaultManagerEnabled() || diff --git a/shared/source/command_stream/command_stream_receiver.cpp b/shared/source/command_stream/command_stream_receiver.cpp index d3b0219307..12d074a228 100644 --- a/shared/source/command_stream/command_stream_receiver.cpp +++ b/shared/source/command_stream/command_stream_receiver.cpp @@ -418,6 +418,16 @@ void CommandStreamReceiver::cleanupResources() { tagsMultiAllocation = nullptr; } + if (hostFunctionDataMultiAllocation) { + hostFunctionDataAllocation = nullptr; + + for (auto graphicsAllocation : hostFunctionDataMultiAllocation->getGraphicsAllocations()) { + getMemoryManager()->freeGraphicsMemory(graphicsAllocation); + } + delete hostFunctionDataMultiAllocation; + hostFunctionDataMultiAllocation = nullptr; + } + if (globalFenceAllocation) { getMemoryManager()->freeGraphicsMemory(globalFenceAllocation); globalFenceAllocation = nullptr; @@ -538,7 +548,7 @@ void CommandStreamReceiver::setTagAllocation(GraphicsAllocation *allocation) { reinterpret_cast(allocation->getUnderlyingBuffer()) + TagAllocationLayout::debugPauseStateAddressOffset); } -MultiGraphicsAllocation &CommandStreamReceiver::createTagsMultiAllocation() { +MultiGraphicsAllocation &CommandStreamReceiver::createMultiAllocationInSystemMemoryPool(AllocationType allocationType) { RootDeviceIndicesContainer rootDeviceIndices; rootDeviceIndices.pushUnique(rootDeviceIndex); @@ -546,7 +556,7 @@ MultiGraphicsAllocation &CommandStreamReceiver::createTagsMultiAllocation() { auto maxRootDeviceIndex = static_cast(this->executionEnvironment.rootDeviceEnvironments.size() - 1); auto allocations = new MultiGraphicsAllocation(maxRootDeviceIndex); - AllocationProperties unifiedMemoryProperties{rootDeviceIndex, MemoryConstants::pageSize, AllocationType::tagBuffer, systemMemoryBitfield}; + AllocationProperties unifiedMemoryProperties{rootDeviceIndex, MemoryConstants::pageSize, allocationType, systemMemoryBitfield}; this->getMemoryManager()->createMultiGraphicsAllocationInSystemMemoryPool(rootDeviceIndices, unifiedMemoryProperties, *allocations); return *allocations; @@ -695,6 +705,37 @@ void *CommandStreamReceiver::getIndirectHeapCurrentPtr(IndirectHeapType heapType return nullptr; } +void CommandStreamReceiver::ensureHostFunctionDataInitialization() { + if (hostFunctionInitialized == false) { + initializeHostFunctionData(); + } +} + +void CommandStreamReceiver::initializeHostFunctionData() { + + auto lock = obtainUniqueOwnership(); + + if (hostFunctionInitialized) { + return; + } + this->hostFunctionDataMultiAllocation = &this->createMultiAllocationInSystemMemoryPool(AllocationType::hostFunction); + this->hostFunctionDataAllocation = hostFunctionDataMultiAllocation->getGraphicsAllocation(rootDeviceIndex); + + void *hostFunctionBuffer = hostFunctionDataAllocation->getUnderlyingBuffer(); + this->hostFunctionData.entry = reinterpret_cast(ptrOffset(hostFunctionBuffer, HostFunctionHelper::entryOffset)); + this->hostFunctionData.userData = reinterpret_cast(ptrOffset(hostFunctionBuffer, HostFunctionHelper::userDataOffset)); + this->hostFunctionData.internalTag = reinterpret_cast(ptrOffset(hostFunctionBuffer, HostFunctionHelper::internalTagOffset)); + this->hostFunctionInitialized = true; +} + +HostFunctionData &CommandStreamReceiver::getHostFunctionData() { + return hostFunctionData; +} + +GraphicsAllocation *CommandStreamReceiver::getHostFunctionDataAllocation() { + return hostFunctionDataAllocation; +} + IndirectHeap &CommandStreamReceiver::getIndirectHeap(IndirectHeap::Type heapType, size_t minRequiredSize) { DEBUG_BREAK_IF(static_cast(heapType) >= arrayCount(indirectHeap)); @@ -824,8 +865,12 @@ void *CommandStreamReceiver::asyncDebugBreakConfirmation(void *arg) { return nullptr; } +void CommandStreamReceiver::makeResidentHostFunctionAllocation() { + makeResident(*hostFunctionDataAllocation); +} + bool CommandStreamReceiver::initializeTagAllocation() { - this->tagsMultiAllocation = &this->createTagsMultiAllocation(); + this->tagsMultiAllocation = &this->createMultiAllocationInSystemMemoryPool(AllocationType::tagBuffer); auto tagAllocation = tagsMultiAllocation->getGraphicsAllocation(rootDeviceIndex); if (!tagAllocation) { diff --git a/shared/source/command_stream/command_stream_receiver.h b/shared/source/command_stream/command_stream_receiver.h index ab96fdc2fd..9ffc93b4fe 100644 --- a/shared/source/command_stream/command_stream_receiver.h +++ b/shared/source/command_stream/command_stream_receiver.h @@ -6,6 +6,7 @@ */ #pragma once +#include "shared/source/command_stream/host_function.h" #include "shared/source/command_stream/linear_stream.h" #include "shared/source/command_stream/memory_compression_state.h" #include "shared/source/command_stream/preemption_mode.h" @@ -160,8 +161,8 @@ class CommandStreamReceiver : NEO::NonCopyableAndNonMovableClass { MultiGraphicsAllocation *getTagsMultiAllocation() const { return tagsMultiAllocation; } - MultiGraphicsAllocation &createTagsMultiAllocation(); - + MultiGraphicsAllocation &createMultiAllocationInSystemMemoryPool(AllocationType allocationType); + void makeResidentHostFunctionAllocation(); TaskCountType getNextBarrierCount() { return this->barrierCount.fetch_add(1u); } TaskCountType peekBarrierCount() const { return this->barrierCount.load(); } volatile TagAddressType *getTagAddress() const { return tagAddress; } @@ -564,7 +565,13 @@ class CommandStreamReceiver : NEO::NonCopyableAndNonMovableClass { MOCKABLE_VIRTUAL uint32_t getContextGroupId() const; + void ensureHostFunctionDataInitialization(); + HostFunctionData &getHostFunctionData(); + GraphicsAllocation *getHostFunctionDataAllocation(); + protected: + MOCKABLE_VIRTUAL void initializeHostFunctionData(); + virtual CompletionStamp flushTaskHeapless(LinearStream &commandStreamTask, size_t commandStreamTaskStart, const IndirectHeap *dsh, const IndirectHeap *ioh, const IndirectHeap *ssh, TaskCountType taskLevel, DispatchFlags &dispatchFlags, Device &device) = 0; @@ -637,11 +644,13 @@ class CommandStreamReceiver : NEO::NonCopyableAndNonMovableClass { GraphicsAllocation *globalStatelessHeapAllocation = nullptr; MultiGraphicsAllocation *tagsMultiAllocation = nullptr; - + MultiGraphicsAllocation *hostFunctionDataMultiAllocation = nullptr; + GraphicsAllocation *hostFunctionDataAllocation = nullptr; IndirectHeap *indirectHeap[IndirectHeapType::numTypes]; OsContext *osContext = nullptr; CommandStreamReceiver *primaryCsr = nullptr; TaskCountType *completionFenceValuePointer = nullptr; + HostFunctionData hostFunctionData; std::atomic barrierCount{0}; // current taskLevel. Used for determining if a PIPE_CONTROL is needed. @@ -672,7 +681,6 @@ class CommandStreamReceiver : NEO::NonCopyableAndNonMovableClass { uint32_t immWritePostSyncWriteOffset = 0; uint32_t timeStampPostSyncWriteOffset = 0; TaskCountType completionFenceValue = 0; - const uint32_t rootDeviceIndex; const DeviceBitfield deviceBitfield; @@ -697,7 +705,7 @@ class CommandStreamReceiver : NEO::NonCopyableAndNonMovableClass { bool requiresInstructionCacheFlush = false; bool requiresDcFlush = false; bool pushAllocationsForMakeResident = true; - + bool hostFunctionInitialized = false; bool localMemoryEnabled = false; bool pageTableManagerInitialized = false; diff --git a/shared/source/gmm_helper/cache_settings_helper.cpp b/shared/source/gmm_helper/cache_settings_helper.cpp index 81e494b2f4..442bf41af2 100644 --- a/shared/source/gmm_helper/cache_settings_helper.cpp +++ b/shared/source/gmm_helper/cache_settings_helper.cpp @@ -60,7 +60,8 @@ GMM_RESOURCE_USAGE_TYPE_ENUM CacheSettingsHelper::getDefaultUsageTypeWithCaching return GMM_RESOURCE_USAGE_OCL_BUFFER_CSR_UC; } else if (AllocationType::semaphoreBuffer == allocationType) { return GMM_RESOURCE_USAGE_OCL_SYSTEM_MEMORY_BUFFER; - } else if (AllocationType::tagBuffer == allocationType) { + } else if (AllocationType::tagBuffer == allocationType || + AllocationType::hostFunction == allocationType) { return GMM_RESOURCE_USAGE_OCL_BUFFER; } } @@ -96,6 +97,7 @@ GMM_RESOURCE_USAGE_TYPE_ENUM CacheSettingsHelper::getDefaultUsageTypeWithCaching case AllocationType::svmZeroCopy: case AllocationType::tagBuffer: case AllocationType::printfSurface: + case AllocationType::hostFunction: if (debugManager.flags.DisableCachingForStatefulBufferAccess.get()) { return getDefaultUsageTypeWithCachingDisabled(allocationType, productHelper); } diff --git a/shared/source/helpers/app_resource_helper.cpp b/shared/source/helpers/app_resource_helper.cpp index ecb99f1f90..022107821e 100644 --- a/shared/source/helpers/app_resource_helper.cpp +++ b/shared/source/helpers/app_resource_helper.cpp @@ -118,6 +118,8 @@ const char *AppResourceHelper::getResourceTagStr(AllocationType type) { return "ASSRTBUF"; case AllocationType::syncDispatchToken: return "SYNCTOK"; + case AllocationType::hostFunction: + return "HOSTFUNC"; default: return "NOTFOUND"; } diff --git a/shared/source/memory_manager/allocation_type.h b/shared/source/memory_manager/allocation_type.h index 7f98cb2312..0587ce35fd 100644 --- a/shared/source/memory_manager/allocation_type.h +++ b/shared/source/memory_manager/allocation_type.h @@ -59,6 +59,7 @@ enum class AllocationType { deferredTasksList, assertBuffer, syncDispatchToken, + hostFunction, count }; diff --git a/shared/source/memory_manager/memory_manager.cpp b/shared/source/memory_manager/memory_manager.cpp index f13533bdd3..3dd6e7f0c6 100644 --- a/shared/source/memory_manager/memory_manager.cpp +++ b/shared/source/memory_manager/memory_manager.cpp @@ -600,6 +600,7 @@ bool MemoryManager::getAllocationData(AllocationData &allocationData, const Allo case AllocationType::debugContextSaveArea: case AllocationType::debugSbaTrackingBuffer: case AllocationType::swTagBuffer: + case AllocationType::hostFunction: allocationData.flags.useSystemMemory = true; default: break; diff --git a/shared/source/utilities/logger.cpp b/shared/source/utilities/logger.cpp index 845a83a7c4..7d7c97d3ed 100644 --- a/shared/source/utilities/logger.cpp +++ b/shared/source/utilities/logger.cpp @@ -221,6 +221,8 @@ const char *getAllocationTypeString(GraphicsAllocation const *graphicsAllocation return "ASSERT_BUFFER"; case AllocationType::syncDispatchToken: return "SYNC_DISPATCH_TOKEN"; + case AllocationType::hostFunction: + return "HOST_FUNCTION"; default: return "ILLEGAL_VALUE"; } diff --git a/shared/source/xe_hpg_core/xe_lpg/os_agnostic_product_helper_xe_lpg.inl b/shared/source/xe_hpg_core/xe_lpg/os_agnostic_product_helper_xe_lpg.inl index c21a076faa..19a37636c7 100644 --- a/shared/source/xe_hpg_core/xe_lpg/os_agnostic_product_helper_xe_lpg.inl +++ b/shared/source/xe_hpg_core/xe_lpg/os_agnostic_product_helper_xe_lpg.inl @@ -56,6 +56,7 @@ std::optional ProductHelperHw::getPreferr switch (allocationType) { case AllocationType::tagBuffer: case AllocationType::timestampPacketTagBuffer: + case AllocationType::hostFunction: return {}; default: return GfxMemoryAllocationMethod::allocateByKmd; diff --git a/shared/test/common/mocks/mock_command_stream_receiver.h b/shared/test/common/mocks/mock_command_stream_receiver.h index fa1c8f6333..ddcc0d7944 100644 --- a/shared/test/common/mocks/mock_command_stream_receiver.h +++ b/shared/test/common/mocks/mock_command_stream_receiver.h @@ -43,6 +43,8 @@ class MockCommandStreamReceiver : public CommandStreamReceiver { using CommandStreamReceiver::gpuHangCheckPeriod; using CommandStreamReceiver::heaplessStateInitEnabled; using CommandStreamReceiver::heaplessStateInitialized; + using CommandStreamReceiver::hostFunctionDataAllocation; + using CommandStreamReceiver::hostFunctionDataMultiAllocation; using CommandStreamReceiver::immWritePostSyncWriteOffset; using CommandStreamReceiver::internalAllocationStorage; using CommandStreamReceiver::latestFlushedTaskCount; @@ -277,6 +279,11 @@ class MockCommandStreamReceiver : public CommandStreamReceiver { BaseClass::setupContext(osContext); } + void initializeHostFunctionData() override { + initializeHostFunctionDataCalledTimes++; + BaseClass::initializeHostFunctionData(); + } + static constexpr size_t tagSize = 256; static volatile TagAddressType mockTagAddress[tagSize]; std::vector instructionHeapReserveredData; @@ -289,6 +296,7 @@ class MockCommandStreamReceiver : public CommandStreamReceiver { uint32_t downloadAllocationsCalledCount = 0; uint32_t submitDependencyUpdateCalledTimes = 0; uint32_t stopDirectSubmissionCalledTimes = 0; + uint32_t initializeHostFunctionDataCalledTimes = 0; int hostPtrSurfaceCreationMutexLockCount = 0; bool multiOsContextCapable = false; bool memoryCompressionEnabled = false; diff --git a/shared/test/unit_test/aub/aub_helper_tests.cpp b/shared/test/unit_test/aub/aub_helper_tests.cpp index 3ba4b2e760..e28dd74711 100644 --- a/shared/test/unit_test/aub/aub_helper_tests.cpp +++ b/shared/test/unit_test/aub/aub_helper_tests.cpp @@ -119,6 +119,7 @@ TEST(AubHelper, givenAllocationTypeWhenAskingIfOneTimeWritableThenReturnCorrectR case AllocationType::assertBuffer: case AllocationType::tagBuffer: case AllocationType::syncDispatchToken: + case AllocationType::hostFunction: EXPECT_TRUE(isOneTimeWritable); break; default: 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 63072266ad..e381ddd163 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 @@ -6446,3 +6446,75 @@ HWTEST_F(CommandStreamReceiverHwTest, givenVariousCsrModeWhenGettingHardwareMode ultCsr.commandStreamReceiverType = CommandStreamReceiverType::tbxWithAub; EXPECT_FALSE(ultCsr.isHardwareMode()); } + +TEST(CommandStreamReceiverHostFunctionsTest, givenCommandStreamReceiverWhenEnsureHostFunctionDataInitializationCalledThenHostFunctionAllocationIsBeingAllocatedOnlyOnce) { + MockExecutionEnvironment executionEnvironment(defaultHwInfo.get()); + DeviceBitfield devices(0b11); + auto csr = std::make_unique(executionEnvironment, 0, devices); + executionEnvironment.memoryManager.reset(new OsAgnosticMemoryManager(executionEnvironment)); + + EXPECT_EQ(nullptr, csr->getHostFunctionDataAllocation()); + + csr->ensureHostFunctionDataInitialization(); + auto *hostDataAllocation = csr->getHostFunctionDataAllocation(); + EXPECT_NE(nullptr, hostDataAllocation); + EXPECT_EQ(1u, csr->initializeHostFunctionDataCalledTimes); + + csr->ensureHostFunctionDataInitialization(); + EXPECT_EQ(hostDataAllocation, csr->getHostFunctionDataAllocation()); + EXPECT_EQ(1u, csr->initializeHostFunctionDataCalledTimes); + + csr->initializeHostFunctionData(); + EXPECT_EQ(2u, csr->initializeHostFunctionDataCalledTimes); // direct call -> the counter updated but due to an early return allocation didn't change + EXPECT_EQ(hostDataAllocation, csr->getHostFunctionDataAllocation()); + + EXPECT_EQ(AllocationType::hostFunction, hostDataAllocation->getAllocationType()); + + auto expectedHostFunctionAddress = reinterpret_cast(ptrOffset(hostDataAllocation->getUnderlyingBuffer(), HostFunctionHelper::entryOffset)); + EXPECT_EQ(expectedHostFunctionAddress, reinterpret_cast(csr->getHostFunctionData().entry)); + + auto expectedUserDataAddress = reinterpret_cast(ptrOffset(hostDataAllocation->getUnderlyingBuffer(), HostFunctionHelper::userDataOffset)); + EXPECT_EQ(expectedUserDataAddress, reinterpret_cast(csr->getHostFunctionData().userData)); + + auto expectedInternalTagAddress = reinterpret_cast(ptrOffset(hostDataAllocation->getUnderlyingBuffer(), HostFunctionHelper::internalTagOffset)); + EXPECT_EQ(expectedInternalTagAddress, reinterpret_cast(csr->getHostFunctionData().internalTag)); +} + +TEST(CommandStreamReceiverHostFunctionsTest, givenDestructedCommandStreamReceiverWhenEnsureHostFunctionDataInitializationCalledThenHostFunctionAllocationsDeallocated) { + MockExecutionEnvironment executionEnvironment(defaultHwInfo.get()); + DeviceBitfield devices(0b11); + + auto csr = std::make_unique(executionEnvironment, 0, devices); + executionEnvironment.memoryManager.reset(new OsAgnosticMemoryManager(executionEnvironment)); + + EXPECT_EQ(nullptr, csr->getHostFunctionDataAllocation()); + + csr->ensureHostFunctionDataInitialization(); + EXPECT_NE(nullptr, csr->hostFunctionDataAllocation); + EXPECT_NE(nullptr, csr->hostFunctionDataMultiAllocation); + csr->cleanupResources(); + + EXPECT_EQ(nullptr, csr->hostFunctionDataAllocation); + EXPECT_EQ(nullptr, csr->hostFunctionDataMultiAllocation); +} + +TEST(CommandStreamReceiverHostFunctionsTest, givenCommandStreamReceiverWithHostFunctionDataWhenMakeResidentHostFunctionAllocationIsCalledThenHostAllocationIsResident) { + + std::unique_ptr device(MockDevice::createWithNewExecutionEnvironment(defaultHwInfo.get(), 0u)); + auto &csr = *device->commandStreamReceivers[0]; + ASSERT_EQ(nullptr, csr.getHostFunctionDataAllocation()); + csr.ensureHostFunctionDataInitialization(); + auto *hostDataAllocation = csr.getHostFunctionDataAllocation(); + ASSERT_NE(nullptr, hostDataAllocation); + + auto csrContextId = csr.getOsContext().getContextId(); + EXPECT_FALSE(hostDataAllocation->isResident(csrContextId)); + + csr.makeResidentHostFunctionAllocation(); + EXPECT_TRUE(hostDataAllocation->isResident(csrContextId)); + + csr.makeNonResident(*hostDataAllocation); + EXPECT_FALSE(hostDataAllocation->isResident(csrContextId)); + + EXPECT_EQ(1u, csr.getEvictionAllocations().size()); +} diff --git a/shared/test/unit_test/command_stream/tbx_command_stream_tests.cpp b/shared/test/unit_test/command_stream/tbx_command_stream_tests.cpp index 33ebbfe406..252ff56aa2 100644 --- a/shared/test/unit_test/command_stream/tbx_command_stream_tests.cpp +++ b/shared/test/unit_test/command_stream/tbx_command_stream_tests.cpp @@ -1555,6 +1555,7 @@ static constexpr std::array onceWritableAllocTypesForTbx{ AllocationType::tagBuffer, AllocationType::syncDispatchToken, AllocationType::bufferHostMemory, + AllocationType::hostFunction, }; HWTEST_F(TbxCommandStreamTests, givenAubOneTimeWritableAllocWhenTbxFaultManagerIsAvailableAndAllocIsTbxFaultableThenTbxFaultableTypesShouldReturnTrue) { diff --git a/shared/test/unit_test/gmm_helper/gmm_helper_tests.cpp b/shared/test/unit_test/gmm_helper/gmm_helper_tests.cpp index bf294a08ee..b210116f09 100644 --- a/shared/test/unit_test/gmm_helper/gmm_helper_tests.cpp +++ b/shared/test/unit_test/gmm_helper/gmm_helper_tests.cpp @@ -722,6 +722,7 @@ TEST(GmmTest, givenAllocationTypeWhenGettingUsageTypeThenReturnCorrectValue) { case AllocationType::svmZeroCopy: case AllocationType::tagBuffer: case AllocationType::printfSurface: + case AllocationType::hostFunction: expectedUsage = forceUncached ? uncachedGmmUsageType : GMM_RESOURCE_USAGE_OCL_SYSTEM_MEMORY_BUFFER; break; default: @@ -831,6 +832,7 @@ TEST(GmmTest, givenAllocationTypeAndMitigatedDcFlushWhenGettingUsageTypeThenRetu case AllocationType::svmZeroCopy: case AllocationType::tagBuffer: case AllocationType::printfSurface: + case AllocationType::hostFunction: expectedUsage = GMM_RESOURCE_USAGE_OCL_SYSTEM_MEMORY_BUFFER; break; default: diff --git a/shared/test/unit_test/helpers/app_resource_tests.cpp b/shared/test/unit_test/helpers/app_resource_tests.cpp index 4a20118d36..78ecbb3746 100644 --- a/shared/test/unit_test/helpers/app_resource_tests.cpp +++ b/shared/test/unit_test/helpers/app_resource_tests.cpp @@ -102,7 +102,8 @@ AllocationTypeTagTestCase allocationTypeTagValues[static_cast(AllocationTyp {AllocationType::swTagBuffer, "SWTAGBF"}, {AllocationType::deferredTasksList, "TSKLIST"}, {AllocationType::assertBuffer, "ASSRTBUF"}, - {AllocationType::syncDispatchToken, "SYNCTOK"}}; + {AllocationType::syncDispatchToken, "SYNCTOK"}, + {AllocationType::hostFunction, "HOSTFUNC"}}; class AllocationTypeTagString : public ::testing::TestWithParam {}; TEST_P(AllocationTypeTagString, givenGraphicsAllocationTypeWhenCopyTagToStorageInfoThenCorrectTagIsReturned) { diff --git a/shared/test/unit_test/memory_manager/memory_manager_allocate_in_preferred_pool_tests.cpp b/shared/test/unit_test/memory_manager/memory_manager_allocate_in_preferred_pool_tests.cpp index 12d37b38ce..81a1d8d680 100644 --- a/shared/test/unit_test/memory_manager/memory_manager_allocate_in_preferred_pool_tests.cpp +++ b/shared/test/unit_test/memory_manager/memory_manager_allocate_in_preferred_pool_tests.cpp @@ -532,6 +532,14 @@ TEST(MemoryManagerTest, givenTagBufferTypeWhenGetAllocationDataIsCalledThenSyste EXPECT_TRUE(allocData.flags.useSystemMemory); } +TEST(MemoryManagerTest, givenHostFunctionTypeWhenGetAllocationDataIsCalledThenSystemMemoryIsRequested) { + AllocationData allocData; + MockMemoryManager mockMemoryManager; + AllocationProperties properties{mockRootDeviceIndex, 1, AllocationType::hostFunction, mockDeviceBitfield}; + mockMemoryManager.getAllocationData(allocData, properties, nullptr, mockMemoryManager.createStorageInfoFromProperties(properties)); + EXPECT_TRUE(allocData.flags.useSystemMemory); +} + TEST(MemoryManagerTest, givenGlobalFenceTypeWhenGetAllocationDataIsCalledThenSystemMemoryIsRequested) { AllocationData allocData; MockMemoryManager mockMemoryManager; diff --git a/shared/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp b/shared/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp index 3a8014d410..a8e78b3473 100644 --- a/shared/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp +++ b/shared/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp @@ -601,7 +601,8 @@ TEST_F(WddmMemoryManagerTests, givenTypeWhenCallIsStatelessAccessRequiredThenPro AllocationType::swTagBuffer, AllocationType::deferredTasksList, AllocationType::assertBuffer, - AllocationType::syncDispatchToken}) { + AllocationType::syncDispatchToken, + AllocationType::hostFunction}) { EXPECT_FALSE(wddmMemoryManager->isStatelessAccessRequired(type)); } } diff --git a/shared/test/unit_test/utilities/logger_tests.cpp b/shared/test/unit_test/utilities/logger_tests.cpp index 6fe3d991dc..bf5348bc66 100644 --- a/shared/test/unit_test/utilities/logger_tests.cpp +++ b/shared/test/unit_test/utilities/logger_tests.cpp @@ -447,7 +447,7 @@ TEST(AllocationTypeLogging, givenGraphicsAllocationTypeWhenConvertingToStringThe DebugVariables flags; FullyEnabledFileLogger fileLogger(testFile, flags); - std::array, 40> allocationTypeValues = { + std::array, 41> allocationTypeValues = { {{AllocationType::buffer, "BUFFER"}, {AllocationType::bufferHostMemory, "BUFFER_HOST_MEMORY"}, {AllocationType::commandBuffer, "COMMAND_BUFFER"}, @@ -487,7 +487,8 @@ TEST(AllocationTypeLogging, givenGraphicsAllocationTypeWhenConvertingToStringThe {AllocationType::debugContextSaveArea, "DEBUG_CONTEXT_SAVE_AREA"}, {AllocationType::debugSbaTrackingBuffer, "DEBUG_SBA_TRACKING_BUFFER"}, {AllocationType::debugModuleArea, "DEBUG_MODULE_AREA"}, - {AllocationType::swTagBuffer, "SW_TAG_BUFFER"}}}; + {AllocationType::swTagBuffer, "SW_TAG_BUFFER"}, + {AllocationType::hostFunction, "HOST_FUNCTION"}}}; for (const auto &[type, str] : allocationTypeValues) { GraphicsAllocation graphicsAllocation(0, 1u /*num gmms*/, type, nullptr, 0, 0, MemoryPool::memoryNull, MemoryManager::maxOsContextCount, 0llu); diff --git a/shared/test/unit_test/xe2_hpg_core/lnl/product_helper_tests_lnl.cpp b/shared/test/unit_test/xe2_hpg_core/lnl/product_helper_tests_lnl.cpp index ff4055a860..7e36eb25ea 100644 --- a/shared/test/unit_test/xe2_hpg_core/lnl/product_helper_tests_lnl.cpp +++ b/shared/test/unit_test/xe2_hpg_core/lnl/product_helper_tests_lnl.cpp @@ -102,7 +102,8 @@ LNLTEST_F(LnlProductHelper, whenCheckPreferredAllocationMethodThenAllocateByKmdI auto allocationType = static_cast(i); auto preferredAllocationMethod = productHelper->getPreferredAllocationMethod(allocationType); if (allocationType == AllocationType::tagBuffer || - allocationType == AllocationType::timestampPacketTagBuffer) { + allocationType == AllocationType::timestampPacketTagBuffer || + allocationType == AllocationType::hostFunction) { EXPECT_TRUE(preferredAllocationMethod.has_value()); EXPECT_EQ(GfxMemoryAllocationMethod::allocateByKmd, preferredAllocationMethod.value()); } diff --git a/shared/test/unit_test/xe_hpg_core/os_agnostic_product_helper_xe_lpg_tests.cpp b/shared/test/unit_test/xe_hpg_core/os_agnostic_product_helper_xe_lpg_tests.cpp index 370efbdd8c..62023caf79 100644 --- a/shared/test/unit_test/xe_hpg_core/os_agnostic_product_helper_xe_lpg_tests.cpp +++ b/shared/test/unit_test/xe_hpg_core/os_agnostic_product_helper_xe_lpg_tests.cpp @@ -336,7 +336,8 @@ HWTEST2_F(XeLpgProductHelperTests, whenCheckPreferredAllocationMethodThenAllocat auto allocationType = static_cast(i); auto preferredAllocationMethod = productHelper->getPreferredAllocationMethod(allocationType); if (allocationType == AllocationType::tagBuffer || - allocationType == AllocationType::timestampPacketTagBuffer) { + allocationType == AllocationType::timestampPacketTagBuffer || + allocationType == AllocationType::hostFunction) { EXPECT_FALSE(preferredAllocationMethod.has_value()); } else { EXPECT_TRUE(preferredAllocationMethod.has_value());