mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Check if KMD migration is supported
Related-To: NEO-3312 Signed-off-by: Lukasz Jobczyk <lukasz.jobczyk@intel.com>
This commit is contained in:

committed by
Compute-Runtime-Automation

parent
320a404a91
commit
049e77b235
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2017-2020 Intel Corporation
|
* Copyright (C) 2017-2021 Intel Corporation
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
@ -72,6 +72,7 @@ class DrmMockTime : public DrmMockSuccess {
|
|||||||
|
|
||||||
class DrmMockCustom : public Drm {
|
class DrmMockCustom : public Drm {
|
||||||
public:
|
public:
|
||||||
|
using Drm::bindAvailable;
|
||||||
using Drm::memoryInfo;
|
using Drm::memoryInfo;
|
||||||
|
|
||||||
struct IoctlResExt {
|
struct IoctlResExt {
|
||||||
|
@ -80,6 +80,53 @@ TEST_F(DrmMemoryManagerTest, givenDebugVariableWhenCreatingDrmMemoryManagerThenS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenCheckForKmdMigrationThenCorrectValueIsReturned) {
|
||||||
|
DebugManagerStateRestore restorer;
|
||||||
|
auto drm = static_cast<DrmMockCustom *>(executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface->get()->getDrm());
|
||||||
|
|
||||||
|
{
|
||||||
|
DebugManager.flags.UseKmdMigration.set(-1);
|
||||||
|
|
||||||
|
drm->bindAvailable = false;
|
||||||
|
auto retVal = memoryManager->isKmdMigrationAvailable(rootDeviceIndex);
|
||||||
|
|
||||||
|
EXPECT_FALSE(retVal);
|
||||||
|
|
||||||
|
drm->bindAvailable = true;
|
||||||
|
retVal = memoryManager->isKmdMigrationAvailable(rootDeviceIndex);
|
||||||
|
|
||||||
|
auto hwInfo = executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->getHardwareInfo();
|
||||||
|
auto &hwHelper = NEO::HwHelper::get(hwInfo->platform.eRenderCoreFamily);
|
||||||
|
EXPECT_EQ(hwHelper.isKmdMigrationSupported(*hwInfo), retVal);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
DebugManager.flags.UseKmdMigration.set(1);
|
||||||
|
|
||||||
|
drm->bindAvailable = false;
|
||||||
|
auto retVal = memoryManager->isKmdMigrationAvailable(rootDeviceIndex);
|
||||||
|
|
||||||
|
EXPECT_TRUE(retVal);
|
||||||
|
|
||||||
|
drm->bindAvailable = true;
|
||||||
|
retVal = memoryManager->isKmdMigrationAvailable(rootDeviceIndex);
|
||||||
|
|
||||||
|
EXPECT_TRUE(retVal);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
DebugManager.flags.UseKmdMigration.set(0);
|
||||||
|
|
||||||
|
drm->bindAvailable = false;
|
||||||
|
auto retVal = memoryManager->isKmdMigrationAvailable(rootDeviceIndex);
|
||||||
|
|
||||||
|
EXPECT_FALSE(retVal);
|
||||||
|
|
||||||
|
drm->bindAvailable = true;
|
||||||
|
retVal = memoryManager->isKmdMigrationAvailable(rootDeviceIndex);
|
||||||
|
|
||||||
|
EXPECT_FALSE(retVal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(DrmMemoryManagerTest, GivenGraphicsAllocationWhenAddAndRemoveAllocationToHostPtrManagerThenfragmentHasCorrectValues) {
|
TEST_F(DrmMemoryManagerTest, GivenGraphicsAllocationWhenAddAndRemoveAllocationToHostPtrManagerThenfragmentHasCorrectValues) {
|
||||||
void *cpuPtr = (void *)0x30000;
|
void *cpuPtr = (void *)0x30000;
|
||||||
size_t size = 0x1000;
|
size_t size = 0x1000;
|
||||||
|
@ -29,7 +29,7 @@ AUBDumpAllocsOnEnqueueSVMMemcpyOnly = 0
|
|||||||
AUBDumpForceAllToLocalMemory = 0
|
AUBDumpForceAllToLocalMemory = 0
|
||||||
ForceDeviceId = unk
|
ForceDeviceId = unk
|
||||||
ForceL1Caching = -1
|
ForceL1Caching = -1
|
||||||
UseKmdMigration = -1
|
UseKmdMigration = 0
|
||||||
SchedulerSimulationReturnInstance = 0
|
SchedulerSimulationReturnInstance = 0
|
||||||
SchedulerGWS = 0
|
SchedulerGWS = 0
|
||||||
EnableExperimentalCommandBuffer = 0
|
EnableExperimentalCommandBuffer = 0
|
||||||
|
@ -214,7 +214,7 @@ DECLARE_DEBUG_VARIABLE(int32_t, OverrideThreadArbitrationPolicy, -1, "-1 (dont o
|
|||||||
DECLARE_DEBUG_VARIABLE(int32_t, OverrideAubDeviceId, -1, "-1 dont override, any other: use this value for AUB generation device id")
|
DECLARE_DEBUG_VARIABLE(int32_t, OverrideAubDeviceId, -1, "-1 dont override, any other: use this value for AUB generation device id")
|
||||||
DECLARE_DEBUG_VARIABLE(int32_t, EnableTimestampPacket, -1, "-1: default, 0: disable, 1:enable. Write Timestamp Packet for each set of gpu walkers")
|
DECLARE_DEBUG_VARIABLE(int32_t, EnableTimestampPacket, -1, "-1: default, 0: disable, 1:enable. Write Timestamp Packet for each set of gpu walkers")
|
||||||
DECLARE_DEBUG_VARIABLE(int32_t, AllocateSharedAllocationsWithCpuAndGpuStorage, -1, "When enabled driver creates cpu & gpu storage for shared unified memory allocations. (-1 - devices default mode, 0 - disable, 1 - enable)")
|
DECLARE_DEBUG_VARIABLE(int32_t, AllocateSharedAllocationsWithCpuAndGpuStorage, -1, "When enabled driver creates cpu & gpu storage for shared unified memory allocations. (-1 - devices default mode, 0 - disable, 1 - enable)")
|
||||||
DECLARE_DEBUG_VARIABLE(int32_t, UseKmdMigration, -1, "-1: devices default mode (currently - disabled), 0: disable - pagefault handling by UMD using handler for SIGSEGV, 1: enable - pagefault handling by KMD, GEM objects migrated by KMD upon access)")
|
DECLARE_DEBUG_VARIABLE(int32_t, UseKmdMigration, 0, "-1: devices default mode, 0: disable - pagefault handling by UMD using handler for SIGSEGV, 1: enable - pagefault handling by KMD, GEM objects migrated by KMD upon access)")
|
||||||
DECLARE_DEBUG_VARIABLE(int32_t, ForceSemaphoreDelayBetweenWaits, -1, "Specifies the minimum number of microseconds allowed for command streamer to wait before re-fetching the data. 0 - poll interval will be equal to the memory latency of the read completion")
|
DECLARE_DEBUG_VARIABLE(int32_t, ForceSemaphoreDelayBetweenWaits, -1, "Specifies the minimum number of microseconds allowed for command streamer to wait before re-fetching the data. 0 - poll interval will be equal to the memory latency of the read completion")
|
||||||
DECLARE_DEBUG_VARIABLE(int32_t, ForceLocalMemoryAccessMode, -1, "-1: don't override, 0: default rules apply, 1: CPU can access local memory, 3: CPU never accesses local memory")
|
DECLARE_DEBUG_VARIABLE(int32_t, ForceLocalMemoryAccessMode, -1, "-1: don't override, 0: default rules apply, 1: CPU can access local memory, 3: CPU never accesses local memory")
|
||||||
DECLARE_DEBUG_VARIABLE(int32_t, ForceUserptrAlignment, -1, "-1: no force (4kb), >0: n kb alignment")
|
DECLARE_DEBUG_VARIABLE(int32_t, ForceUserptrAlignment, -1, "-1: no force (4kb), >0: n kb alignment")
|
||||||
|
@ -129,6 +129,7 @@ class HwHelper {
|
|||||||
virtual bool isSipWANeeded(const HardwareInfo &hwInfo) const = 0;
|
virtual bool isSipWANeeded(const HardwareInfo &hwInfo) const = 0;
|
||||||
virtual bool additionalKernelExecInfoSupported(const HardwareInfo &hwInfo) const = 0;
|
virtual bool additionalKernelExecInfoSupported(const HardwareInfo &hwInfo) const = 0;
|
||||||
virtual bool isCpuImageTransferPreferred(const HardwareInfo &hwInfo) const = 0;
|
virtual bool isCpuImageTransferPreferred(const HardwareInfo &hwInfo) const = 0;
|
||||||
|
virtual bool isKmdMigrationSupported(const HardwareInfo &hwInfo) const = 0;
|
||||||
|
|
||||||
static uint32_t getSubDevicesCount(const HardwareInfo *pHwInfo);
|
static uint32_t getSubDevicesCount(const HardwareInfo *pHwInfo);
|
||||||
static uint32_t getEnginesCount(const HardwareInfo &hwInfo);
|
static uint32_t getEnginesCount(const HardwareInfo &hwInfo);
|
||||||
@ -318,6 +319,8 @@ class HwHelperHw : public HwHelper {
|
|||||||
|
|
||||||
bool isMediaBlockIOSupported(const HardwareInfo &hwInfo) const override;
|
bool isMediaBlockIOSupported(const HardwareInfo &hwInfo) const override;
|
||||||
|
|
||||||
|
bool isKmdMigrationSupported(const HardwareInfo &hwInfo) const override;
|
||||||
|
|
||||||
bool isCopyOnlyEngineType(EngineGroupType type) const override;
|
bool isCopyOnlyEngineType(EngineGroupType type) const override;
|
||||||
|
|
||||||
void adjustAddressWidthForCanonize(uint32_t &addressWidth) const override;
|
void adjustAddressWidthForCanonize(uint32_t &addressWidth) const override;
|
||||||
|
@ -515,6 +515,11 @@ bool HwHelperHw<GfxFamily>::isMediaBlockIOSupported(const HardwareInfo &hwInfo)
|
|||||||
return hwInfo.capabilityTable.supportsImages;
|
return hwInfo.capabilityTable.supportsImages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename GfxFamily>
|
||||||
|
bool HwHelperHw<GfxFamily>::isKmdMigrationSupported(const HardwareInfo &hwInfo) const {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
template <typename GfxFamily>
|
template <typename GfxFamily>
|
||||||
bool HwHelperHw<GfxFamily>::isCopyOnlyEngineType(EngineGroupType type) const {
|
bool HwHelperHw<GfxFamily>::isCopyOnlyEngineType(EngineGroupType type) const {
|
||||||
return NEO::EngineGroupType::Copy == type;
|
return NEO::EngineGroupType::Copy == type;
|
||||||
|
@ -145,6 +145,8 @@ class MemoryManager {
|
|||||||
bool isLocalMemorySupported(uint32_t rootDeviceIndex) const;
|
bool isLocalMemorySupported(uint32_t rootDeviceIndex) const;
|
||||||
virtual bool isMemoryBudgetExhausted() const;
|
virtual bool isMemoryBudgetExhausted() const;
|
||||||
|
|
||||||
|
virtual bool isKmdMigrationAvailable(uint32_t rootDeviceIndex) { return false; }
|
||||||
|
|
||||||
virtual AlignedMallocRestrictions *getAlignedMallocRestrictions() {
|
virtual AlignedMallocRestrictions *getAlignedMallocRestrictions() {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -220,13 +220,9 @@ void *SVMAllocsManager::createSharedUnifiedMemoryAllocation(size_t size,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (supportDualStorageSharedMemory) {
|
if (supportDualStorageSharedMemory) {
|
||||||
bool useKmdMigration = false;
|
bool useKmdMigration = memoryManager->isKmdMigrationAvailable(*memoryProperties.rootDeviceIndices.begin());
|
||||||
|
|
||||||
if (DebugManager.flags.UseKmdMigration.get() != -1) {
|
|
||||||
useKmdMigration = DebugManager.flags.UseKmdMigration.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
void *unifiedMemoryPointer = nullptr;
|
void *unifiedMemoryPointer = nullptr;
|
||||||
|
|
||||||
if (useKmdMigration) {
|
if (useKmdMigration) {
|
||||||
unifiedMemoryPointer = createUnifiedKmdMigratedAllocation(size, {}, memoryProperties);
|
unifiedMemoryPointer = createUnifiedKmdMigratedAllocation(size, {}, memoryProperties);
|
||||||
if (!unifiedMemoryPointer) {
|
if (!unifiedMemoryPointer) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2017-2020 Intel Corporation
|
* Copyright (C) 2017-2021 Intel Corporation
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
@ -175,6 +175,20 @@ void DrmMemoryManager::releaseGpuRange(void *address, size_t unmapSize, uint32_t
|
|||||||
gfxPartition->freeGpuAddressRange(graphicsAddress, unmapSize);
|
gfxPartition->freeGpuAddressRange(graphicsAddress, unmapSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DrmMemoryManager::isKmdMigrationAvailable(uint32_t rootDeviceIndex) {
|
||||||
|
auto hwInfo = executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->getHardwareInfo();
|
||||||
|
auto &hwHelper = NEO::HwHelper::get(hwInfo->platform.eRenderCoreFamily);
|
||||||
|
|
||||||
|
auto useKmdMigration = hwHelper.isKmdMigrationSupported(*hwInfo) &&
|
||||||
|
this->getDrm(rootDeviceIndex).isVmBindAvailable();
|
||||||
|
|
||||||
|
if (DebugManager.flags.UseKmdMigration.get() != -1) {
|
||||||
|
useKmdMigration = DebugManager.flags.UseKmdMigration.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
return useKmdMigration;
|
||||||
|
}
|
||||||
|
|
||||||
NEO::BufferObject *DrmMemoryManager::allocUserptr(uintptr_t address, size_t size, uint64_t flags, uint32_t rootDeviceIndex) {
|
NEO::BufferObject *DrmMemoryManager::allocUserptr(uintptr_t address, size_t size, uint64_t flags, uint32_t rootDeviceIndex) {
|
||||||
drm_i915_gem_userptr userptr = {};
|
drm_i915_gem_userptr userptr = {};
|
||||||
userptr.user_ptr = address;
|
userptr.user_ptr = address;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2017-2020 Intel Corporation
|
* Copyright (C) 2017-2021 Intel Corporation
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
@ -62,6 +62,8 @@ class DrmMemoryManager : public MemoryManager {
|
|||||||
void freeGpuAddress(AddressRange addressRange, uint32_t rootDeviceIndex) override;
|
void freeGpuAddress(AddressRange addressRange, uint32_t rootDeviceIndex) override;
|
||||||
MOCKABLE_VIRTUAL BufferObject *createBufferObjectInMemoryRegion(Drm *drm, uint64_t gpuAddress, size_t size, uint32_t memoryBanks, size_t maxOsContextCount);
|
MOCKABLE_VIRTUAL BufferObject *createBufferObjectInMemoryRegion(Drm *drm, uint64_t gpuAddress, size_t size, uint32_t memoryBanks, size_t maxOsContextCount);
|
||||||
|
|
||||||
|
bool isKmdMigrationAvailable(uint32_t rootDeviceIndex) override;
|
||||||
|
|
||||||
std::unique_lock<std::mutex> acquireAllocLock();
|
std::unique_lock<std::mutex> acquireAllocLock();
|
||||||
std::vector<GraphicsAllocation *> &getSysMemAllocs();
|
std::vector<GraphicsAllocation *> &getSysMemAllocs();
|
||||||
std::vector<GraphicsAllocation *> &getLocalMemAllocs(uint32_t rootDeviceIndex);
|
std::vector<GraphicsAllocation *> &getLocalMemAllocs(uint32_t rootDeviceIndex);
|
||||||
|
Reference in New Issue
Block a user