mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Add missing USM host allocation flag
Change-Id: I5658d5574fd522cff072adcc679f04805daabf12 Signed-off-by: Lukasz Jobczyk <lukasz.jobczyk@intel.com>
This commit is contained in:
@ -268,6 +268,29 @@ TEST_F(DrmMemoryManagerLocalMemoryTest, givenMemoryInfoWhenAllocateWithAlignment
|
||||
memoryManager->freeGraphicsMemory(allocation);
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerLocalMemoryTest, givenMemoryInfoAndNotUseObjectMmapPropertyWhenAllocateWithAlignmentThenUserptrIsUsed) {
|
||||
DebugManagerStateRestore restorer;
|
||||
DebugManager.flags.EnableBOMmapCreate.set(0);
|
||||
|
||||
drm_i915_memory_region_info regionInfo[2] = {};
|
||||
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
|
||||
regionInfo[1].region = {I915_MEMORY_CLASS_DEVICE, 0};
|
||||
|
||||
mock->memoryInfo.reset(new MemoryInfoImpl(regionInfo, 2));
|
||||
mock->mmapOffsetRetVal = -1;
|
||||
|
||||
AllocationData allocationData;
|
||||
allocationData.size = MemoryConstants::pageSize64k;
|
||||
allocationData.useMmapObject = false;
|
||||
|
||||
auto allocation = memoryManager->allocateGraphicsMemoryWithAlignment(allocationData);
|
||||
|
||||
EXPECT_NE(allocation, nullptr);
|
||||
EXPECT_EQ(static_cast<int>(mock->returnHandle), allocation->getBO()->peekHandle() + 1);
|
||||
|
||||
memoryManager->freeGraphicsMemory(allocation);
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerLocalMemoryTest, givenMemoryInfoAndFailedMmapOffsetWhenAllocateWithAlignmentThenNullptr) {
|
||||
DebugManagerStateRestore restorer;
|
||||
DebugManager.flags.EnableBOMmapCreate.set(-1);
|
||||
|
@ -40,6 +40,7 @@ struct AllocationProperties {
|
||||
DeviceBitfield subDevicesBitfield{};
|
||||
uint64_t gpuAddress = 0;
|
||||
OsContext *osContext = nullptr;
|
||||
bool useMmapObject = true;
|
||||
|
||||
AllocationProperties(uint32_t rootDeviceIndex, size_t size,
|
||||
GraphicsAllocation::AllocationType allocationType, DeviceBitfield subDevicesBitfieldParam)
|
||||
@ -112,5 +113,6 @@ struct AllocationData {
|
||||
ImageInfo *imgInfo = nullptr;
|
||||
uint32_t rootDeviceIndex = 0;
|
||||
OsContext *osContext = nullptr;
|
||||
bool useMmapObject = true;
|
||||
};
|
||||
} // namespace NEO
|
||||
|
@ -139,11 +139,13 @@ GraphicsAllocation *MemoryManager::createPaddedAllocation(GraphicsAllocation *in
|
||||
|
||||
void *MemoryManager::createMultiGraphicsAllocation(std::vector<uint32_t> &rootDeviceIndices, AllocationProperties &properties, MultiGraphicsAllocation &multiGraphicsAllocation) {
|
||||
void *ptr = nullptr;
|
||||
properties.useMmapObject = rootDeviceIndices.size() == 1u;
|
||||
|
||||
for (auto &rootDeviceIndex : rootDeviceIndices) {
|
||||
properties.rootDeviceIndex = rootDeviceIndex;
|
||||
|
||||
if (!ptr) {
|
||||
properties.flags.isUSMHostAllocation = true;
|
||||
auto graphicsAllocation = allocateGraphicsMemoryWithProperties(properties);
|
||||
if (!graphicsAllocation) {
|
||||
return nullptr;
|
||||
@ -395,6 +397,7 @@ bool MemoryManager::getAllocationData(AllocationData &allocationData, const Allo
|
||||
allocationData.gpuAddress = properties.gpuAddress;
|
||||
allocationData.osContext = properties.osContext;
|
||||
allocationData.rootDeviceIndex = properties.rootDeviceIndex;
|
||||
allocationData.useMmapObject = properties.useMmapObject;
|
||||
|
||||
hwHelper.setExtraAllocationData(allocationData, properties, *hwInfo);
|
||||
|
||||
|
@ -66,7 +66,7 @@ BufferObject *DrmMemoryManager::createBufferObjectInMemoryRegion(Drm *drm,
|
||||
}
|
||||
|
||||
DrmAllocation *DrmMemoryManager::createAllocWithAlignment(const AllocationData &allocationData, size_t size, size_t alignment, size_t alignedSize, uint64_t gpuAddress) {
|
||||
bool useBooMmap = this->getDrm(allocationData.rootDeviceIndex).getMemoryInfo() != nullptr;
|
||||
bool useBooMmap = this->getDrm(allocationData.rootDeviceIndex).getMemoryInfo() && allocationData.useMmapObject;
|
||||
|
||||
if (DebugManager.flags.EnableBOMmapCreate.get() != -1) {
|
||||
useBooMmap = DebugManager.flags.EnableBOMmapCreate.get();
|
||||
|
Reference in New Issue
Block a user