Skip to content

Commit 151aaf7

Browse files
Fix alignment for host allocations.
- it is 4k not 64k. Signed-off-by: Michal Mrozek <[email protected]>
1 parent 15ac453 commit 151aaf7

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

level_zero/core/test/black_box_tests/zello_scratch.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2021 Intel Corporation
2+
* Copyright (C) 2021-2022 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -50,7 +50,7 @@ void executeGpuKernelAndValidate(ze_context_handle_t context, ze_device_handle_t
5050
uint32_t typeSize = sizeof(uint32_t);
5151
uint32_t srcAdditionalMul = 3u;
5252

53-
uint32_t expectedMemorySize = arraySize * vectorSize * typeSize;
53+
uint32_t expectedMemorySize = arraySize * vectorSize * typeSize * 2;
5454
uint32_t srcMemorySize = expectedMemorySize * srcAdditionalMul;
5555
uint32_t idxMemorySize = arraySize * sizeof(uint32_t);
5656

opencl/test/unit_test/memory_manager/unified_memory_manager_tests.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019-2021 Intel Corporation
2+
* Copyright (C) 2019-2022 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -806,6 +806,21 @@ TEST_F(UnifiedMemoryManagerPropertiesTest,
806806
svmManager->freeSVMAlloc(ptr);
807807
}
808808

809+
TEST_F(UnifiedMemoryManagerPropertiesTest,
810+
given1ByteAsAllocationSizeWhenHostMemAllocIsCreatedItIsAlignedTo4k) {
811+
std::set<uint32_t> rootDeviceIndices{mockRootDeviceIndex};
812+
std::map<uint32_t, DeviceBitfield> deviceBitfields{{mockRootDeviceIndex, DeviceBitfield(0x1)}};
813+
SVMAllocsManager::UnifiedMemoryProperties unifiedMemoryProperties(InternalMemoryType::HOST_UNIFIED_MEMORY, rootDeviceIndices, deviceBitfields);
814+
815+
svmManager->multiOsContextSupport = true;
816+
auto ptr = svmManager->createHostUnifiedMemoryAllocation(1u, unifiedMemoryProperties);
817+
818+
auto allocation = svmManager->getSVMAlloc(ptr);
819+
EXPECT_EQ(MemoryConstants::pageSize, allocation->gpuAllocations.getDefaultGraphicsAllocation()->getUnderlyingBufferSize());
820+
821+
svmManager->freeSVMAlloc(ptr);
822+
}
823+
809824
TEST_F(UnifiedMemoryManagerPropertiesTest,
810825
givenSvmManagerMultiOsContextSupportFlagFalseWhenRootDeviceIsMultiThenMultiStorageFlagFalse) {
811826
std::set<uint32_t> rootDeviceIndices{mockRootDeviceIndex};

shared/source/memory_manager/unified_memory_manager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ void *SVMAllocsManager::createSVMAlloc(size_t size, const SvmAllocationPropertie
125125

126126
void *SVMAllocsManager::createHostUnifiedMemoryAllocation(size_t size,
127127
const UnifiedMemoryProperties &memoryProperties) {
128-
size_t alignedSize = alignUp<size_t>(size, MemoryConstants::pageSize64k);
128+
size_t alignedSize = alignUp<size_t>(size, MemoryConstants::pageSize);
129129

130130
bool compressionEnabled = false;
131131
GraphicsAllocation::AllocationType allocationType = getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled);

0 commit comments

Comments
 (0)