Create kmd migrated allocation with initial placement
Implements ZE_HOST_MEM_ALLOC_FLAG_BIAS_INITIAL_PLACEMENT for zeMemAllocShared with KMD migrated allocation. Signed-off-by: Milczarek, Slawomir <slawomir.milczarek@intel.com>
This commit is contained in:
parent
fc71a59504
commit
2be98a1e62
|
@ -1,11 +1,12 @@
|
|||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/helpers/memory_properties_helpers.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/mocks/mock_device.h"
|
||||
#include "shared/test/common/mocks/mock_graphics_allocation.h"
|
||||
#include "shared/test/common/mocks/ult_device_factory.h"
|
||||
|
@ -452,4 +453,48 @@ TEST_F(MemoryPropertiesHelperTests, WhenAdjustingDeviceBitfieldThenCorrectBitfie
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(MemoryPropertiesHelperTests, WhenCallingGetInitialPlacementThenCorrectValueIsReturned) {
|
||||
MemoryProperties memoryProperties{};
|
||||
EXPECT_EQ(GraphicsAllocation::UsmInitialPlacement::CPU, MemoryPropertiesHelper::getUSMInitialPlacement(memoryProperties));
|
||||
|
||||
memoryProperties.allocFlags.usmInitialPlacementCpu = false;
|
||||
memoryProperties.allocFlags.usmInitialPlacementGpu = false;
|
||||
EXPECT_EQ(GraphicsAllocation::UsmInitialPlacement::CPU, MemoryPropertiesHelper::getUSMInitialPlacement(memoryProperties));
|
||||
|
||||
memoryProperties.allocFlags.usmInitialPlacementCpu = false;
|
||||
memoryProperties.allocFlags.usmInitialPlacementGpu = true;
|
||||
EXPECT_EQ(GraphicsAllocation::UsmInitialPlacement::GPU, MemoryPropertiesHelper::getUSMInitialPlacement(memoryProperties));
|
||||
|
||||
memoryProperties.allocFlags.usmInitialPlacementCpu = true;
|
||||
memoryProperties.allocFlags.usmInitialPlacementGpu = false;
|
||||
EXPECT_EQ(GraphicsAllocation::UsmInitialPlacement::CPU, MemoryPropertiesHelper::getUSMInitialPlacement(memoryProperties));
|
||||
|
||||
memoryProperties.allocFlags.usmInitialPlacementCpu = true;
|
||||
memoryProperties.allocFlags.usmInitialPlacementGpu = true;
|
||||
EXPECT_EQ(GraphicsAllocation::UsmInitialPlacement::CPU, MemoryPropertiesHelper::getUSMInitialPlacement(memoryProperties));
|
||||
}
|
||||
|
||||
TEST_F(MemoryPropertiesHelperTests, givenUsmInitialPlacementSetWhenCallingHasInitialPlacementCpuThenCorrectValueIsReturned) {
|
||||
DebugManagerStateRestore restorer;
|
||||
MemoryProperties memoryProperties{};
|
||||
|
||||
for (auto intialPlacement : {-1, 0, 1}) {
|
||||
DebugManager.flags.UsmInitialPlacement.set(intialPlacement);
|
||||
if (intialPlacement == 1) {
|
||||
EXPECT_EQ(GraphicsAllocation::UsmInitialPlacement::GPU, MemoryPropertiesHelper::getUSMInitialPlacement(memoryProperties));
|
||||
} else {
|
||||
EXPECT_EQ(GraphicsAllocation::UsmInitialPlacement::CPU, MemoryPropertiesHelper::getUSMInitialPlacement(memoryProperties));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(MemoryPropertiesHelperTests, WhenCallingSetInitialPlacementThenCorrectValueIsSetInAllocationProperties) {
|
||||
AllocationProperties allocationProperties{mockRootDeviceIndex, 0, GraphicsAllocation::AllocationType::UNIFIED_SHARED_MEMORY, mockDeviceBitfield};
|
||||
|
||||
for (auto initialPlacement : {GraphicsAllocation::UsmInitialPlacement::CPU, GraphicsAllocation::UsmInitialPlacement::GPU}) {
|
||||
MemoryPropertiesHelper::setUSMInitialPlacement(allocationProperties, initialPlacement);
|
||||
EXPECT_EQ(initialPlacement, allocationProperties.usmInitialPlacement);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2021 Intel Corporation
|
||||
* Copyright (C) 2019-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -220,7 +220,7 @@ HWTEST2_F(MemoryInfoTest, givenMemoryInfoWithRegionsWhenCreatingGemWithExtension
|
|||
ASSERT_NE(nullptr, memoryInfo);
|
||||
|
||||
uint32_t handle = 0;
|
||||
std::vector<MemoryClassInstance> memClassInstance = {regionInfo[0].region, regionInfo[1].region};
|
||||
MemRegionsVec memClassInstance = {regionInfo[0].region, regionInfo[1].region};
|
||||
auto ret = memoryInfo->createGemExt(drm.get(), memClassInstance, 1024, handle);
|
||||
EXPECT_EQ(1u, handle);
|
||||
EXPECT_EQ(0u, ret);
|
||||
|
|
|
@ -25,7 +25,7 @@ DG1TEST_F(IoctlHelperTestsDg1, givenDg1WhenCreateGemExtThenReturnCorrectValue) {
|
|||
|
||||
auto ioctlHelper = drm->getIoctlHelper();
|
||||
uint32_t handle = 0;
|
||||
std::vector<MemoryClassInstance> memClassInstance = {{I915_MEMORY_CLASS_DEVICE, 0}};
|
||||
MemRegionsVec memClassInstance = {{I915_MEMORY_CLASS_DEVICE, 0}};
|
||||
auto ret = ioctlHelper->createGemExt(drm.get(), memClassInstance, 1024, handle);
|
||||
|
||||
EXPECT_EQ(0u, ret);
|
||||
|
@ -46,7 +46,7 @@ DG1TEST_F(IoctlHelperTestsDg1, givenDg1WithDrmTipWhenCreateGemExtWithDebugFlagTh
|
|||
testing::internal::CaptureStdout();
|
||||
auto ioctlHelper = drm->getIoctlHelper();
|
||||
uint32_t handle = 0;
|
||||
std::vector<MemoryClassInstance> memClassInstance = {{I915_MEMORY_CLASS_DEVICE, 0}};
|
||||
MemRegionsVec memClassInstance = {{I915_MEMORY_CLASS_DEVICE, 0}};
|
||||
auto ret = ioctlHelper->createGemExt(drm.get(), memClassInstance, 1024, handle);
|
||||
|
||||
std::string output = testing::internal::GetCapturedStdout();
|
||||
|
@ -67,7 +67,7 @@ DG1TEST_F(IoctlHelperTestsDg1, givenDg1WhenCreateGemExtWithDebugFlagThenPrintDeb
|
|||
testing::internal::CaptureStdout();
|
||||
auto ioctlHelper = drm->getIoctlHelper();
|
||||
uint32_t handle = 0;
|
||||
std::vector<MemoryClassInstance> memClassInstance = {{I915_MEMORY_CLASS_DEVICE, 0}};
|
||||
MemRegionsVec memClassInstance = {{I915_MEMORY_CLASS_DEVICE, 0}};
|
||||
auto ret = ioctlHelper->createGemExt(drm.get(), memClassInstance, 1024, handle);
|
||||
|
||||
std::string output = testing::internal::GetCapturedStdout();
|
||||
|
|
|
@ -55,7 +55,7 @@ class IoctlHelperPrelimFixture : public ::testing::Test {
|
|||
TEST_F(IoctlHelperPrelimFixture, givenPrelimsWhenCreateGemExtThenReturnSuccess) {
|
||||
auto ioctlHelper = drm->getIoctlHelper();
|
||||
uint32_t handle = 0;
|
||||
std::vector<MemoryClassInstance> memClassInstance = {{I915_MEMORY_CLASS_DEVICE, 0}};
|
||||
MemRegionsVec memClassInstance = {{I915_MEMORY_CLASS_DEVICE, 0}};
|
||||
auto ret = ioctlHelper->createGemExt(drm.get(), memClassInstance, 1024, handle);
|
||||
|
||||
EXPECT_EQ(1u, handle);
|
||||
|
@ -70,7 +70,7 @@ TEST_F(IoctlHelperPrelimFixture, givenPrelimsWhenCreateGemExtWithDebugFlagThenPr
|
|||
testing::internal::CaptureStdout();
|
||||
auto ioctlHelper = drm->getIoctlHelper();
|
||||
uint32_t handle = 0;
|
||||
std::vector<MemoryClassInstance> memClassInstance = {{I915_MEMORY_CLASS_DEVICE, 0}};
|
||||
MemRegionsVec memClassInstance = {{I915_MEMORY_CLASS_DEVICE, 0}};
|
||||
ioctlHelper->createGemExt(drm.get(), memClassInstance, 1024, handle);
|
||||
|
||||
std::string output = testing::internal::GetCapturedStdout();
|
||||
|
|
|
@ -22,7 +22,7 @@ TEST(IoctlHelperTestsUpstream, givenUpstreamWhenCreateGemExtThenReturnCorrectVal
|
|||
|
||||
auto ioctlHelper = drm->getIoctlHelper();
|
||||
uint32_t handle = 0;
|
||||
std::vector<MemoryClassInstance> memClassInstance = {{I915_MEMORY_CLASS_DEVICE, 0}};
|
||||
MemRegionsVec memClassInstance = {{I915_MEMORY_CLASS_DEVICE, 0}};
|
||||
auto ret = ioctlHelper->createGemExt(drm.get(), memClassInstance, 1024, handle);
|
||||
|
||||
EXPECT_EQ(0u, ret);
|
||||
|
@ -43,7 +43,7 @@ TEST(IoctlHelperTestsUpstream, givenUpstreamWhenCreateGemExtWithDebugFlagThenPri
|
|||
testing::internal::CaptureStdout();
|
||||
auto ioctlHelper = drm->getIoctlHelper();
|
||||
uint32_t handle = 0;
|
||||
std::vector<MemoryClassInstance> memClassInstance = {{I915_MEMORY_CLASS_DEVICE, 0}};
|
||||
MemRegionsVec memClassInstance = {{I915_MEMORY_CLASS_DEVICE, 0}};
|
||||
ioctlHelper->createGemExt(drm.get(), memClassInstance, 1024, handle);
|
||||
|
||||
std::string output = testing::internal::GetCapturedStdout();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -35,5 +35,9 @@ class MemoryPropertiesHelper {
|
|||
bool deviceOnlyVisibilty, uint32_t cacheRegion);
|
||||
|
||||
static uint32_t getCacheRegion(const MemoryProperties &memoryProperties);
|
||||
|
||||
static GraphicsAllocation::UsmInitialPlacement getUSMInitialPlacement(const MemoryProperties &memoryProperties);
|
||||
|
||||
static void setUSMInitialPlacement(AllocationProperties &allocationProperties, GraphicsAllocation::UsmInitialPlacement initialPlacement);
|
||||
};
|
||||
} // namespace NEO
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -41,4 +41,22 @@ DeviceBitfield MemoryPropertiesHelper::adjustDeviceBitfield(uint32_t rootDeviceI
|
|||
return deviceBitfieldIn;
|
||||
}
|
||||
|
||||
GraphicsAllocation::UsmInitialPlacement MemoryPropertiesHelper::getUSMInitialPlacement(const MemoryProperties &memoryProperties) {
|
||||
auto initialPlacement = GraphicsAllocation::UsmInitialPlacement::CPU;
|
||||
if (memoryProperties.allocFlags.usmInitialPlacementGpu) {
|
||||
initialPlacement = GraphicsAllocation::UsmInitialPlacement::GPU;
|
||||
}
|
||||
if (memoryProperties.allocFlags.usmInitialPlacementCpu) {
|
||||
initialPlacement = GraphicsAllocation::UsmInitialPlacement::CPU;
|
||||
}
|
||||
if (const int32_t debugFlag = DebugManager.flags.UsmInitialPlacement.get(); debugFlag != -1) {
|
||||
initialPlacement = debugFlag != 1 ? GraphicsAllocation::UsmInitialPlacement::CPU : GraphicsAllocation::UsmInitialPlacement::GPU;
|
||||
}
|
||||
return initialPlacement;
|
||||
}
|
||||
|
||||
void MemoryPropertiesHelper::setUSMInitialPlacement(AllocationProperties &allocationProperties, GraphicsAllocation::UsmInitialPlacement initialPlacement) {
|
||||
allocationProperties.usmInitialPlacement = initialPlacement;
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2021 Intel Corporation
|
||||
* Copyright (C) 2019-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -38,6 +38,7 @@ struct AllocationProperties {
|
|||
size_t size = 0;
|
||||
size_t alignment = 0;
|
||||
GraphicsAllocation::AllocationType allocationType = GraphicsAllocation::AllocationType::UNKNOWN;
|
||||
GraphicsAllocation::UsmInitialPlacement usmInitialPlacement = GraphicsAllocation::UsmInitialPlacement::DEFAULT;
|
||||
ImageInfo *imgInfo = nullptr;
|
||||
bool multiStorageResource = false;
|
||||
ColouringPolicy colouringPolicy = ColouringPolicy::DeviceCountBased;
|
||||
|
@ -114,6 +115,7 @@ struct AllocationData {
|
|||
};
|
||||
static_assert(sizeof(AllocationData::flags) == sizeof(AllocationData::allFlags), "");
|
||||
GraphicsAllocation::AllocationType type = GraphicsAllocation::AllocationType::UNKNOWN;
|
||||
GraphicsAllocation::UsmInitialPlacement usmInitialPlacement = GraphicsAllocation::UsmInitialPlacement::DEFAULT;
|
||||
const void *hostPtr = nullptr;
|
||||
uint64_t gpuAddress = 0;
|
||||
size_t size = 0;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -103,6 +103,12 @@ class GraphicsAllocation : public IDNode<GraphicsAllocation> {
|
|||
COUNT
|
||||
};
|
||||
|
||||
enum UsmInitialPlacement {
|
||||
DEFAULT,
|
||||
CPU,
|
||||
GPU
|
||||
};
|
||||
|
||||
~GraphicsAllocation() override;
|
||||
GraphicsAllocation &operator=(const GraphicsAllocation &) = delete;
|
||||
GraphicsAllocation(const GraphicsAllocation &) = delete;
|
||||
|
|
|
@ -425,6 +425,7 @@ bool MemoryManager::getAllocationData(AllocationData &allocationData, const Allo
|
|||
allocationData.flags.preferCompressed = properties.flags.preferCompressed;
|
||||
allocationData.flags.preferCompressed |= CompressionSelector::preferCompressedAllocation(properties, *hwInfo);
|
||||
allocationData.flags.multiOsContextCapable = properties.flags.multiOsContextCapable;
|
||||
allocationData.usmInitialPlacement = properties.usmInitialPlacement;
|
||||
|
||||
if (properties.allocationType == GraphicsAllocation::AllocationType::DEBUG_CONTEXT_SAVE_AREA) {
|
||||
allocationData.flags.zeroMemory = 1;
|
||||
|
|
|
@ -293,6 +293,8 @@ void *SVMAllocsManager::createUnifiedKmdMigratedAllocation(size_t size, const Sv
|
|||
gpuProperties.alignment = pageSizeForAlignment;
|
||||
auto cacheRegion = MemoryPropertiesHelper::getCacheRegion(unifiedMemoryProperties.allocationFlags);
|
||||
MemoryPropertiesHelper::fillCachePolicyInProperties(gpuProperties, false, svmProperties.readOnly, false, cacheRegion);
|
||||
auto initialPlacement = MemoryPropertiesHelper::getUSMInitialPlacement(unifiedMemoryProperties.allocationFlags);
|
||||
MemoryPropertiesHelper::setUSMInitialPlacement(gpuProperties, initialPlacement);
|
||||
GraphicsAllocation *allocationGpu = memoryManager->allocateGraphicsMemoryWithProperties(gpuProperties);
|
||||
if (!allocationGpu) {
|
||||
return nullptr;
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/source/utilities/stackvec.h"
|
||||
|
||||
#include "igfxfmid.h"
|
||||
|
||||
#include <cstddef>
|
||||
|
@ -52,6 +54,8 @@ struct DistanceInfo {
|
|||
int32_t distance;
|
||||
};
|
||||
|
||||
using MemRegionsVec = StackVec<MemoryClassInstance, 5>;
|
||||
|
||||
class IoctlHelper {
|
||||
public:
|
||||
virtual ~IoctlHelper() {}
|
||||
|
@ -59,7 +63,7 @@ class IoctlHelper {
|
|||
static uint32_t ioctl(Drm *drm, unsigned long request, void *arg);
|
||||
virtual IoctlHelper *clone() = 0;
|
||||
|
||||
virtual uint32_t createGemExt(Drm *drm, const std::vector<MemoryClassInstance> &memClassInstances, size_t allocSize, uint32_t &handle) = 0;
|
||||
virtual uint32_t createGemExt(Drm *drm, const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle) = 0;
|
||||
virtual std::vector<MemoryRegion> translateToMemoryRegions(const std::vector<uint8_t> ®ionInfo) = 0;
|
||||
virtual CacheRegion closAlloc(Drm *drm) = 0;
|
||||
virtual uint16_t closAllocWays(Drm *drm, CacheRegion closIndex, uint16_t cacheLevel, uint16_t numWays) = 0;
|
||||
|
@ -84,7 +88,7 @@ class IoctlHelperUpstream : public IoctlHelper {
|
|||
public:
|
||||
IoctlHelper *clone() override;
|
||||
|
||||
uint32_t createGemExt(Drm *drm, const std::vector<MemoryClassInstance> &memClassInstances, size_t allocSize, uint32_t &handle) override;
|
||||
uint32_t createGemExt(Drm *drm, const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle) override;
|
||||
std::vector<MemoryRegion> translateToMemoryRegions(const std::vector<uint8_t> ®ionInfo) override;
|
||||
CacheRegion closAlloc(Drm *drm) override;
|
||||
uint16_t closAllocWays(Drm *drm, CacheRegion closIndex, uint16_t cacheLevel, uint16_t numWays) override;
|
||||
|
@ -114,7 +118,7 @@ class IoctlHelperImpl : public IoctlHelperUpstream {
|
|||
}
|
||||
IoctlHelper *clone() override;
|
||||
|
||||
uint32_t createGemExt(Drm *drm, const std::vector<MemoryClassInstance> &memClassInstances, size_t allocSize, uint32_t &handle) override;
|
||||
uint32_t createGemExt(Drm *drm, const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle) override;
|
||||
std::vector<MemoryRegion> translateToMemoryRegions(const std::vector<uint8_t> ®ionInfo) override;
|
||||
};
|
||||
|
||||
|
@ -122,7 +126,7 @@ class IoctlHelperPrelim20 : public IoctlHelper {
|
|||
public:
|
||||
IoctlHelper *clone() override;
|
||||
|
||||
uint32_t createGemExt(Drm *drm, const std::vector<MemoryClassInstance> &memClassInstances, size_t allocSize, uint32_t &handle) override;
|
||||
uint32_t createGemExt(Drm *drm, const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle) override;
|
||||
std::vector<MemoryRegion> translateToMemoryRegions(const std::vector<uint8_t> ®ionInfo) override;
|
||||
CacheRegion closAlloc(Drm *drm) override;
|
||||
uint16_t closAllocWays(Drm *drm, CacheRegion closIndex, uint16_t cacheLevel, uint16_t numWays) override;
|
||||
|
|
|
@ -23,7 +23,7 @@ IoctlHelper *IoctlHelperPrelim20::clone() {
|
|||
return new IoctlHelperPrelim20{};
|
||||
}
|
||||
|
||||
uint32_t IoctlHelperPrelim20::createGemExt(Drm *drm, const std::vector<MemoryClassInstance> &memClassInstances, size_t allocSize, uint32_t &handle) {
|
||||
uint32_t IoctlHelperPrelim20::createGemExt(Drm *drm, const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle) {
|
||||
uint32_t regionsSize = static_cast<uint32_t>(memClassInstances.size());
|
||||
std::vector<prelim_drm_i915_gem_memory_class_instance> regions(regionsSize);
|
||||
for (uint32_t i = 0; i < regionsSize; i++) {
|
||||
|
|
|
@ -17,7 +17,7 @@ IoctlHelper *IoctlHelperUpstream::clone() {
|
|||
return new IoctlHelperUpstream{};
|
||||
}
|
||||
|
||||
uint32_t IoctlHelperUpstream::createGemExt(Drm *drm, const std::vector<MemoryClassInstance> &memClassInstances, size_t allocSize, uint32_t &handle) {
|
||||
uint32_t IoctlHelperUpstream::createGemExt(Drm *drm, const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle) {
|
||||
uint32_t regionsSize = static_cast<uint32_t>(memClassInstances.size());
|
||||
std::vector<drm_i915_gem_memory_class_instance> regions(regionsSize);
|
||||
for (uint32_t i = 0; i < regionsSize; i++) {
|
||||
|
|
|
@ -23,7 +23,7 @@ IoctlHelper *IoctlHelperImpl<gfxProduct>::clone() {
|
|||
}
|
||||
|
||||
template <>
|
||||
uint32_t IoctlHelperImpl<gfxProduct>::createGemExt(Drm *drm, const std::vector<MemoryClassInstance> &memClassInstances, size_t allocSize, uint32_t &handle) {
|
||||
uint32_t IoctlHelperImpl<gfxProduct>::createGemExt(Drm *drm, const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle) {
|
||||
auto ret = IoctlHelperUpstream::createGemExt(drm, memClassInstances, allocSize, handle);
|
||||
if (ret == 0) {
|
||||
return ret;
|
||||
|
|
|
@ -49,7 +49,7 @@ void MemoryInfo::assignRegionsFromDistances(const std::vector<DistanceInfo> &dis
|
|||
}
|
||||
}
|
||||
|
||||
uint32_t MemoryInfo::createGemExt(Drm *drm, const std::vector<MemoryClassInstance> &memClassInstances, size_t allocSize, uint32_t &handle) {
|
||||
uint32_t MemoryInfo::createGemExt(Drm *drm, const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle) {
|
||||
return drm->getIoctlHelper()->createGemExt(drm, memClassInstances, allocSize, handle);
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,7 @@ void MemoryInfo::printRegionSizes() {
|
|||
uint32_t MemoryInfo::createGemExtWithSingleRegion(Drm *drm, uint32_t memoryBanks, size_t allocSize, uint32_t &handle) {
|
||||
auto pHwInfo = drm->getRootDeviceEnvironment().getHardwareInfo();
|
||||
auto regionClassAndInstance = getMemoryRegionClassAndInstance(memoryBanks, *pHwInfo);
|
||||
std::vector<MemoryClassInstance> region = {regionClassAndInstance};
|
||||
MemRegionsVec region = {regionClassAndInstance};
|
||||
auto ret = createGemExt(drm, region, allocSize, handle);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2021 Intel Corporation
|
||||
* Copyright (C) 2019-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -26,7 +26,7 @@ class MemoryInfo {
|
|||
|
||||
void assignRegionsFromDistances(const std::vector<DistanceInfo> &distances);
|
||||
|
||||
MOCKABLE_VIRTUAL uint32_t createGemExt(Drm *drm, const std::vector<MemoryClassInstance> &memClassInstances, size_t allocSize, uint32_t &handle);
|
||||
MOCKABLE_VIRTUAL uint32_t createGemExt(Drm *drm, const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle);
|
||||
|
||||
MemoryClassInstance getMemoryRegionClassAndInstance(uint32_t memoryBank, const HardwareInfo &hwInfo);
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2021 Intel Corporation
|
||||
* Copyright (C) 2019-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include "shared/source/debug_settings/debug_settings_manager.h"
|
||||
#include "shared/source/helpers/debug_helpers.h"
|
||||
#include "shared/source/helpers/memory_properties_helpers.h"
|
||||
#include "shared/source/helpers/options.h"
|
||||
#include "shared/source/helpers/ptr_math.h"
|
||||
#include "shared/source/memory_manager/unified_memory_manager.h"
|
||||
|
@ -17,21 +18,12 @@
|
|||
|
||||
namespace NEO {
|
||||
void PageFaultManager::insertAllocation(void *ptr, size_t size, SVMAllocsManager *unifiedMemoryManager, void *cmdQ, const MemoryProperties &memoryProperties) {
|
||||
bool initialPlacementCpu = true;
|
||||
if (memoryProperties.allocFlags.usmInitialPlacementGpu) {
|
||||
initialPlacementCpu = false;
|
||||
}
|
||||
if (memoryProperties.allocFlags.usmInitialPlacementCpu) {
|
||||
initialPlacementCpu = true;
|
||||
}
|
||||
if (const int32_t debugFlag = DebugManager.flags.UsmInitialPlacement.get(); debugFlag != -1) {
|
||||
initialPlacementCpu = debugFlag != 1;
|
||||
}
|
||||
const auto domain = initialPlacementCpu ? AllocationDomain::Cpu : AllocationDomain::None;
|
||||
auto initialPlacement = MemoryPropertiesHelper::getUSMInitialPlacement(memoryProperties);
|
||||
const auto domain = (initialPlacement == GraphicsAllocation::UsmInitialPlacement::CPU) ? AllocationDomain::Cpu : AllocationDomain::None;
|
||||
|
||||
std::unique_lock<SpinLock> lock{mtx};
|
||||
this->memoryData.insert(std::make_pair(ptr, PageFaultData{size, unifiedMemoryManager, cmdQ, domain}));
|
||||
if (!initialPlacementCpu) {
|
||||
if (initialPlacement != GraphicsAllocation::UsmInitialPlacement::CPU) {
|
||||
this->protectCPUMemoryAccess(ptr, size);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2021 Intel Corporation
|
||||
* Copyright (C) 2019-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -152,7 +152,7 @@ struct MockedMemoryInfo : public NEO::MemoryInfo {
|
|||
size_t getMemoryRegionSize(uint32_t memoryBank) override {
|
||||
return 1024u;
|
||||
}
|
||||
uint32_t createGemExt(Drm *drm, const std::vector<MemoryClassInstance> &memClassInstances, size_t allocSize, uint32_t &handle) override {
|
||||
uint32_t createGemExt(Drm *drm, const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle) override {
|
||||
if (allocSize == 0) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue