mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-09 22:43:00 +08:00
fix: get right page size when malloc uses 0 alignment
Related-To: GSD-7103 Signed-off-by: Lu, Wenbin <wenbin.lu@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
739d181026
commit
67fa39c9a1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
* Copyright (C) 2018-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -119,6 +119,24 @@ INSTANTIATE_TEST_CASE_P(
|
||||
256,
|
||||
4096));
|
||||
|
||||
struct AlignUpNonZero : public ::testing::TestWithParam<std::tuple<size_t, size_t>> {
|
||||
};
|
||||
|
||||
TEST_P(AlignUpNonZero, GivenSizeAndAlignmentThenAlignedResultIsNonZero) {
|
||||
size_t size = std::get<0>(GetParam());
|
||||
size_t alignment = std::get<1>(GetParam());
|
||||
const size_t result = alignUpNonZero(size, alignment);
|
||||
EXPECT_TRUE(0 < result);
|
||||
EXPECT_TRUE(0 == result % alignment);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
AlignUpNonZeroParameterized,
|
||||
AlignUpNonZero,
|
||||
testing::Combine(
|
||||
testing::Values(0, 1),
|
||||
testing::Values(1, 4, 8, 32, 64, 256, 4096)));
|
||||
|
||||
TEST(AlignWholeSize, GivenSizeLessThanPageSizeWhenAligningWholeSizeToPageThenAlignedSizeIsPageSize) {
|
||||
int size = 1;
|
||||
auto retSize = alignSizeWholePage(ptrAlignedToPage, size);
|
||||
|
||||
@@ -337,7 +337,7 @@ TEST_F(SVMLocalMemoryAllocatorTest, givenAlignmentThenUnifiedMemoryAllocationsAr
|
||||
do {
|
||||
alignment >>= 1;
|
||||
memoryManager->validateAllocateProperties = [alignment](const AllocationProperties &properties) {
|
||||
EXPECT_EQ(properties.alignment, alignUp<size_t>(alignment, MemoryConstants::pageSize64k));
|
||||
EXPECT_EQ(properties.alignment, alignUpNonZero<size_t>(alignment, MemoryConstants::pageSize64k));
|
||||
};
|
||||
SVMAllocsManager::UnifiedMemoryProperties unifiedMemoryProperties(InternalMemoryType::DEVICE_UNIFIED_MEMORY, alignment, rootDeviceIndices, deviceBitfields);
|
||||
unifiedMemoryProperties.device = device;
|
||||
@@ -362,7 +362,7 @@ TEST_F(SVMLocalMemoryAllocatorTest, givenAlignmentThenHostUnifiedMemoryAllocatio
|
||||
do {
|
||||
alignment >>= 1;
|
||||
memoryManager->validateAllocateProperties = [alignment](const AllocationProperties &properties) {
|
||||
EXPECT_EQ(properties.alignment, alignUp<size_t>(alignment, MemoryConstants::pageSize));
|
||||
EXPECT_EQ(properties.alignment, alignUpNonZero<size_t>(alignment, MemoryConstants::pageSize));
|
||||
};
|
||||
SVMAllocsManager::UnifiedMemoryProperties unifiedMemoryProperties(InternalMemoryType::HOST_UNIFIED_MEMORY, alignment, rootDeviceIndices, deviceBitfields);
|
||||
unifiedMemoryProperties.device = device;
|
||||
@@ -391,7 +391,7 @@ TEST_F(SVMLocalMemoryAllocatorTest, givenAlignmentThenSharedUnifiedMemoryAllocat
|
||||
do {
|
||||
alignment >>= 1;
|
||||
memoryManager->validateAllocateProperties = [alignment](const AllocationProperties &properties) {
|
||||
EXPECT_EQ(properties.alignment, alignUp<size_t>(alignment, MemoryConstants::pageSize64k));
|
||||
EXPECT_EQ(properties.alignment, alignUpNonZero<size_t>(alignment, MemoryConstants::pageSize64k));
|
||||
};
|
||||
SVMAllocsManager::UnifiedMemoryProperties unifiedMemoryProperties(InternalMemoryType::SHARED_UNIFIED_MEMORY, alignment, rootDeviceIndices, deviceBitfields);
|
||||
unifiedMemoryProperties.device = device;
|
||||
|
||||
Reference in New Issue
Block a user