From c865dbbaa1e320cc323cfc778aa7448d968328b8 Mon Sep 17 00:00:00 2001 From: "Mrozek, Michal" Date: Fri, 7 Dec 2018 16:12:07 +0100 Subject: [PATCH] Choose BUFFER_HOST_MEMORY as type in 32 bit applications. Change-Id: I33addbd37cb4b9192c2dfa88aeee6d6cbdafd714 --- Jenkinsfile | 2 +- runtime/mem_obj/buffer.cpp | 4 ++- unit_tests/mem_obj/buffer_tests.cpp | 40 ++++++++++++++++++++++++----- 3 files changed, 37 insertions(+), 9 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index e2178d78df..46ac5556f2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,5 +1,5 @@ #!groovy dependenciesRevision='0069cbdd1559b47c9de98ca934b334b12fa59703-1174' strategy='EQUAL' -allowedCD=273 +allowedCD=274 allowedF=4 diff --git a/runtime/mem_obj/buffer.cpp b/runtime/mem_obj/buffer.cpp index c827779d1e..d4fc2dd257 100644 --- a/runtime/mem_obj/buffer.cpp +++ b/runtime/mem_obj/buffer.cpp @@ -319,7 +319,9 @@ void Buffer::checkMemory(cl_mem_flags flags, GraphicsAllocation::AllocationType Buffer::getGraphicsAllocationType(cl_mem_flags flags, bool sharedContext, bool renderCompressedBuffers) { GraphicsAllocation::AllocationType type = GraphicsAllocation::AllocationType::BUFFER; - if (flags & CL_MEM_USE_HOST_PTR) { + if (is32bit) { + type = GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY; + } else if (flags & CL_MEM_USE_HOST_PTR) { type = GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY; } else if (renderCompressedBuffers) { type = GraphicsAllocation::AllocationType::BUFFER_COMPRESSED; diff --git a/unit_tests/mem_obj/buffer_tests.cpp b/unit_tests/mem_obj/buffer_tests.cpp index 357a4df7a5..1f146fc526 100644 --- a/unit_tests/mem_obj/buffer_tests.cpp +++ b/unit_tests/mem_obj/buffer_tests.cpp @@ -307,7 +307,11 @@ TEST(Buffer, givenAllocHostPtrFlagPassedToBufferCreateWhenNoSharedContextOrRende TEST(Buffer, givenRenderCompressedBuffersEnabledWhenAllocationTypeIsQueriedThenBufferCompressedTypeIsReturned) { cl_mem_flags flags = 0; auto type = MockPublicAccessBuffer::getGraphicsAllocationType(flags, false, true); - EXPECT_EQ(GraphicsAllocation::AllocationType::BUFFER_COMPRESSED, type); + if (is32bit) { + EXPECT_EQ(GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY, type); + } else { + EXPECT_EQ(GraphicsAllocation::AllocationType::BUFFER_COMPRESSED, type); + } } TEST(Buffer, givenSharedContextWhenAllocationTypeIsQueriedThenBufferHostMemoryTypeIsReturned) { @@ -343,13 +347,21 @@ TEST(Buffer, givenUseHostPtrFlagAndRenderCompressedBuffersEnabledWhenAllocationT TEST(Buffer, givenAllocHostPtrFlagAndRenderCompressedBuffersEnabledWhenAllocationTypeIsQueriedThenBufferCompressedTypeIsReturned) { cl_mem_flags flags = CL_MEM_ALLOC_HOST_PTR; auto type = MockPublicAccessBuffer::getGraphicsAllocationType(flags, false, true); - EXPECT_EQ(GraphicsAllocation::AllocationType::BUFFER_COMPRESSED, type); + if (is32bit) { + EXPECT_EQ(GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY, type); + } else { + EXPECT_EQ(GraphicsAllocation::AllocationType::BUFFER_COMPRESSED, type); + } } TEST(Buffer, givenZeroFlagsNoSharedContextAndRenderCompressedBuffersDisabledWhenAllocationTypeIsQueriedThenBufferTypeIsReturned) { cl_mem_flags flags = 0; auto type = MockPublicAccessBuffer::getGraphicsAllocationType(flags, false, false); - EXPECT_EQ(GraphicsAllocation::AllocationType::BUFFER, type); + if (is32bit) { + EXPECT_EQ(GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY, type); + } else { + EXPECT_EQ(GraphicsAllocation::AllocationType::BUFFER, type); + } } TEST(Buffer, givenClMemCopyHostPointerPassedToBufferCreateWhenAllocationIsNotInSystemMemoryPoolThenAllocationIsWrittenByEnqueueWriteBuffer) { @@ -441,8 +453,13 @@ TEST_F(RenderCompressedBuffersTests, givenBufferCompressedAllocationAndNoHostPtr localHwInfo.capabilityTable.ftrRenderCompressedBuffers = true; buffer.reset(Buffer::create(context.get(), 0, MemoryConstants::cacheLineSize, nullptr, retVal)); - EXPECT_FALSE(buffer->isMemObjZeroCopy()); - EXPECT_EQ(buffer->getGraphicsAllocation()->getAllocationType(), GraphicsAllocation::AllocationType::BUFFER_COMPRESSED); + if (is32bit) { + EXPECT_TRUE(buffer->isMemObjZeroCopy()); + EXPECT_EQ(buffer->getGraphicsAllocation()->getAllocationType(), GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY); + } else { + EXPECT_FALSE(buffer->isMemObjZeroCopy()); + EXPECT_EQ(buffer->getGraphicsAllocation()->getAllocationType(), GraphicsAllocation::AllocationType::BUFFER_COMPRESSED); + } } TEST_F(RenderCompressedBuffersTests, givenBufferCompressedAllocationWhenSharedContextIsUsedThenForceDisableCompression) { @@ -452,8 +469,11 @@ TEST_F(RenderCompressedBuffersTests, givenBufferCompressedAllocationWhenSharedCo uint32_t hostPtr = 0; buffer.reset(Buffer::create(context.get(), 0, sizeof(uint32_t), &hostPtr, retVal)); - EXPECT_EQ(buffer->getGraphicsAllocation()->getAllocationType(), GraphicsAllocation::AllocationType::BUFFER_COMPRESSED); - + if (is32bit) { + EXPECT_EQ(buffer->getGraphicsAllocation()->getAllocationType(), GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY); + } else { + EXPECT_EQ(buffer->getGraphicsAllocation()->getAllocationType(), GraphicsAllocation::AllocationType::BUFFER_COMPRESSED); + } context->isSharedContext = true; buffer.reset(Buffer::create(context.get(), 0, sizeof(uint32_t), &hostPtr, retVal)); EXPECT_EQ(buffer->getGraphicsAllocation()->getAllocationType(), GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY); @@ -484,6 +504,9 @@ struct RenderCompressedBuffersCopyHostMemoryTests : public RenderCompressedBuffe }; TEST_F(RenderCompressedBuffersCopyHostMemoryTests, givenRenderCompressedBufferWhenCopyFromHostPtrIsRequiredThenCallWriteBuffer) { + if (is32bit) { + return; + } localHwInfo.capabilityTable.ftrRenderCompressedBuffers = true; buffer.reset(Buffer::create(context.get(), CL_MEM_COPY_HOST_PTR, sizeof(uint32_t), &hostPtr, retVal)); @@ -508,6 +531,9 @@ TEST_F(RenderCompressedBuffersCopyHostMemoryTests, givenNonRenderCompressedBuffe } TEST_F(RenderCompressedBuffersCopyHostMemoryTests, givenRenderCompressedBufferWhenWriteBufferFailsThenReturnErrorCode) { + if (is32bit) { + return; + } localHwInfo.capabilityTable.ftrRenderCompressedBuffers = true; mockCmdQ->writeBufferRetValue = CL_INVALID_VALUE;