From 6059e77fb419fd1b504c788289d8b7d7466eecf0 Mon Sep 17 00:00:00 2001 From: "Dunajski, Bartosz" Date: Thu, 24 Oct 2019 14:18:39 +0200 Subject: [PATCH] Unify mapAllocation and hostPtrAllocation to transferAllocation Change-Id: I875d6886ce3b0866da7679925ba973d2d16a1141 Signed-off-by: Dunajski, Bartosz --- runtime/built_ins/builtins_dispatch_builder.h | 3 +-- runtime/command_queue/enqueue_read_buffer.h | 3 +-- runtime/command_queue/enqueue_write_buffer.h | 3 +-- runtime/helpers/blit_commands_helper.cpp | 5 +---- .../command_stream/command_stream_receiver_hw_tests.cpp | 4 ++-- unit_tests/mem_obj/buffer_tests.cpp | 8 ++++---- 6 files changed, 10 insertions(+), 16 deletions(-) diff --git a/runtime/built_ins/builtins_dispatch_builder.h b/runtime/built_ins/builtins_dispatch_builder.h index c2a8f43d61..09e04c7284 100644 --- a/runtime/built_ins/builtins_dispatch_builder.h +++ b/runtime/built_ins/builtins_dispatch_builder.h @@ -37,8 +37,7 @@ struct BuiltinOpParams { MemObj *dstMemObj = nullptr; GraphicsAllocation *srcSvmAlloc = nullptr; GraphicsAllocation *dstSvmAlloc = nullptr; - GraphicsAllocation *mapAllocation = nullptr; - GraphicsAllocation *hostPtrAllocation = nullptr; + GraphicsAllocation *transferAllocation = nullptr; //mapAllocation or hostPtrAllocation const MemObjsForAuxTranslation *memObjsForAuxTranslation = nullptr; AuxTranslationDirection auxTranslationDirection = AuxTranslationDirection::None; bool unifiedMemoryArgsRequireMemSync = true; diff --git a/runtime/command_queue/enqueue_read_buffer.h b/runtime/command_queue/enqueue_read_buffer.h index 9958151597..ea984bba77 100644 --- a/runtime/command_queue/enqueue_read_buffer.h +++ b/runtime/command_queue/enqueue_read_buffer.h @@ -92,8 +92,7 @@ cl_int CommandQueueHw::enqueueReadBuffer( dc.srcMemObj = buffer; dc.srcOffset = {offset, 0, 0}; dc.size = {size, 0, 0}; - dc.mapAllocation = mapAllocation; - dc.hostPtrAllocation = hostPtrSurf.getAllocation(); + dc.transferAllocation = mapAllocation ? mapAllocation : hostPtrSurf.getAllocation(); builder.buildDispatchInfos(dispatchInfo, dc); if (context->isProvidingPerformanceHints()) { diff --git a/runtime/command_queue/enqueue_write_buffer.h b/runtime/command_queue/enqueue_write_buffer.h index fdfa831b29..8a17682835 100644 --- a/runtime/command_queue/enqueue_write_buffer.h +++ b/runtime/command_queue/enqueue_write_buffer.h @@ -88,8 +88,7 @@ cl_int CommandQueueHw::enqueueWriteBuffer( dc.dstMemObj = buffer; dc.dstOffset = {offset, 0, 0}; dc.size = {size, 0, 0}; - dc.mapAllocation = mapAllocation; - dc.hostPtrAllocation = hostPtrSurf.getAllocation(); + dc.transferAllocation = mapAllocation ? mapAllocation : hostPtrSurf.getAllocation(); builder.buildDispatchInfos(dispatchInfo, dc); enqueueHandler( diff --git a/runtime/helpers/blit_commands_helper.cpp b/runtime/helpers/blit_commands_helper.cpp index 83804b8eed..5177e7ef30 100644 --- a/runtime/helpers/blit_commands_helper.cpp +++ b/runtime/helpers/blit_commands_helper.cpp @@ -53,10 +53,7 @@ BlitProperties BlitProperties::constructPropertiesForReadWriteBuffer(BlitterCons void *hostPtr = nullptr; size_t hostPtrOffset = 0; - GraphicsAllocation *hostAllocation = builtinOpParams.hostPtrAllocation; - if (builtinOpParams.mapAllocation) { - hostAllocation = builtinOpParams.mapAllocation; - } + GraphicsAllocation *hostAllocation = builtinOpParams.transferAllocation; if (BlitterConstants::BlitDirection::HostPtrToBuffer == blitDirection) { // write buffer diff --git a/unit_tests/command_stream/command_stream_receiver_hw_tests.cpp b/unit_tests/command_stream/command_stream_receiver_hw_tests.cpp index 442c3e8090..60099f45df 100644 --- a/unit_tests/command_stream/command_stream_receiver_hw_tests.cpp +++ b/unit_tests/command_stream/command_stream_receiver_hw_tests.cpp @@ -766,7 +766,7 @@ HWTEST_F(BcsTests, givenMapAllocationInBuiltinOpParamsWhenConstructingThenUseItA builtinOpParams.dstMemObj = buffer.get(); builtinOpParams.srcPtr = mapPtr; builtinOpParams.size.x = 1; - builtinOpParams.mapAllocation = mapAllocation; + builtinOpParams.transferAllocation = mapAllocation; auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer(BlitterConstants::BlitDirection::HostPtrToBuffer, csr, builtinOpParams, true); @@ -778,7 +778,7 @@ HWTEST_F(BcsTests, givenMapAllocationInBuiltinOpParamsWhenConstructingThenUseItA builtinOpParams.srcMemObj = buffer.get(); builtinOpParams.dstPtr = mapPtr; builtinOpParams.size.x = 1; - builtinOpParams.mapAllocation = mapAllocation; + builtinOpParams.transferAllocation = mapAllocation; auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer(BlitterConstants::BlitDirection::BufferToHostPtr, csr, builtinOpParams, true); diff --git a/unit_tests/mem_obj/buffer_tests.cpp b/unit_tests/mem_obj/buffer_tests.cpp index b2ec1a9901..e7966583ae 100644 --- a/unit_tests/mem_obj/buffer_tests.cpp +++ b/unit_tests/mem_obj/buffer_tests.cpp @@ -887,15 +887,15 @@ HWTEST_TEMPLATED_F(BcsBufferTests, givenMapAllocationWhenEnqueueingReadOrWriteBu auto mapAllocation = bufferForBlt->getMapAllocation(); EXPECT_NE(nullptr, mapAllocation); - mockCmdQ->kernelParams.mapAllocation = nullptr; + mockCmdQ->kernelParams.transferAllocation = nullptr; auto mapPtr = clEnqueueMapBuffer(mockCmdQ, bufferForBlt.get(), true, 0, 0, 1, 0, nullptr, nullptr, &retVal); EXPECT_EQ(CL_SUCCESS, retVal); - EXPECT_EQ(mapAllocation, mockCmdQ->kernelParams.mapAllocation); + EXPECT_EQ(mapAllocation, mockCmdQ->kernelParams.transferAllocation); - mockCmdQ->kernelParams.mapAllocation = nullptr; + mockCmdQ->kernelParams.transferAllocation = nullptr; retVal = clEnqueueUnmapMemObject(mockCmdQ, bufferForBlt.get(), mapPtr, 0, nullptr, nullptr); EXPECT_EQ(CL_SUCCESS, retVal); - EXPECT_EQ(mapAllocation, mockCmdQ->kernelParams.mapAllocation); + EXPECT_EQ(mapAllocation, mockCmdQ->kernelParams.transferAllocation); } HWTEST_TEMPLATED_F(BcsBufferTests, givenWriteBufferEnqueueWhenProgrammingCommandStreamThenAddSemaphoreWait) {