fix: Add platform support for reservation on svm heap

Related-To: GSD-10816

Signed-off-by: Aravind Gopalakrishnan <aravind.gopalakrishnan@intel.com>
This commit is contained in:
Aravind Gopalakrishnan 2025-04-01 23:47:02 +00:00 committed by Compute-Runtime-Automation
parent a48d66ad75
commit 3a7d7e022c
9 changed files with 39 additions and 7 deletions

View File

@ -1067,6 +1067,13 @@ ze_result_t ContextImp::reserveVirtualMem(const void *pStart,
if (castToUint64(pStart) <= maxCpuVa) {
reserveOnSvmHeap = true;
}
bool platformSupportSvmHeapReservation = true;
for (auto &device : this->driverHandle->devices) {
auto &productHelper = device->getNEODevice()->getProductHelper();
platformSupportSvmHeapReservation &= productHelper.isSvmHeapReservationSupported();
}
reserveOnSvmHeap &= platformSupportSvmHeapReservation;
reserveOnSvmHeap &= NEO::debugManager.flags.EnableReservingInSvmRange.get();
NEO::AddressRange addressRange{};

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2024 Intel Corporation
* Copyright (C) 2020-2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -1559,7 +1559,7 @@ class ReserveMemoryManagerMock : public NEO::MemoryManager {
std::unique_ptr<NEO::GraphicsAllocation> mockAllocation;
};
TEST_F(ContextTest, whenCallingVirtualMemReserveWithPStartInSvmRangeWithSuccessfulAllocationThenSuccessReturned) {
HWTEST2_F(ContextTest, whenCallingVirtualMemReserveWithPStartInSvmRangeWithSuccessfulAllocationThenSuccessReturned, IsNotMTL) {
ze_context_handle_t hContext{};
ze_context_desc_t desc = {ZE_STRUCTURE_TYPE_CONTEXT_DESC, nullptr, 0};
@ -1763,7 +1763,7 @@ TEST_F(ContextTest, whenUsingOffsetsIntoReservedVirtualMemoryWithMultiplePhysica
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
}
TEST_F(ContextTest, whenCallingVirtualMemoryReservationWhenOutOfMemoryThenOutOfMemoryReturned) {
HWTEST2_F(ContextTest, whenCallingVirtualMemoryReservationWhenOutOfMemoryThenOutOfMemoryReturned, IsNotMTL) {
ze_context_handle_t hContext;
ze_context_desc_t desc = {ZE_STRUCTURE_TYPE_CONTEXT_DESC, nullptr, 0};
@ -1955,7 +1955,7 @@ class MockCpuInfoOverrideVirtualAddressSize {
uint32_t virtualAddressSizeSave = 0;
};
TEST_F(ContextTest, Given32BitCpuAddressWidthWhenCallingVirtualMemoryReservationCorrectAllocationMethodIsSelected) {
HWTEST2_F(ContextTest, Given32BitCpuAddressWidthWhenCallingVirtualMemoryReservationCorrectAllocationMethodIsSelected, IsNotMTL) {
MockCpuInfoOverrideVirtualAddressSize overrideCpuInfo(32);
ze_context_handle_t hContext;
@ -2000,7 +2000,7 @@ TEST_F(ContextTest, Given32BitCpuAddressWidthWhenCallingVirtualMemoryReservation
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
}
TEST_F(ContextTest, Given48BitCpuAddressWidthWhenCallingVirtualMemoryReservationCorrectAllocationMethodIsSelected) {
HWTEST2_F(ContextTest, Given48BitCpuAddressWidthWhenCallingVirtualMemoryReservationCorrectAllocationMethodIsSelected, IsNotMTL) {
MockCpuInfoOverrideVirtualAddressSize overrideCpuInfo(48);
ze_context_handle_t hContext;
@ -2044,7 +2044,7 @@ TEST_F(ContextTest, Given48BitCpuAddressWidthWhenCallingVirtualMemoryReservation
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
}
TEST_F(ContextTest, Given57BitCpuAddressWidthWhenCallingVirtualMemoryReservationCorrectAllocationMethodIsSelected) {
HWTEST2_F(ContextTest, Given57BitCpuAddressWidthWhenCallingVirtualMemoryReservationCorrectAllocationMethodIsSelected, IsNotMTL) {
MockCpuInfoOverrideVirtualAddressSize overrideCpuInfo(57);
ze_context_handle_t hContext;

View File

@ -268,6 +268,7 @@ class ProductHelper {
virtual bool isL3FlushAfterPostSyncRequired(bool heaplessEnabled) const = 0;
virtual void overrideDirectSubmissionTimeouts(std::chrono::microseconds &timeout, std::chrono::microseconds &maxTimeout) const = 0;
virtual bool isMisalignedUserPtr2WayCoherent() const = 0;
virtual bool isSvmHeapReservationSupported() const = 0;
virtual ~ProductHelper() = default;

View File

@ -1034,6 +1034,11 @@ bool ProductHelperHw<gfxProduct>::isMisalignedUserPtr2WayCoherent() const {
return false;
}
template <PRODUCT_FAMILY gfxProduct>
bool ProductHelperHw<gfxProduct>::isSvmHeapReservationSupported() const {
return true;
}
template <PRODUCT_FAMILY gfxProduct>
bool ProductHelperHw<gfxProduct>::isTimestampWaitSupportedForQueues(bool heaplessEnabled) const {
return false;

View File

@ -205,6 +205,7 @@ class ProductHelperHw : public ProductHelper {
bool isL3FlushAfterPostSyncRequired(bool heaplessEnabled) const override;
void overrideDirectSubmissionTimeouts(std::chrono::microseconds &timeout, std::chrono::microseconds &maxTimeout) const override;
bool isMisalignedUserPtr2WayCoherent() const override;
bool isSvmHeapReservationSupported() const override;
~ProductHelperHw() override = default;

View File

@ -14,4 +14,13 @@ constexpr static auto gfxProduct = IGFX_METEORLAKE;
#include "shared/source/xe_hpg_core/xe_lpg/os_agnostic_product_helper_xe_lpg.inl"
#include "shared/source/xe_hpg_core/xe_lpg/windows/product_helper_xe_lpg_windows.inl"
template class NEO::ProductHelperHw<gfxProduct>;
namespace NEO {
template <>
bool ProductHelperHw<gfxProduct>::isSvmHeapReservationSupported() const {
return false;
}
template class ProductHelperHw<gfxProduct>;
} // namespace NEO

View File

@ -79,6 +79,7 @@ using IsAtLeastPVC = IsAtLeastProduct<IGFX_PVC>;
using IsAtMostPVC = IsAtMostProduct<IGFX_PVC>;
using IsNotPVC = IsNotWithinProducts<IGFX_PVC, IGFX_PVC>;
using IsNotDG2 = IsNotWithinProducts<IGFX_DG2, IGFX_DG2>;
using IsNotMTL = IsNotWithinProducts<IGFX_METEORLAKE, IGFX_METEORLAKE>;
using IsNotPvcOrDg2 = IsNotWithinProducts<IGFX_DG2, IGFX_PVC>;
using IsAtMostArl = IsAtMostProduct<IGFX_ARROWLAKE>;

View File

@ -475,6 +475,10 @@ HWTEST2_F(ProductHelperTest, givenProductHelperWhenAskedIfDisableScratchPagesIsS
EXPECT_TRUE(productHelper->isDisableScratchPagesRequiredForDebugger());
}
HWTEST2_F(ProductHelperTest, givenProductHelperWhenAskedIfPlatformSupportsSvmHeapReservationThenReturnTrue, IsXeHpcCore) {
EXPECT_TRUE(productHelper->isSvmHeapReservationSupported());
}
HWTEST_F(ProductHelperTest, givenProductHelperWhenCheckBlitEnqueuePreferredThenReturnTrue) {
EXPECT_TRUE(productHelper->blitEnqueuePreferred(false));
}

View File

@ -93,4 +93,8 @@ HWTEST_F(ProductHelperTestWindows, givenFtrIaCoherencyFlagWhenConfiguringHwInfoT
productHelper->configureHwInfoWddm(&initialHwInfo, &outHwInfo, *rootDeviceEnvironment.get());
EXPECT_EQ(initialCoherencyStatus, outHwInfo.capabilityTable.ftrSupportsCoherency);
}
HWTEST2_F(ProductHelperTestWindows, givenProductHelperWhenAskedIfPlatformSupportsSvmHeapReservationThenReturnFalseForMTL, IsMTL) {
EXPECT_FALSE(productHelper->isSvmHeapReservationSupported());
}
} // namespace NEO