Skip to content

Commit df1162f

Browse files
kgibalaCompute-Runtime-Automation
authored andcommitted
Change alignment for forced created ptr in image
Related-To: NEO-5723 Signed-off-by: Krzysztof Gibala <[email protected]>
1 parent 5f41e00 commit df1162f

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

opencl/source/mem_obj/image.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,8 @@ Image *Image::create(Context *context,
344344
const_cast<MemoryProperties &>(memoryPropertiesToSet), hwInfo,
345345
context->getDeviceBitfieldForAllocation(rootDeviceIndex));
346346
allocProperties.flags.crossRootDeviceAccess = true;
347-
348-
hostPtrForced = alignedMalloc(hostPtrMinSize, MemoryConstants::pageSize64k);
347+
auto hostPtrForcedSize = alignUp(hostPtrMinSize, MemoryConstants::pageSize);
348+
hostPtrForced = alignedMalloc(hostPtrForcedSize, MemoryConstants::pageSize);
349349
allocationInfo[rootDeviceIndex].memory = memoryManager->allocateGraphicsMemoryWithProperties(allocProperties, hostPtrForced);
350350
if (allocationInfo[rootDeviceIndex].memory) {
351351
cpuPtr = reinterpret_cast<void *>(allocationInfo[rootDeviceIndex].memory->getUnderlyingBuffer());

opencl/test/unit_test/mem_obj/image_tests.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1628,6 +1628,15 @@ HWTEST_F(ImageTransformTest, givenSurfaceBaseAddressAndUnifiedSurfaceWhenSetUnif
16281628

16291629
using ImageMultiRootDeviceTests = MultiRootDeviceFixture;
16301630

1631+
TEST_F(ImageMultiRootDeviceTests, WhenImageIsCreatedThenImageAllocationHostPtrForcedHasCorrectAlignment) {
1632+
std::unique_ptr<Image> image(ImageHelper<Image3dDefaults>::create(context.get()));
1633+
1634+
auto hostPtrForced = image->getAllocatedMapPtr();
1635+
1636+
ASSERT_NE(nullptr, hostPtrForced);
1637+
EXPECT_EQ(0u, (uintptr_t)hostPtrForced % MemoryConstants::pageSize);
1638+
}
1639+
16311640
TEST_F(ImageMultiRootDeviceTests, WhenImageIsCreatedThenImageAllocationHasCorrectRootDeviceIndex) {
16321641
std::unique_ptr<Image> image(ImageHelper<Image3dDefaults>::create(context.get()));
16331642

0 commit comments

Comments
 (0)