diff --git a/opencl/source/mem_obj/buffer.cpp b/opencl/source/mem_obj/buffer.cpp index c3e6a4814f..96be8ca301 100644 --- a/opencl/source/mem_obj/buffer.cpp +++ b/opencl/source/mem_obj/buffer.cpp @@ -49,7 +49,7 @@ Buffer::Buffer(Context *context, size_t size, void *memoryStorage, void *hostPtr, - MultiGraphicsAllocation multiGraphicsAllocation, + MultiGraphicsAllocation &&multiGraphicsAllocation, bool zeroCopy, bool isHostPtrSVM, bool isObjectRedescribed) @@ -310,7 +310,7 @@ Buffer *Buffer::create(Context *context, memoryManager->addAllocationToHostPtrManager(allocationInfo[rootDeviceIndex].memory); } - //if allocation failed for CL_MEM_USE_HOST_PTR case retry with non zero copy path + // if allocation failed for CL_MEM_USE_HOST_PTR case retry with non zero copy path if (memoryProperties.flags.useHostPtr && !allocationInfo[rootDeviceIndex].memory && Buffer::isReadOnlyMemoryPermittedByFlags(memoryProperties)) { allocationInfo[rootDeviceIndex].allocationType = AllocationType::BUFFER_HOST_MEMORY; allocationInfo[rootDeviceIndex].zeroCopyAllowed = false; @@ -535,10 +535,12 @@ Buffer *Buffer::createSubBuffer(cl_mem_flags flags, DEBUG_BREAK_IF(nullptr == createFunction); MemoryProperties memoryProperties = ClMemoryPropertiesHelper::createMemoryProperties(flags, flagsIntel, 0, &this->context->getDevice(0)->getDevice()); + + auto copyMultiGraphicsAllocation = MultiGraphicsAllocation{this->multiGraphicsAllocation}; auto buffer = createFunction(this->context, memoryProperties, flags, 0, region->size, ptrOffset(this->memoryStorage, region->origin), this->hostPtr ? ptrOffset(this->hostPtr, region->origin) : nullptr, - this->multiGraphicsAllocation, + std::move(copyMultiGraphicsAllocation), this->isZeroCopy, this->isHostPtrSVM, false); if (this->context->isProvidingPerformanceHints()) { @@ -652,12 +654,12 @@ bool Buffer::isReadWriteOnCpuAllowed(const Device &device) { bool Buffer::isReadWriteOnCpuPreferred(void *ptr, size_t size, const Device &device) { auto graphicsAllocation = multiGraphicsAllocation.getGraphicsAllocation(device.getRootDeviceIndex()); if (MemoryPoolHelper::isSystemMemoryPool(graphicsAllocation->getMemoryPool())) { - //if buffer is not zero copy and pointer is aligned it will be more beneficial to do the transfer on GPU + // if buffer is not zero copy and pointer is aligned it will be more beneficial to do the transfer on GPU if (!isMemObjZeroCopy() && (reinterpret_cast(ptr) & (MemoryConstants::cacheLineSize - 1)) == 0) { return false; } - //on low power devices larger transfers are better on the GPU + // on low power devices larger transfers are better on the GPU if (device.getSpecializedDevice()->getDeviceInfo().platformLP && size > maxBufferSizeForReadWriteOnCpu) { return false; } @@ -674,7 +676,7 @@ Buffer *Buffer::createBufferHw(Context *context, size_t size, void *memoryStorage, void *hostPtr, - MultiGraphicsAllocation multiGraphicsAllocation, + MultiGraphicsAllocation &&multiGraphicsAllocation, bool zeroCopy, bool isHostPtrSVM, bool isImageRedescribed) { @@ -698,7 +700,7 @@ Buffer *Buffer::createBufferHwFromDevice(const Device *device, size_t size, void *memoryStorage, void *hostPtr, - MultiGraphicsAllocation multiGraphicsAllocation, + MultiGraphicsAllocation &&multiGraphicsAllocation, size_t offset, bool zeroCopy, bool isHostPtrSVM, diff --git a/opencl/source/mem_obj/buffer.h b/opencl/source/mem_obj/buffer.h index 5dc32c5a1f..948d052bf8 100644 --- a/opencl/source/mem_obj/buffer.h +++ b/opencl/source/mem_obj/buffer.h @@ -33,7 +33,7 @@ using BufferCreatFunc = Buffer *(*)(Context *context, size_t size, void *memoryStorage, void *hostPtr, - MultiGraphicsAllocation multiGraphicsAllocation, + MultiGraphicsAllocation &&multiGraphicsAllocation, bool zeroCopy, bool isHostPtrSVM, bool isImageRedescribed); @@ -98,7 +98,7 @@ class Buffer : public MemObj { size_t size, void *memoryStorage, void *hostPtr, - MultiGraphicsAllocation multiGraphicsAllocation, + MultiGraphicsAllocation &&multiGraphicsAllocation, bool zeroCopy, bool isHostPtrSVM, bool isImageRedescribed); @@ -109,7 +109,7 @@ class Buffer : public MemObj { size_t size, void *memoryStorage, void *hostPtr, - MultiGraphicsAllocation multiGraphicsAllocation, + MultiGraphicsAllocation &&multiGraphicsAllocation, size_t offset, bool zeroCopy, bool isHostPtrSVM, @@ -173,7 +173,7 @@ class Buffer : public MemObj { size_t size, void *memoryStorage, void *hostPtr, - MultiGraphicsAllocation multiGraphicsAllocation, + MultiGraphicsAllocation &&multiGraphicsAllocation, bool zeroCopy, bool isHostPtrSVM, bool isObjectRedescribed); @@ -208,7 +208,7 @@ class BufferHw : public Buffer { size_t size, void *memoryStorage, void *hostPtr, - MultiGraphicsAllocation multiGraphicsAllocation, + MultiGraphicsAllocation &&multiGraphicsAllocation, bool zeroCopy, bool isHostPtrSVM, bool isObjectRedescribed) @@ -225,7 +225,7 @@ class BufferHw : public Buffer { size_t size, void *memoryStorage, void *hostPtr, - MultiGraphicsAllocation multiGraphicsAllocation, + MultiGraphicsAllocation &&multiGraphicsAllocation, bool zeroCopy, bool isHostPtrSVM, bool isObjectRedescribed) { diff --git a/opencl/source/mem_obj/mem_obj.cpp b/opencl/source/mem_obj/mem_obj.cpp index f279a28ebe..ce27f1b69a 100644 --- a/opencl/source/mem_obj/mem_obj.cpp +++ b/opencl/source/mem_obj/mem_obj.cpp @@ -35,7 +35,7 @@ MemObj::MemObj(Context *context, size_t size, void *memoryStorage, void *hostPtr, - MultiGraphicsAllocation multiGraphicsAllocation, + MultiGraphicsAllocation &&multiGraphicsAllocation, bool zeroCopy, bool isHostPtrSVM, bool isObjectRedescribed) diff --git a/opencl/source/mem_obj/mem_obj.h b/opencl/source/mem_obj/mem_obj.h index d63da3d7dc..8254a9ceb8 100644 --- a/opencl/source/mem_obj/mem_obj.h +++ b/opencl/source/mem_obj/mem_obj.h @@ -68,7 +68,7 @@ class MemObj : public BaseObject<_cl_mem> { size_t size, void *memoryStorage, void *hostPtr, - MultiGraphicsAllocation multiGraphicsAllocation, + MultiGraphicsAllocation &&multiGraphicsAllocation, bool zeroCopy, bool isHostPtrSVM, bool isObjectRedescrbied); diff --git a/opencl/test/unit_test/command_queue/multiple_map_buffer_tests.cpp b/opencl/test/unit_test/command_queue/multiple_map_buffer_tests.cpp index 33d6ce7fa0..a0cab41327 100644 --- a/opencl/test/unit_test/command_queue/multiple_map_buffer_tests.cpp +++ b/opencl/test/unit_test/command_queue/multiple_map_buffer_tests.cpp @@ -21,7 +21,7 @@ struct MultipleMapBufferTest : public ClDeviceFixture, public ::testing::Test { template struct MockBuffer : public BufferHw { template - MockBuffer(Params... params) : BufferHw(params...) { + MockBuffer(Params... params) : BufferHw(std::forward(params)...) { this->createFunction = BufferHw::create; }; @@ -92,9 +92,10 @@ struct MultipleMapBufferTest : public ClDeviceFixture, public ::testing::Test { std::unique_ptr> createMockBuffer(bool mapOnGpu) { MemoryProperties memoryProperties; auto mockAlloc = pDevice->getMemoryManager()->allocateGraphicsMemoryWithProperties(MockAllocationProperties{pDevice->getRootDeviceIndex(), MemoryConstants::pageSize}); + auto multiGraphicsAllocation = GraphicsAllocationHelper::toMultiGraphicsAllocation(mockAlloc); auto buffer = new MockBuffer(context, memoryProperties, 0, 0, 1024, mockAlloc->getUnderlyingBuffer(), mockAlloc->getUnderlyingBuffer(), - GraphicsAllocationHelper::toMultiGraphicsAllocation(mockAlloc), false, false, false); + std::move(multiGraphicsAllocation), false, false, false); if (mapOnGpu) { buffer->setSharingHandler(new SharingHandler()); auto gfxAllocation = buffer->getGraphicsAllocation(pDevice->getRootDeviceIndex()); diff --git a/opencl/test/unit_test/helpers/test_preamble_xehp_and_later.cpp b/opencl/test/unit_test/helpers/test_preamble_xehp_and_later.cpp index fdf99568bb..ea7d7dddb4 100644 --- a/opencl/test/unit_test/helpers/test_preamble_xehp_and_later.cpp +++ b/opencl/test/unit_test/helpers/test_preamble_xehp_and_later.cpp @@ -569,7 +569,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, RenderSurfaceStateXeHPAndLaterTests, givenSpecificP multiGraphicsAllocation.addAllocation(allocation); std::unique_ptr> buffer(static_cast *>( - BufferHw::create(&context, {}, 0, 0, allocationSize, nullptr, nullptr, multiGraphicsAllocation, false, false, false))); + BufferHw::create(&context, {}, 0, 0, allocationSize, nullptr, nullptr, std::move(multiGraphicsAllocation), false, false, false))); NEO::EncodeSurfaceStateArgs args; args.outMemory = &rssCmd; diff --git a/opencl/test/unit_test/mem_obj/buffer_tests.cpp b/opencl/test/unit_test/mem_obj/buffer_tests.cpp index 321e30bec7..19ba514fb2 100644 --- a/opencl/test/unit_test/mem_obj/buffer_tests.cpp +++ b/opencl/test/unit_test/mem_obj/buffer_tests.cpp @@ -908,7 +908,7 @@ TEST_P(NoHostPtr, GivenNoHostPtrWhenHwBufferCreationFailsThenReturnNullptr) { size_t, void *, void *, - MultiGraphicsAllocation, + MultiGraphicsAllocation &&, bool, bool, bool) @@ -1793,7 +1793,9 @@ HWTEST_F(BufferHwFromDeviceTests, givenMultiGraphicsAllocationWhenCreateBufferHw auto multiGraphicsAllocation = MultiGraphicsAllocation(device->getRootDeviceIndex()); multiGraphicsAllocation.addAllocation(&svmAlloc); - auto buffer = std::unique_ptr(Buffer::createBufferHwFromDevice(device.get(), 0, 0, size, ptr, ptr, multiGraphicsAllocation, 0, true, false, false)); + + auto copyMultiGraphicsAllocation = multiGraphicsAllocation; + auto buffer = std::unique_ptr(Buffer::createBufferHwFromDevice(device.get(), 0, 0, size, ptr, ptr, std::move(copyMultiGraphicsAllocation), 0, true, false, false)); EXPECT_EQ(device->getRootDeviceIndex(), 0u); EXPECT_EQ(buffer->getMultiGraphicsAllocation().getGraphicsAllocations().size(), multiGraphicsAllocation.getGraphicsAllocations().size()); diff --git a/opencl/test/unit_test/mem_obj/mem_obj_tests.cpp b/opencl/test/unit_test/mem_obj/mem_obj_tests.cpp index 425843067f..1f6e214270 100644 --- a/opencl/test/unit_test/mem_obj/mem_obj_tests.cpp +++ b/opencl/test/unit_test/mem_obj/mem_obj_tests.cpp @@ -531,7 +531,7 @@ TEST_F(MemObjMultiRootDeviceTests, WhenMemObjIsCreatedWithMultiGraphicsAllocatio auto memoryProperties = ClMemoryPropertiesHelper::createMemoryProperties(CL_MEM_READ_WRITE, 0, 0, &context->getDevice(0)->getDevice()); std::unique_ptr memObj( new MemObj(context.get(), CL_MEM_OBJECT_BUFFER, memoryProperties, CL_MEM_READ_WRITE, 0, - 1, nullptr, nullptr, multiGraphicsAllocation, true, false, false)); + 1, nullptr, nullptr, std::move(multiGraphicsAllocation), true, false, false)); EXPECT_NE(nullptr, memObj->getMultiGraphicsAllocation().getGraphicsAllocation(0)); EXPECT_NE(nullptr, memObj->getMultiGraphicsAllocation().getGraphicsAllocation(1)); @@ -552,7 +552,7 @@ TEST_F(MemObjMultiRootDeviceTests, WhenMemObjMapAreCreatedThenAllAllocationAreDe auto memoryProperties = ClMemoryPropertiesHelper::createMemoryProperties(CL_MEM_READ_WRITE, 0, 0, &context->getDevice(1)->getDevice()); std::unique_ptr memObj( new MemObj(context.get(), CL_MEM_OBJECT_BUFFER, memoryProperties, CL_MEM_READ_WRITE, 0, - 1, nullptr, nullptr, multiGraphicsAllocation, true, false, false)); + 1, nullptr, nullptr, std::move(multiGraphicsAllocation), true, false, false)); auto mapAllocation0 = memObj->getMapAllocation(2); auto mapAllocation1 = memObj->getMapAllocation(1); diff --git a/opencl/test/unit_test/xe_hpc_core/test_cmds_programming_xe_hpc_core.cpp b/opencl/test/unit_test/xe_hpc_core/test_cmds_programming_xe_hpc_core.cpp index c6c38417b2..7a587a2ec0 100644 --- a/opencl/test/unit_test/xe_hpc_core/test_cmds_programming_xe_hpc_core.cpp +++ b/opencl/test/unit_test/xe_hpc_core/test_cmds_programming_xe_hpc_core.cpp @@ -99,7 +99,7 @@ XE_HPC_CORETEST_F(CmdsProgrammingTestsXeHpcCore, whenAppendingRssThenProgramWtL1 multiGraphicsAllocation.addAllocation(allocation); std::unique_ptr> buffer(static_cast *>( - BufferHw::create(&context, {}, 0, 0, allocationSize, nullptr, nullptr, multiGraphicsAllocation, false, false, false))); + BufferHw::create(&context, {}, 0, 0, allocationSize, nullptr, nullptr, std::move(multiGraphicsAllocation), false, false, false))); NEO::EncodeSurfaceStateArgs args; args.outMemory = &rssCmd; diff --git a/opencl/test/unit_test/xe_hpg_core/dg2/test_cmds_programming_dg2.cpp b/opencl/test/unit_test/xe_hpg_core/dg2/test_cmds_programming_dg2.cpp index 9ce54b922b..e2e1427e69 100644 --- a/opencl/test/unit_test/xe_hpg_core/dg2/test_cmds_programming_dg2.cpp +++ b/opencl/test/unit_test/xe_hpg_core/dg2/test_cmds_programming_dg2.cpp @@ -100,7 +100,7 @@ DG2TEST_F(CmdsProgrammingTestsDg2, whenAppendingRssThenProgramWtL1CachePolicy) { multiGraphicsAllocation.addAllocation(allocation); std::unique_ptr> buffer(static_cast *>( - BufferHw::create(&context, {}, 0, 0, allocationSize, nullptr, nullptr, multiGraphicsAllocation, false, false, false))); + BufferHw::create(&context, {}, 0, 0, allocationSize, nullptr, nullptr, std::move(multiGraphicsAllocation), false, false, false))); NEO::EncodeSurfaceStateArgs args; args.outMemory = &rssCmd; diff --git a/opencl/test/unit_test/xe_hpg_core/test_cmds_programming_xe_hpg_core.cpp b/opencl/test/unit_test/xe_hpg_core/test_cmds_programming_xe_hpg_core.cpp index ac4a150878..1be36de9bf 100644 --- a/opencl/test/unit_test/xe_hpg_core/test_cmds_programming_xe_hpg_core.cpp +++ b/opencl/test/unit_test/xe_hpg_core/test_cmds_programming_xe_hpg_core.cpp @@ -102,7 +102,7 @@ XE_HPG_CORETEST_F(CmdsProgrammingTestsXeHpgCore, whenAppendingRssThenProgramWtL1 multiGraphicsAllocation.addAllocation(allocation); std::unique_ptr> buffer(static_cast *>( - BufferHw::create(&context, {}, 0, 0, allocationSize, nullptr, nullptr, multiGraphicsAllocation, false, false, false))); + BufferHw::create(&context, {}, 0, 0, allocationSize, nullptr, nullptr, std::move(multiGraphicsAllocation), false, false, false))); NEO::EncodeSurfaceStateArgs args; args.outMemory = &rssCmd;