From 76289be8c19702026a7b70f74f8b3d09fe9111fd Mon Sep 17 00:00:00 2001 From: Dominik Dabek Date: Tue, 5 Apr 2022 16:47:19 +0000 Subject: [PATCH] Avoid unnecessary allocation in enqueueHandler Related-To: NEO-6837 kernelObjsForAuxTranslation will allocate only if needed Signed-off-by: Dominik Dabek --- opencl/source/command_queue/enqueue_common.h | 22 ++--- opencl/source/helpers/dispatch_info.h | 8 +- opencl/source/kernel/kernel.cpp | 14 +-- opencl/source/kernel/kernel.h | 2 +- .../unit_test/built_ins/built_in_tests.cpp | 92 ++++++++++--------- .../command_queue_hw_1_tests.cpp | 8 +- .../command_queue/dispatch_walker_tests.cpp | 16 ++-- .../context/driver_diagnostics_tests.cpp | 24 ++--- .../kernel/kernel_arg_buffer_tests.cpp | 22 ++--- 9 files changed, 104 insertions(+), 104 deletions(-) diff --git a/opencl/source/command_queue/enqueue_common.h b/opencl/source/command_queue/enqueue_common.h index 2bb3d68855..5c33bbd39e 100644 --- a/opencl/source/command_queue/enqueue_common.h +++ b/opencl/source/command_queue/enqueue_common.h @@ -61,19 +61,19 @@ cl_int CommandQueueHw::enqueueHandler(Surface *(&surfaces)[surfaceCou const cl_event *eventWaitList, cl_event *event) { BuiltInOwnershipWrapper builtInLock; - KernelObjsForAuxTranslation kernelObjsForAuxTranslation; + std::unique_ptr kernelObjsForAuxTranslation; MultiDispatchInfo multiDispatchInfo(kernel); auto auxTranslationMode = AuxTranslationMode::None; kernel->updateAuxTranslationRequired(); if (kernel->isAuxTranslationRequired()) { - kernel->fillWithKernelObjsForAuxTranslation(kernelObjsForAuxTranslation); - multiDispatchInfo.setKernelObjsForAuxTranslation(kernelObjsForAuxTranslation); + kernelObjsForAuxTranslation = kernel->fillWithKernelObjsForAuxTranslation(); - if (!kernelObjsForAuxTranslation.empty()) { + if (!kernelObjsForAuxTranslation->empty()) { auxTranslationMode = HwHelperHw::get().getAuxTranslationMode(device->getHardwareInfo()); } + multiDispatchInfo.setKernelObjsForAuxTranslation(std::move(kernelObjsForAuxTranslation)); } if (AuxTranslationMode::Builtin == auxTranslationMode) { @@ -502,16 +502,16 @@ void CommandQueueHw::processDispatchForBlitAuxTranslation(CommandStre BlitPropertiesContainer &blitPropertiesContainer, TimestampPacketDependencies ×tampPacketDependencies, const EventsRequest &eventsRequest, bool queueBlocked) { - auto rootDeviceIndex = getDevice().getRootDeviceIndex(); - auto nodesAllocator = getGpgpuCommandStreamReceiver().getTimestampPacketAllocator(); - auto numKernelObjs = multiDispatchInfo.getKernelObjsForAuxTranslation()->size(); + const auto rootDeviceIndex = getDevice().getRootDeviceIndex(); + const auto nodesAllocator = getGpgpuCommandStreamReceiver().getTimestampPacketAllocator(); + const auto numKernelObjs = multiDispatchInfo.getKernelObjsForAuxTranslation()->size(); blitPropertiesContainer.resize(numKernelObjs * 2); auto bufferIndex = 0; - for (auto &kernelObj : *multiDispatchInfo.getKernelObjsForAuxTranslation()) { + for (const auto &kernelObj : *multiDispatchInfo.getKernelObjsForAuxTranslation()) { GraphicsAllocation *allocation = nullptr; if (kernelObj.type == KernelObjForAuxTranslation::Type::MEM_OBJ) { - auto buffer = static_cast(kernelObj.object); + const auto buffer = static_cast(kernelObj.object); allocation = buffer->getGraphicsAllocation(rootDeviceIndex); } else { DEBUG_BREAK_IF(kernelObj.type != KernelObjForAuxTranslation::Type::GFX_ALLOC); @@ -521,7 +521,7 @@ void CommandQueueHw::processDispatchForBlitAuxTranslation(CommandStre // Aux to NonAux blitPropertiesContainer[bufferIndex] = BlitProperties::constructPropertiesForAuxTranslation( AuxTranslationDirection::AuxToNonAux, allocation, getGpgpuCommandStreamReceiver().getClearColorAllocation()); - auto auxToNonAuxNode = nodesAllocator->getTag(); + const auto auxToNonAuxNode = nodesAllocator->getTag(); timestampPacketDependencies.auxToNonAuxNodes.add(auxToNonAuxNode); } @@ -529,7 +529,7 @@ void CommandQueueHw::processDispatchForBlitAuxTranslation(CommandStre // NonAux to Aux blitPropertiesContainer[bufferIndex + numKernelObjs] = BlitProperties::constructPropertiesForAuxTranslation( AuxTranslationDirection::NonAuxToAux, allocation, getGpgpuCommandStreamReceiver().getClearColorAllocation()); - auto nonAuxToAuxNode = nodesAllocator->getTag(); + const auto nonAuxToAuxNode = nodesAllocator->getTag(); timestampPacketDependencies.nonAuxToAuxNodes.add(nonAuxToAuxNode); } bufferIndex++; diff --git a/opencl/source/helpers/dispatch_info.h b/opencl/source/helpers/dispatch_info.h index 0dd1be958e..0271f774e5 100644 --- a/opencl/source/helpers/dispatch_info.h +++ b/opencl/source/helpers/dispatch_info.h @@ -197,19 +197,19 @@ struct MultiDispatchInfo { return builtinOpParams; } - void setKernelObjsForAuxTranslation(const KernelObjsForAuxTranslation &kernelObjsForAuxTranslation) { - this->kernelObjsForAuxTranslation = &kernelObjsForAuxTranslation; + void setKernelObjsForAuxTranslation(std::unique_ptr &&kernelObjsForAuxTranslation) { + this->kernelObjsForAuxTranslation = std::move(kernelObjsForAuxTranslation); } const KernelObjsForAuxTranslation *getKernelObjsForAuxTranslation() const { - return kernelObjsForAuxTranslation; + return kernelObjsForAuxTranslation.get(); } protected: BuiltinOpParams builtinOpParams = {}; StackVec dispatchInfos; StackVec redescribedSurfaces; - const KernelObjsForAuxTranslation *kernelObjsForAuxTranslation = nullptr; + std::unique_ptr kernelObjsForAuxTranslation; Kernel *mainKernel = nullptr; }; } // namespace NEO diff --git a/opencl/source/kernel/kernel.cpp b/opencl/source/kernel/kernel.cpp index 1f55072720..22e5e25384 100644 --- a/opencl/source/kernel/kernel.cpp +++ b/opencl/source/kernel/kernel.cpp @@ -1858,14 +1858,15 @@ bool Kernel::canTransformImages() const { return renderCoreFamily >= IGFX_GEN9_CORE && renderCoreFamily <= IGFX_GEN11LP_CORE && !isBuiltIn; } -void Kernel::fillWithKernelObjsForAuxTranslation(KernelObjsForAuxTranslation &kernelObjsForAuxTranslation) { - kernelObjsForAuxTranslation.reserve(getKernelArgsNumber()); +std::unique_ptr Kernel::fillWithKernelObjsForAuxTranslation() { + auto kernelObjsForAuxTranslation = std::make_unique(); + kernelObjsForAuxTranslation->reserve(getKernelArgsNumber()); for (uint32_t i = 0; i < getKernelArgsNumber(); i++) { const auto &arg = kernelInfo.kernelDescriptor.payloadMappings.explicitArgs[i]; if (BUFFER_OBJ == kernelArguments.at(i).type && !arg.as().isPureStateful()) { auto buffer = castToObject(getKernelArg(i)); if (buffer && buffer->getMultiGraphicsAllocation().getDefaultGraphicsAllocation()->isCompressionEnabled()) { - kernelObjsForAuxTranslation.insert({KernelObjForAuxTranslation::Type::MEM_OBJ, buffer}); + kernelObjsForAuxTranslation->insert({KernelObjForAuxTranslation::Type::MEM_OBJ, buffer}); auto &context = this->program->getContext(); if (context.isProvidingPerformanceHints()) { const auto &argExtMeta = kernelInfo.kernelDescriptor.explicitArgsExtendedMetadata[i]; @@ -1877,7 +1878,7 @@ void Kernel::fillWithKernelObjsForAuxTranslation(KernelObjsForAuxTranslation &ke if (SVM_ALLOC_OBJ == getKernelArguments().at(i).type && !arg.as().isPureStateful()) { auto svmAlloc = reinterpret_cast(const_cast(getKernelArg(i))); if (svmAlloc && svmAlloc->isCompressionEnabled()) { - kernelObjsForAuxTranslation.insert({KernelObjForAuxTranslation::Type::GFX_ALLOC, svmAlloc}); + kernelObjsForAuxTranslation->insert({KernelObjForAuxTranslation::Type::GFX_ALLOC, svmAlloc}); auto &context = this->program->getContext(); if (context.isProvidingPerformanceHints()) { const auto &argExtMeta = kernelInfo.kernelDescriptor.explicitArgsExtendedMetadata[i]; @@ -1891,7 +1892,7 @@ void Kernel::fillWithKernelObjsForAuxTranslation(KernelObjsForAuxTranslation &ke if (hwInfoConfig.allowStatelessCompression(getDevice().getHardwareInfo())) { for (auto gfxAllocation : kernelUnifiedMemoryGfxAllocations) { if (gfxAllocation->isCompressionEnabled()) { - kernelObjsForAuxTranslation.insert({KernelObjForAuxTranslation::Type::GFX_ALLOC, gfxAllocation}); + kernelObjsForAuxTranslation->insert({KernelObjForAuxTranslation::Type::GFX_ALLOC, gfxAllocation}); auto &context = this->program->getContext(); if (context.isProvidingPerformanceHints()) { context.providePerformanceHint(CL_CONTEXT_DIAGNOSTICS_LEVEL_BAD_INTEL, KERNEL_ALLOCATION_AUX_TRANSLATION, @@ -1904,7 +1905,7 @@ void Kernel::fillWithKernelObjsForAuxTranslation(KernelObjsForAuxTranslation &ke for (auto &allocation : getContext().getSVMAllocsManager()->getSVMAllocs()->allocations) { auto gfxAllocation = allocation.second.gpuAllocations.getDefaultGraphicsAllocation(); if (gfxAllocation->isCompressionEnabled()) { - kernelObjsForAuxTranslation.insert({KernelObjForAuxTranslation::Type::GFX_ALLOC, gfxAllocation}); + kernelObjsForAuxTranslation->insert({KernelObjForAuxTranslation::Type::GFX_ALLOC, gfxAllocation}); auto &context = this->program->getContext(); if (context.isProvidingPerformanceHints()) { context.providePerformanceHint(CL_CONTEXT_DIAGNOSTICS_LEVEL_BAD_INTEL, KERNEL_ALLOCATION_AUX_TRANSLATION, @@ -1915,6 +1916,7 @@ void Kernel::fillWithKernelObjsForAuxTranslation(KernelObjsForAuxTranslation &ke } } } + return kernelObjsForAuxTranslation; } bool Kernel::hasDirectStatelessAccessToSharedBuffer() const { diff --git a/opencl/source/kernel/kernel.h b/opencl/source/kernel/kernel.h index 5790117ea0..4f9e7826ed 100644 --- a/opencl/source/kernel/kernel.h +++ b/opencl/source/kernel/kernel.h @@ -332,7 +332,7 @@ class Kernel : public ReferenceTrackedObject { return usingImagesOnly; } - void fillWithKernelObjsForAuxTranslation(KernelObjsForAuxTranslation &kernelObjsForAuxTranslation); + std::unique_ptr fillWithKernelObjsForAuxTranslation(); MOCKABLE_VIRTUAL bool requiresCacheFlushCommand(const CommandQueue &commandQueue) const; diff --git a/opencl/test/unit_test/built_ins/built_in_tests.cpp b/opencl/test/unit_test/built_ins/built_in_tests.cpp index 377bbd1c6c..717d05709a 100644 --- a/opencl/test/unit_test/built_ins/built_in_tests.cpp +++ b/opencl/test/unit_test/built_ins/built_in_tests.cpp @@ -258,9 +258,6 @@ HWTEST2_P(AuxBuiltInTests, givenInputBufferWhenBuildingNonAuxDispatchInfoForAuxT BuiltinDispatchInfoBuilder &baseBuilder = BuiltInDispatchBuilderOp::getBuiltinDispatchInfoBuilder(EBuiltInOps::AuxTranslation, *pClDevice); auto &builder = static_cast &>(baseBuilder); - KernelObjsForAuxTranslation kernelObjsForAuxTranslation; - MultiDispatchInfo multiDispatchInfo; - multiDispatchInfo.setKernelObjsForAuxTranslation(kernelObjsForAuxTranslation); std::vector builtinKernels; std::vector mockKernelObjForAuxTranslation; mockKernelObjForAuxTranslation.push_back(MockKernelObjForAuxTranslation(kernelObjType, 0x1000)); @@ -270,9 +267,14 @@ HWTEST2_P(AuxBuiltInTests, givenInputBufferWhenBuildingNonAuxDispatchInfoForAuxT BuiltinOpParams builtinOpsParams; builtinOpsParams.auxTranslationDirection = AuxTranslationDirection::AuxToNonAux; + auto kernelObjsForAuxTranslation = std::make_unique(); for (auto &kernelObj : mockKernelObjForAuxTranslation) { - kernelObjsForAuxTranslation.insert(kernelObj); + kernelObjsForAuxTranslation->insert(kernelObj); } + auto kernelObjsForAuxTranslationPtr = kernelObjsForAuxTranslation.get(); + + MultiDispatchInfo multiDispatchInfo; + multiDispatchInfo.setKernelObjsForAuxTranslation(std::move(kernelObjsForAuxTranslation)); EXPECT_TRUE(builder.buildDispatchInfosForAuxTranslation(multiDispatchInfo, builtinOpsParams)); EXPECT_EQ(3u, multiDispatchInfo.size()); @@ -283,10 +285,10 @@ HWTEST2_P(AuxBuiltInTests, givenInputBufferWhenBuildingNonAuxDispatchInfoForAuxT if (kernelObjType == KernelObjForAuxTranslation::Type::MEM_OBJ) { auto buffer = castToObject(kernel->getKernelArguments().at(0).object); - auto kernelObj = *kernelObjsForAuxTranslation.find({KernelObjForAuxTranslation::Type::MEM_OBJ, buffer}); + auto kernelObj = *kernelObjsForAuxTranslationPtr->find({KernelObjForAuxTranslation::Type::MEM_OBJ, buffer}); EXPECT_NE(nullptr, kernelObj.object); EXPECT_EQ(KernelObjForAuxTranslation::Type::MEM_OBJ, kernelObj.type); - kernelObjsForAuxTranslation.erase(kernelObj); + kernelObjsForAuxTranslationPtr->erase(kernelObj); cl_mem clMem = buffer; EXPECT_EQ(clMem, kernel->getKernelArguments().at(0).object); @@ -298,10 +300,10 @@ HWTEST2_P(AuxBuiltInTests, givenInputBufferWhenBuildingNonAuxDispatchInfoForAuxT EXPECT_EQ(gws, dispatchInfo.getGWS()); } else { auto gfxAllocation = static_cast(kernel->getKernelArguments().at(0).object); - auto kernelObj = *kernelObjsForAuxTranslation.find({KernelObjForAuxTranslation::Type::GFX_ALLOC, gfxAllocation}); + auto kernelObj = *kernelObjsForAuxTranslationPtr->find({KernelObjForAuxTranslation::Type::GFX_ALLOC, gfxAllocation}); EXPECT_NE(nullptr, kernelObj.object); EXPECT_EQ(KernelObjForAuxTranslation::Type::GFX_ALLOC, kernelObj.type); - kernelObjsForAuxTranslation.erase(kernelObj); + kernelObjsForAuxTranslationPtr->erase(kernelObj); EXPECT_EQ(gfxAllocation, kernel->getKernelArguments().at(0).object); EXPECT_EQ(gfxAllocation, kernel->getKernelArguments().at(1).object); @@ -324,9 +326,6 @@ HWTEST2_P(AuxBuiltInTests, givenInputBufferWhenBuildingAuxDispatchInfoForAuxTran BuiltinDispatchInfoBuilder &baseBuilder = BuiltInDispatchBuilderOp::getBuiltinDispatchInfoBuilder(EBuiltInOps::AuxTranslation, *pClDevice); auto &builder = static_cast &>(baseBuilder); - KernelObjsForAuxTranslation kernelObjsForAuxTranslation; - MultiDispatchInfo multiDispatchInfo; - multiDispatchInfo.setKernelObjsForAuxTranslation(kernelObjsForAuxTranslation); std::vector builtinKernels; std::vector mockKernelObjForAuxTranslation; mockKernelObjForAuxTranslation.push_back(MockKernelObjForAuxTranslation(kernelObjType, 0x1000)); @@ -336,9 +335,13 @@ HWTEST2_P(AuxBuiltInTests, givenInputBufferWhenBuildingAuxDispatchInfoForAuxTran BuiltinOpParams builtinOpsParams; builtinOpsParams.auxTranslationDirection = AuxTranslationDirection::NonAuxToAux; + auto kernelObjsForAuxTranslation = std::make_unique(); + auto kernelObjsForAuxTranslationPtr = kernelObjsForAuxTranslation.get(); for (auto &kernelObj : mockKernelObjForAuxTranslation) { - kernelObjsForAuxTranslation.insert(kernelObj); + kernelObjsForAuxTranslation->insert(kernelObj); } + MultiDispatchInfo multiDispatchInfo; + multiDispatchInfo.setKernelObjsForAuxTranslation(std::move(kernelObjsForAuxTranslation)); EXPECT_TRUE(builder.buildDispatchInfosForAuxTranslation(multiDispatchInfo, builtinOpsParams)); EXPECT_EQ(3u, multiDispatchInfo.size()); @@ -349,10 +352,10 @@ HWTEST2_P(AuxBuiltInTests, givenInputBufferWhenBuildingAuxDispatchInfoForAuxTran if (kernelObjType == KernelObjForAuxTranslation::Type::MEM_OBJ) { auto buffer = castToObject(kernel->getKernelArguments().at(0).object); - auto kernelObj = *kernelObjsForAuxTranslation.find({KernelObjForAuxTranslation::Type::MEM_OBJ, buffer}); + auto kernelObj = *kernelObjsForAuxTranslationPtr->find({KernelObjForAuxTranslation::Type::MEM_OBJ, buffer}); EXPECT_NE(nullptr, kernelObj.object); EXPECT_EQ(KernelObjForAuxTranslation::Type::MEM_OBJ, kernelObj.type); - kernelObjsForAuxTranslation.erase(kernelObj); + kernelObjsForAuxTranslationPtr->erase(kernelObj); cl_mem clMem = buffer; EXPECT_EQ(clMem, kernel->getKernelArguments().at(0).object); @@ -364,10 +367,10 @@ HWTEST2_P(AuxBuiltInTests, givenInputBufferWhenBuildingAuxDispatchInfoForAuxTran EXPECT_EQ(gws, dispatchInfo.getGWS()); } else { auto gfxAllocation = static_cast(kernel->getKernelArguments().at(0).object); - auto kernelObj = *kernelObjsForAuxTranslation.find({KernelObjForAuxTranslation::Type::GFX_ALLOC, gfxAllocation}); + auto kernelObj = *kernelObjsForAuxTranslationPtr->find({KernelObjForAuxTranslation::Type::GFX_ALLOC, gfxAllocation}); EXPECT_NE(nullptr, kernelObj.object); EXPECT_EQ(KernelObjForAuxTranslation::Type::GFX_ALLOC, kernelObj.type); - kernelObjsForAuxTranslation.erase(kernelObj); + kernelObjsForAuxTranslationPtr->erase(kernelObj); EXPECT_EQ(gfxAllocation, kernel->getKernelArguments().at(0).object); EXPECT_EQ(gfxAllocation, kernel->getKernelArguments().at(1).object); @@ -390,20 +393,20 @@ HWTEST2_P(AuxBuiltInTests, givenInputBufferWhenBuildingAuxTranslationDispatchThe BuiltinDispatchInfoBuilder &baseBuilder = BuiltInDispatchBuilderOp::getBuiltinDispatchInfoBuilder(EBuiltInOps::AuxTranslation, *pClDevice); auto &builder = static_cast &>(baseBuilder); - KernelObjsForAuxTranslation kernelObjsForAuxTranslation; std::vector mockKernelObjForAuxTranslation; for (int i = 0; i < 3; i++) { mockKernelObjForAuxTranslation.push_back(MockKernelObjForAuxTranslation(kernelObjType)); } std::vector builtinKernels; - MultiDispatchInfo multiDispatchInfo; - multiDispatchInfo.setKernelObjsForAuxTranslation(kernelObjsForAuxTranslation); BuiltinOpParams builtinOpsParams; + auto kernelObjsForAuxTranslation = std::make_unique(); for (auto &kernelObj : mockKernelObjForAuxTranslation) { - kernelObjsForAuxTranslation.insert(kernelObj); + kernelObjsForAuxTranslation->insert(kernelObj); } + MultiDispatchInfo multiDispatchInfo; + multiDispatchInfo.setKernelObjsForAuxTranslation(std::move(kernelObjsForAuxTranslation)); builtinOpsParams.auxTranslationDirection = AuxTranslationDirection::AuxToNonAux; EXPECT_TRUE(builder.buildDispatchInfosForAuxTranslation(multiDispatchInfo, builtinOpsParams)); @@ -428,14 +431,15 @@ HWTEST2_P(AuxBuiltInTests, givenInvalidAuxTranslationDirectionWhenBuildingDispat BuiltinDispatchInfoBuilder &baseBuilder = BuiltInDispatchBuilderOp::getBuiltinDispatchInfoBuilder(EBuiltInOps::AuxTranslation, *pClDevice); auto &builder = static_cast &>(baseBuilder); - KernelObjsForAuxTranslation kernelObjsForAuxTranslation; + auto kernelObjsForAuxTranslation = std::make_unique(); + auto kernelObjsForAuxTranslationPtr = kernelObjsForAuxTranslation.get(); MockKernelObjForAuxTranslation mockKernelObjForAuxTranslation(kernelObjType); MultiDispatchInfo multiDispatchInfo; - multiDispatchInfo.setKernelObjsForAuxTranslation(kernelObjsForAuxTranslation); + multiDispatchInfo.setKernelObjsForAuxTranslation(std::move(kernelObjsForAuxTranslation)); BuiltinOpParams builtinOpsParams; - kernelObjsForAuxTranslation.insert(mockKernelObjForAuxTranslation); + kernelObjsForAuxTranslationPtr->insert(mockKernelObjForAuxTranslation); builtinOpsParams.auxTranslationDirection = AuxTranslationDirection::None; EXPECT_THROW(builder.buildDispatchInfosForAuxTranslation(multiDispatchInfo, builtinOpsParams), std::exception); @@ -465,20 +469,20 @@ HWTEST2_P(AuxBuiltInTests, givenMoreKernelObjectsForAuxTranslationThanKernelInst EXPECT_EQ(5u, mockAuxBuiltInOp.convertToAuxKernel.size()); EXPECT_EQ(5u, mockAuxBuiltInOp.convertToNonAuxKernel.size()); - KernelObjsForAuxTranslation kernelObjsForAuxTranslation; - BuiltinOpParams builtinOpsParams; - MultiDispatchInfo multiDispatchInfo; - multiDispatchInfo.setKernelObjsForAuxTranslation(kernelObjsForAuxTranslation); std::vector mockKernelObjForAuxTranslation; for (int i = 0; i < 7; i++) { mockKernelObjForAuxTranslation.push_back(MockKernelObjForAuxTranslation(kernelObjType)); } + BuiltinOpParams builtinOpsParams; builtinOpsParams.auxTranslationDirection = AuxTranslationDirection::AuxToNonAux; + auto kernelObjsForAuxTranslation = std::make_unique(); for (auto &kernelObj : mockKernelObjForAuxTranslation) { - kernelObjsForAuxTranslation.insert(kernelObj); + kernelObjsForAuxTranslation->insert(kernelObj); } + MultiDispatchInfo multiDispatchInfo; + multiDispatchInfo.setKernelObjsForAuxTranslation(std::move(kernelObjsForAuxTranslation)); EXPECT_TRUE(mockAuxBuiltInOp.buildDispatchInfosForAuxTranslation(multiDispatchInfo, builtinOpsParams)); EXPECT_EQ(7u, mockAuxBuiltInOp.convertToAuxKernel.size()); @@ -558,9 +562,6 @@ HWCMDTEST_P(IGFX_GEN8_CORE, AuxBuiltInTests, givenAuxTranslationKernelWhenSettin using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE; MockAuxBuilInOp mockAuxBuiltInOp(*pBuiltIns, *pClDevice); - MultiDispatchInfo multiDispatchInfo; - KernelObjsForAuxTranslation kernelObjsForAuxTranslation; - multiDispatchInfo.setKernelObjsForAuxTranslation(kernelObjsForAuxTranslation); BuiltinOpParams builtinOpParamsToAux; builtinOpParamsToAux.auxTranslationDirection = AuxTranslationDirection::NonAuxToAux; @@ -571,15 +572,20 @@ HWCMDTEST_P(IGFX_GEN8_CORE, AuxBuiltInTests, givenAuxTranslationKernelWhenSettin std::unique_ptr buffer = nullptr; std::unique_ptr gfxAllocation = nullptr; + auto kernelObjsForAuxTranslation = std::make_unique(); + if (kernelObjType == MockKernelObjForAuxTranslation::Type::MEM_OBJ) { cl_int retVal = CL_SUCCESS; buffer.reset(Buffer::create(pContext, 0, MemoryConstants::pageSize, nullptr, retVal)); - kernelObjsForAuxTranslation.insert({KernelObjForAuxTranslation::Type::MEM_OBJ, buffer.get()}); + kernelObjsForAuxTranslation->insert({KernelObjForAuxTranslation::Type::MEM_OBJ, buffer.get()}); } else { gfxAllocation.reset(new MockGraphicsAllocation(nullptr, MemoryConstants::pageSize)); - kernelObjsForAuxTranslation.insert({KernelObjForAuxTranslation::Type::GFX_ALLOC, gfxAllocation.get()}); + kernelObjsForAuxTranslation->insert({KernelObjForAuxTranslation::Type::GFX_ALLOC, gfxAllocation.get()}); } + MultiDispatchInfo multiDispatchInfo; + multiDispatchInfo.setKernelObjsForAuxTranslation(std::move(kernelObjsForAuxTranslation)); + mockAuxBuiltInOp.buildDispatchInfosForAuxTranslation(multiDispatchInfo, builtinOpParamsToAux); mockAuxBuiltInOp.buildDispatchInfosForAuxTranslation(multiDispatchInfo, builtinOpParamsToNonAux); @@ -624,9 +630,6 @@ HWTEST2_P(AuxBuiltInTests, givenAuxToNonAuxTranslationWhenSettingSurfaceStateThe using AUXILIARY_SURFACE_MODE = typename RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE; MockAuxBuilInOp mockAuxBuiltInOp(*pBuiltIns, *pClDevice); - MultiDispatchInfo multiDispatchInfo; - KernelObjsForAuxTranslation kernelObjsForAuxTranslation; - multiDispatchInfo.setKernelObjsForAuxTranslation(kernelObjsForAuxTranslation); BuiltinOpParams builtinOpParams; builtinOpParams.auxTranslationDirection = AuxTranslationDirection::AuxToNonAux; @@ -637,19 +640,22 @@ HWTEST2_P(AuxBuiltInTests, givenAuxToNonAuxTranslationWhenSettingSurfaceStateThe auto gmm = std::unique_ptr(new Gmm(pDevice->getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true)); gmm->isCompressionEnabled = true; + auto kernelObjsForAuxTranslation = std::make_unique(); + if (kernelObjType == MockKernelObjForAuxTranslation::Type::MEM_OBJ) { cl_int retVal = CL_SUCCESS; buffer.reset(Buffer::create(pContext, 0, MemoryConstants::pageSize, nullptr, retVal)); buffer->getGraphicsAllocation(pClDevice->getRootDeviceIndex())->setDefaultGmm(gmm.release()); - kernelObjsForAuxTranslation.insert({KernelObjForAuxTranslation::Type::MEM_OBJ, buffer.get()}); + kernelObjsForAuxTranslation->insert({KernelObjForAuxTranslation::Type::MEM_OBJ, buffer.get()}); } else { gfxAllocation.reset(new MockGraphicsAllocation(nullptr, MemoryConstants::pageSize)); gfxAllocation->setDefaultGmm(gmm.get()); - kernelObjsForAuxTranslation.insert({KernelObjForAuxTranslation::Type::GFX_ALLOC, gfxAllocation.get()}); + kernelObjsForAuxTranslation->insert({KernelObjForAuxTranslation::Type::GFX_ALLOC, gfxAllocation.get()}); } - + MultiDispatchInfo multiDispatchInfo; + multiDispatchInfo.setKernelObjsForAuxTranslation(std::move(kernelObjsForAuxTranslation)); mockAuxBuiltInOp.buildDispatchInfosForAuxTranslation(multiDispatchInfo, builtinOpParams); { @@ -681,9 +687,6 @@ HWTEST2_P(AuxBuiltInTests, givenNonAuxToAuxTranslationWhenSettingSurfaceStateThe using AUXILIARY_SURFACE_MODE = typename RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE; MockAuxBuilInOp mockAuxBuiltInOp(*pBuiltIns, *pClDevice); - MultiDispatchInfo multiDispatchInfo; - KernelObjsForAuxTranslation kernelObjsForAuxTranslation; - multiDispatchInfo.setKernelObjsForAuxTranslation(kernelObjsForAuxTranslation); BuiltinOpParams builtinOpParams; builtinOpParams.auxTranslationDirection = AuxTranslationDirection::NonAuxToAux; @@ -696,8 +699,11 @@ HWTEST2_P(AuxBuiltInTests, givenNonAuxToAuxTranslationWhenSettingSurfaceStateThe } else { mockKernelObjForAuxTranslation.mockGraphicsAllocation->setDefaultGmm(gmm.get()); } - kernelObjsForAuxTranslation.insert(mockKernelObjForAuxTranslation); + auto kernelObjsForAuxTranslation = std::make_unique(); + kernelObjsForAuxTranslation->insert(mockKernelObjForAuxTranslation); + MultiDispatchInfo multiDispatchInfo; + multiDispatchInfo.setKernelObjsForAuxTranslation(std::move(kernelObjsForAuxTranslation)); mockAuxBuiltInOp.buildDispatchInfosForAuxTranslation(multiDispatchInfo, builtinOpParams); { diff --git a/opencl/test/unit_test/command_queue/command_queue_hw_1_tests.cpp b/opencl/test/unit_test/command_queue/command_queue_hw_1_tests.cpp index fcc178e41d..e6f6ae1147 100644 --- a/opencl/test/unit_test/command_queue/command_queue_hw_1_tests.cpp +++ b/opencl/test/unit_test/command_queue/command_queue_hw_1_tests.cpp @@ -106,7 +106,7 @@ HWTEST_F(CommandQueueHwTest, WhenConstructingCommandQueueDebugOnButIgcDoesNotRet HWTEST_F(CommandQueueHwTest, givenMultiDispatchInfoWhenAskingForAuxTranslationThenCheckMemObjectsCountAndDebugFlag) { DebugManagerStateRestore restore; MockBuffer buffer; - KernelObjsForAuxTranslation kernelObjects; + auto emptyKernelObjsForAuxTranslation = std::make_unique(); MultiDispatchInfo multiDispatchInfo; HardwareInfo *hwInfo = pClDevice->getExecutionEnvironment()->rootDeviceEnvironments[0]->getMutableHardwareInfo(); @@ -118,10 +118,12 @@ HWTEST_F(CommandQueueHwTest, givenMultiDispatchInfoWhenAskingForAuxTranslationTh EXPECT_FALSE(mockCmdQueueHw.isBlitAuxTranslationRequired(multiDispatchInfo)); - multiDispatchInfo.setKernelObjsForAuxTranslation(kernelObjects); + multiDispatchInfo.setKernelObjsForAuxTranslation(std::move(emptyKernelObjsForAuxTranslation)); EXPECT_FALSE(mockCmdQueueHw.isBlitAuxTranslationRequired(multiDispatchInfo)); - kernelObjects.insert({KernelObjForAuxTranslation::Type::MEM_OBJ, &buffer}); + auto kernelObjsForAuxTranslation = std::make_unique(); + kernelObjsForAuxTranslation->insert({KernelObjForAuxTranslation::Type::MEM_OBJ, &buffer}); + multiDispatchInfo.setKernelObjsForAuxTranslation(std::move(kernelObjsForAuxTranslation)); EXPECT_TRUE(mockCmdQueueHw.isBlitAuxTranslationRequired(multiDispatchInfo)); hwInfo->capabilityTable.blitterOperationsSupported = false; diff --git a/opencl/test/unit_test/command_queue/dispatch_walker_tests.cpp b/opencl/test/unit_test/command_queue/dispatch_walker_tests.cpp index bb6c2c8fa3..6c7b044368 100644 --- a/opencl/test/unit_test/command_queue/dispatch_walker_tests.cpp +++ b/opencl/test/unit_test/command_queue/dispatch_walker_tests.cpp @@ -1336,11 +1336,11 @@ HWTEST_P(DispatchWalkerTestForAuxTranslation, givenKernelWhenAuxToNonAuxWhenTran MockKernelObjForAuxTranslation mockKernelObj1(kernelObjType); MockKernelObjForAuxTranslation mockKernelObj2(kernelObjType); + auto kernelObjsForAuxTranslation = std::make_unique(); + kernelObjsForAuxTranslation->insert(mockKernelObj1); + kernelObjsForAuxTranslation->insert(mockKernelObj2); MultiDispatchInfo multiDispatchInfo; - KernelObjsForAuxTranslation kernelObjsForAuxTranslation; - multiDispatchInfo.setKernelObjsForAuxTranslation(kernelObjsForAuxTranslation); - kernelObjsForAuxTranslation.insert(mockKernelObj1); - kernelObjsForAuxTranslation.insert(mockKernelObj2); + multiDispatchInfo.setKernelObjsForAuxTranslation(std::move(kernelObjsForAuxTranslation)); BuiltinOpParams builtinOpsParams; builtinOpsParams.auxTranslationDirection = AuxTranslationDirection::AuxToNonAux; @@ -1390,11 +1390,11 @@ HWTEST_P(DispatchWalkerTestForAuxTranslation, givenKernelWhenNonAuxToAuxWhenTran MockKernelObjForAuxTranslation mockKernelObj1(kernelObjType); MockKernelObjForAuxTranslation mockKernelObj2(kernelObjType); + auto kernelObjsForAuxTranslation = std::make_unique(); + kernelObjsForAuxTranslation->insert(mockKernelObj1); + kernelObjsForAuxTranslation->insert(mockKernelObj2); MultiDispatchInfo multiDispatchInfo; - KernelObjsForAuxTranslation kernelObjsForAuxTranslation; - multiDispatchInfo.setKernelObjsForAuxTranslation(kernelObjsForAuxTranslation); - kernelObjsForAuxTranslation.insert(mockKernelObj1); - kernelObjsForAuxTranslation.insert(mockKernelObj2); + multiDispatchInfo.setKernelObjsForAuxTranslation(std::move(kernelObjsForAuxTranslation)); BuiltinOpParams builtinOpsParams; builtinOpsParams.auxTranslationDirection = AuxTranslationDirection::NonAuxToAux; diff --git a/opencl/test/unit_test/context/driver_diagnostics_tests.cpp b/opencl/test/unit_test/context/driver_diagnostics_tests.cpp index b69cb799f7..0f6dfc7146 100644 --- a/opencl/test/unit_test/context/driver_diagnostics_tests.cpp +++ b/opencl/test/unit_test/context/driver_diagnostics_tests.cpp @@ -448,8 +448,7 @@ TEST_F(PerformanceHintTest, givenPrintDriverDiagnosticsDebugModeEnabledWhenCallF mockKernel.mockKernel->setArgBuffer(0, sizeof(cl_mem *), &clMem); testing::internal::CaptureStdout(); - KernelObjsForAuxTranslation kernelObjects; - mockKernel.mockKernel->fillWithKernelObjsForAuxTranslation(kernelObjects); + auto kernelObjects = mockKernel.mockKernel->fillWithKernelObjsForAuxTranslation(); snprintf(expectedHint, DriverDiagnostics::maxHintStringSize, DriverDiagnostics::hintFormat[KERNEL_ARGUMENT_AUX_TRANSLATION], mockKernel.mockKernel->getKernelInfo().kernelDescriptor.kernelMetadata.kernelName.c_str(), 0, mockKernel.mockKernel->getKernelInfo().getExtendedMetadata(0).argName.c_str()); @@ -479,8 +478,7 @@ TEST_F(PerformanceHintTest, givenPrintDriverDiagnosticsDebugModeEnabledWhenCallF mockKernel.mockKernel->setArgSvmAlloc(0, ptr, &gfxAllocation, 0u); testing::internal::CaptureStdout(); - KernelObjsForAuxTranslation kernelObjects; - mockKernel.mockKernel->fillWithKernelObjsForAuxTranslation(kernelObjects); + auto kernelObjects = mockKernel.mockKernel->fillWithKernelObjsForAuxTranslation(); snprintf(expectedHint, DriverDiagnostics::maxHintStringSize, DriverDiagnostics::hintFormat[KERNEL_ARGUMENT_AUX_TRANSLATION], mockKernel.mockKernel->getKernelInfo().kernelDescriptor.kernelMetadata.kernelName.c_str(), 0, mockKernel.mockKernel->getKernelInfo().getExtendedMetadata(0).argName.c_str()); @@ -509,8 +507,7 @@ TEST_F(PerformanceHintTest, givenPrintDriverDiagnosticsDebugModeEnabledWhenCallF mockKernel.mockKernel->setUnifiedMemoryExecInfo(&gfxAllocation); testing::internal::CaptureStdout(); - KernelObjsForAuxTranslation kernelObjects; - mockKernel.mockKernel->fillWithKernelObjsForAuxTranslation(kernelObjects); + auto kernelObjects = mockKernel.mockKernel->fillWithKernelObjsForAuxTranslation(); snprintf(expectedHint, DriverDiagnostics::maxHintStringSize, DriverDiagnostics::hintFormat[KERNEL_ALLOCATION_AUX_TRANSLATION], mockKernel.mockKernel->getKernelInfo().kernelDescriptor.kernelMetadata.kernelName.c_str(), ptr, 128); @@ -548,8 +545,7 @@ TEST_F(PerformanceHintTest, givenPrintDriverDiagnosticsDebugModeEnabledWhenCallF context->getSVMAllocsManager()->insertSVMAlloc(allocData); testing::internal::CaptureStdout(); - KernelObjsForAuxTranslation kernelObjects; - mockKernel.mockKernel->fillWithKernelObjsForAuxTranslation(kernelObjects); + auto kernelObjects = mockKernel.mockKernel->fillWithKernelObjsForAuxTranslation(); snprintf(expectedHint, DriverDiagnostics::maxHintStringSize, DriverDiagnostics::hintFormat[KERNEL_ALLOCATION_AUX_TRANSLATION], mockKernel.mockKernel->getKernelInfo().kernelDescriptor.kernelMetadata.kernelName.c_str(), ptr, 128); @@ -583,8 +579,7 @@ TEST_F(PerformanceHintTest, givenPrintDriverDiagnosticsDebugModeEnabledWhenKerne testing::internal::CaptureStdout(); - KernelObjsForAuxTranslation kernelObjects; - mockKernel.mockKernel->fillWithKernelObjsForAuxTranslation(kernelObjects); + auto kernelObjects = mockKernel.mockKernel->fillWithKernelObjsForAuxTranslation(); std::string output = testing::internal::GetCapturedStdout(); EXPECT_EQ(0u, output.size()); @@ -610,8 +605,7 @@ TEST_F(PerformanceHintTest, givenPrintDriverDiagnosticsDebugModeDisabledWhenCall testing::internal::CaptureStdout(); - KernelObjsForAuxTranslation kernelObjects; - mockKernel.mockKernel->fillWithKernelObjsForAuxTranslation(kernelObjects); + auto kernelObjects = mockKernel.mockKernel->fillWithKernelObjsForAuxTranslation(); std::string output = testing::internal::GetCapturedStdout(); EXPECT_EQ(0u, output.size()); @@ -631,8 +625,7 @@ TEST_F(PerformanceHintTest, whenCallingFillWithKernelObjsForAuxTranslationOnNull testing::internal::CaptureStdout(); - KernelObjsForAuxTranslation kernelObjects; - mockKernel.mockKernel->fillWithKernelObjsForAuxTranslation(kernelObjects); + auto kernelObjects = mockKernel.mockKernel->fillWithKernelObjsForAuxTranslation(); std::string output = testing::internal::GetCapturedStdout(); EXPECT_EQ(0u, output.size()); @@ -654,8 +647,7 @@ TEST_F(PerformanceHintTest, givenPrintDriverDiagnosticsDebugModeDisabledWhenCall mockKernel.mockKernel->setUnifiedMemoryExecInfo(&gfxAllocation); testing::internal::CaptureStdout(); - KernelObjsForAuxTranslation kernelObjects; - mockKernel.mockKernel->fillWithKernelObjsForAuxTranslation(kernelObjects); + auto kernelObjects = mockKernel.mockKernel->fillWithKernelObjsForAuxTranslation(); std::string output = testing::internal::GetCapturedStdout(); EXPECT_EQ(0u, output.size()); diff --git a/opencl/test/unit_test/kernel/kernel_arg_buffer_tests.cpp b/opencl/test/unit_test/kernel/kernel_arg_buffer_tests.cpp index 338889c539..f3ecd10dc5 100644 --- a/opencl/test/unit_test/kernel/kernel_arg_buffer_tests.cpp +++ b/opencl/test/unit_test/kernel/kernel_arg_buffer_tests.cpp @@ -667,17 +667,16 @@ TEST_F(KernelArgBufferTest, givenSetUnifiedMemoryExecInfoOnKernelWithIndirectSta pKernel->setUnifiedMemoryExecInfo(&gfxAllocation); gmm->isCompressionEnabled = type.compressed; - KernelObjsForAuxTranslation kernelObjsForAuxTranslation; - pKernel->fillWithKernelObjsForAuxTranslation(kernelObjsForAuxTranslation); + auto kernelObjsForAuxTranslation = pKernel->fillWithKernelObjsForAuxTranslation(); if (type.compressed) { - EXPECT_EQ(1u, kernelObjsForAuxTranslation.size()); - auto kernelObj = *kernelObjsForAuxTranslation.find({KernelObjForAuxTranslation::Type::GFX_ALLOC, &gfxAllocation}); + EXPECT_EQ(1u, kernelObjsForAuxTranslation->size()); + auto kernelObj = *kernelObjsForAuxTranslation->find({KernelObjForAuxTranslation::Type::GFX_ALLOC, &gfxAllocation}); EXPECT_NE(nullptr, kernelObj.object); EXPECT_EQ(KernelObjForAuxTranslation::Type::GFX_ALLOC, kernelObj.type); - kernelObjsForAuxTranslation.erase(kernelObj); + kernelObjsForAuxTranslation->erase(kernelObj); } else { - EXPECT_EQ(0u, kernelObjsForAuxTranslation.size()); + EXPECT_EQ(0u, kernelObjsForAuxTranslation->size()); } pKernel->clearUnifiedMemoryExecInfo(); @@ -714,17 +713,16 @@ TEST_F(KernelArgBufferTest, givenSVMAllocsManagerWithCompressedSVMAllocationsWhe pContext->getSVMAllocsManager()->insertSVMAlloc(allocData); - KernelObjsForAuxTranslation kernelObjsForAuxTranslation; - pKernel->fillWithKernelObjsForAuxTranslation(kernelObjsForAuxTranslation); + auto kernelObjsForAuxTranslation = pKernel->fillWithKernelObjsForAuxTranslation(); if (type.compressed) { - EXPECT_EQ(1u, kernelObjsForAuxTranslation.size()); - auto kernelObj = *kernelObjsForAuxTranslation.find({KernelObjForAuxTranslation::Type::GFX_ALLOC, &gfxAllocation}); + EXPECT_EQ(1u, kernelObjsForAuxTranslation->size()); + auto kernelObj = *kernelObjsForAuxTranslation->find({KernelObjForAuxTranslation::Type::GFX_ALLOC, &gfxAllocation}); EXPECT_NE(nullptr, kernelObj.object); EXPECT_EQ(KernelObjForAuxTranslation::Type::GFX_ALLOC, kernelObj.type); - kernelObjsForAuxTranslation.erase(kernelObj); + kernelObjsForAuxTranslation->erase(kernelObj); } else { - EXPECT_EQ(0u, kernelObjsForAuxTranslation.size()); + EXPECT_EQ(0u, kernelObjsForAuxTranslation->size()); } pContext->getSVMAllocsManager()->removeSVMAlloc(allocData);