From df1162ff4d359853e1319a3039c16cd2658f29f3 Mon Sep 17 00:00:00 2001 From: Krzysztof Gibala Date: Tue, 27 Apr 2021 10:21:32 +0000 Subject: [PATCH] Change alignment for forced created ptr in image Related-To: NEO-5723 Signed-off-by: Krzysztof Gibala --- opencl/source/mem_obj/image.cpp | 4 ++-- opencl/test/unit_test/mem_obj/image_tests.cpp | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/opencl/source/mem_obj/image.cpp b/opencl/source/mem_obj/image.cpp index 858dfe6ac6..f78c684110 100644 --- a/opencl/source/mem_obj/image.cpp +++ b/opencl/source/mem_obj/image.cpp @@ -344,8 +344,8 @@ Image *Image::create(Context *context, const_cast(memoryPropertiesToSet), hwInfo, context->getDeviceBitfieldForAllocation(rootDeviceIndex)); allocProperties.flags.crossRootDeviceAccess = true; - - hostPtrForced = alignedMalloc(hostPtrMinSize, MemoryConstants::pageSize64k); + auto hostPtrForcedSize = alignUp(hostPtrMinSize, MemoryConstants::pageSize); + hostPtrForced = alignedMalloc(hostPtrForcedSize, MemoryConstants::pageSize); allocationInfo[rootDeviceIndex].memory = memoryManager->allocateGraphicsMemoryWithProperties(allocProperties, hostPtrForced); if (allocationInfo[rootDeviceIndex].memory) { cpuPtr = reinterpret_cast(allocationInfo[rootDeviceIndex].memory->getUnderlyingBuffer()); diff --git a/opencl/test/unit_test/mem_obj/image_tests.cpp b/opencl/test/unit_test/mem_obj/image_tests.cpp index e2dff4f1fc..755a11923d 100644 --- a/opencl/test/unit_test/mem_obj/image_tests.cpp +++ b/opencl/test/unit_test/mem_obj/image_tests.cpp @@ -1628,6 +1628,15 @@ HWTEST_F(ImageTransformTest, givenSurfaceBaseAddressAndUnifiedSurfaceWhenSetUnif using ImageMultiRootDeviceTests = MultiRootDeviceFixture; +TEST_F(ImageMultiRootDeviceTests, WhenImageIsCreatedThenImageAllocationHostPtrForcedHasCorrectAlignment) { + std::unique_ptr image(ImageHelper::create(context.get())); + + auto hostPtrForced = image->getAllocatedMapPtr(); + + ASSERT_NE(nullptr, hostPtrForced); + EXPECT_EQ(0u, (uintptr_t)hostPtrForced % MemoryConstants::pageSize); +} + TEST_F(ImageMultiRootDeviceTests, WhenImageIsCreatedThenImageAllocationHasCorrectRootDeviceIndex) { std::unique_ptr image(ImageHelper::create(context.get()));