From 31d68c42e6764a6eb6e0bd3710afd28b1d718dfc Mon Sep 17 00:00:00 2001 From: Pawel Cieslak Date: Tue, 14 Feb 2023 00:47:39 +0000 Subject: [PATCH] fix mismatched-new-delete when using unique_ptr Related-To: NEO-6511 Signed-off-by: Pawel Cieslak --- .../api/cl_set_event_callback_tests.inl | 4 ++-- ...nd_stream_receiver_hw_tests_dg2_and_later.cpp | 4 ++-- ...d_stream_receiver_hw_tests_xehp_and_later.cpp | 8 ++++---- .../default_cl_cache_config_tests.cpp | 4 ++-- .../helpers/flat_batch_buffer_helper_hw.inl | 4 ++-- .../aub_command_stream_receiver_2_tests.cpp | 16 ++++++++-------- .../compiler_interface/compiler_cache_tests.cpp | 8 ++++---- 7 files changed, 24 insertions(+), 24 deletions(-) diff --git a/opencl/test/unit_test/api/cl_set_event_callback_tests.inl b/opencl/test/unit_test/api/cl_set_event_callback_tests.inl index d1121fde75..9105fc519a 100644 --- a/opencl/test/unit_test/api/cl_set_event_callback_tests.inl +++ b/opencl/test/unit_test/api/cl_set_event_callback_tests.inl @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2022 Intel Corporation + * Copyright (C) 2018-2023 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -48,7 +48,7 @@ TEST_F(ClSetEventCallbackTests, GivenValidEventWhenSettingEventCallbackThenSucce } TEST_F(ClSetEventCallbackTests, GivenInvalidEventWhenSettingEventCallbackThenInvalidEventErrorIsReturned) { - std::unique_ptr event(new char[sizeof(Event)]); + std::unique_ptr event(new char[sizeof(Event)]); memset(event.get(), 0, sizeof(Event)); retVal = clSetEventCallback(reinterpret_cast(event.get()), CL_COMPLETE, eventCallBack, nullptr); EXPECT_EQ(CL_INVALID_EVENT, retVal); diff --git a/opencl/test/unit_test/command_stream/command_stream_receiver_hw_tests_dg2_and_later.cpp b/opencl/test/unit_test/command_stream/command_stream_receiver_hw_tests_dg2_and_later.cpp index 9f8099c325..d1da22df06 100644 --- a/opencl/test/unit_test/command_stream/command_stream_receiver_hw_tests_dg2_and_later.cpp +++ b/opencl/test/unit_test/command_stream/command_stream_receiver_hw_tests_dg2_and_later.cpp @@ -48,7 +48,7 @@ HWTEST2_F(CommandStreamReceiverHwTestDg2AndLater, givenGen12AndLaterWhenRayTraci AllocationProperties properties(pDevice->getRootDeviceIndex(), MemoryConstants::pageSize, AllocationType::SCRATCH_SURFACE, pDevice->getDeviceBitfield()); auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(properties); commandStreamReceiver.perDssBackedBuffer = allocation; - std::unique_ptr buffer(new char[cmdSize]); + std::unique_ptr buffer(new char[cmdSize]); LinearStream cs(buffer.get(), cmdSize); DispatchFlags dispatchFlags = DispatchFlagsHelper::createDefaultDispatchFlags(); dispatchFlags.usePerDssBackedBuffer = true; @@ -156,7 +156,7 @@ HWTEST2_F(CommandStreamReceiverHwTestDg2AndLater, givenGen12AndLaterWhenRayTraci AllocationProperties properties(pDevice->getRootDeviceIndex(), MemoryConstants::pageSize, AllocationType::SCRATCH_SURFACE, pDevice->getDeviceBitfield()); auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(properties); commandStreamReceiver.perDssBackedBuffer = allocation; - std::unique_ptr buffer(new char[cmdSize]); + std::unique_ptr buffer(new char[cmdSize]); LinearStream cs(buffer.get(), cmdSize); DispatchFlags dispatchFlags = DispatchFlagsHelper::createDefaultDispatchFlags(); dispatchFlags.usePerDssBackedBuffer = true; diff --git a/opencl/test/unit_test/command_stream/command_stream_receiver_hw_tests_xehp_and_later.cpp b/opencl/test/unit_test/command_stream/command_stream_receiver_hw_tests_xehp_and_later.cpp index b73defd2b6..e0f36502ec 100644 --- a/opencl/test/unit_test/command_stream/command_stream_receiver_hw_tests_xehp_and_later.cpp +++ b/opencl/test/unit_test/command_stream/command_stream_receiver_hw_tests_xehp_and_later.cpp @@ -842,7 +842,7 @@ HWTEST2_F(CommandStreamReceiverHwTestXeHPAndLater, givenXeHpWhenRayTracingEnable MockCsrHw commandStreamReceiver(*pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); auto cmdSize = commandStreamReceiver.getCmdSizeForPerDssBackedBuffer(pDevice->getHardwareInfo()); EXPECT_EQ(0u, cmdSize); - std::unique_ptr buffer(new char[cmdSize]); + std::unique_ptr buffer(new char[cmdSize]); LinearStream cs(buffer.get(), cmdSize); DispatchFlags dispatchFlags = DispatchFlagsHelper::createDefaultDispatchFlags(); @@ -857,7 +857,7 @@ HWTEST2_F(CommandStreamReceiverHwTestXeHPAndLater, givenStaticPartitionEnabledWh MockCsrHw commandStreamReceiver(*pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); constexpr size_t cmdSize = 256; - std::unique_ptr buffer(new char[cmdSize]); + std::unique_ptr buffer(new char[cmdSize]); LinearStream cs(buffer.get(), cmdSize); commandStreamReceiver.staticWorkPartitioningEnabled = true; @@ -878,7 +878,7 @@ HWTEST2_F(CommandStreamReceiverHwTestXeHPAndLater, givenStaticPartitionDisabledW MockCsrHw commandStreamReceiver(*pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); constexpr size_t cmdSize = 256; - std::unique_ptr buffer(new char[cmdSize]); + std::unique_ptr buffer(new char[cmdSize]); LinearStream cs(buffer.get(), cmdSize); commandStreamReceiver.staticWorkPartitioningEnabled = false; @@ -902,7 +902,7 @@ HWTEST2_F(CommandStreamReceiverHwTestXeHPAndLater, givenStaticPartitionEnabledWh MockCsrHw commandStreamReceiver(*pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); constexpr size_t cmdSize = 256; - std::unique_ptr buffer(new char[cmdSize]); + std::unique_ptr buffer(new char[cmdSize]); MockGraphicsAllocation allocation(buffer.get(), cmdSize); allocation.gpuAddress = 0xFF000; LinearStream cs(buffer.get(), cmdSize); diff --git a/opencl/test/unit_test/compiler_interface/default_cl_cache_config_tests.cpp b/opencl/test/unit_test/compiler_interface/default_cl_cache_config_tests.cpp index 8b25a23adc..0274cf10ec 100644 --- a/opencl/test/unit_test/compiler_interface/default_cl_cache_config_tests.cpp +++ b/opencl/test/unit_test/compiler_interface/default_cl_cache_config_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2022 Intel Corporation + * Copyright (C) 2019-2023 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -18,7 +18,7 @@ TEST(CompilerCache, GivenDefaultClCacheConfigThenValuesAreProperlyPopulated) { TEST(CompilerCacheTests, GivenExistingConfigWhenLoadingFromCacheThenBinaryIsLoaded) { NEO::CompilerCache cache(NEO::getDefaultCompilerCacheConfig()); static const char *hash = "SOME_HASH"; - std::unique_ptr data(new char[32]); + std::unique_ptr data(new char[32]); for (size_t i = 0; i < 32; i++) data.get()[i] = static_cast(i); diff --git a/shared/source/helpers/flat_batch_buffer_helper_hw.inl b/shared/source/helpers/flat_batch_buffer_helper_hw.inl index cfb0958327..fde322c3a6 100644 --- a/shared/source/helpers/flat_batch_buffer_helper_hw.inl +++ b/shared/source/helpers/flat_batch_buffer_helper_hw.inl @@ -29,7 +29,7 @@ GraphicsAllocation *FlatBatchBufferHelperHw::flattenBatchBuffer(uint3 size_t indirectPatchCommandsSize = 0u; std::vector indirectPatchInfo; - std::unique_ptr indirectPatchCommands(getIndirectPatchCommands(indirectPatchCommandsSize, indirectPatchInfo)); + std::unique_ptr indirectPatchCommands(getIndirectPatchCommands(indirectPatchCommandsSize, indirectPatchInfo)); if (dispatchMode == DispatchMode::ImmediateDispatch) { if (batchBuffer.chainedBatchBuffer) { @@ -158,7 +158,7 @@ char *FlatBatchBufferHelperHw::getIndirectPatchCommands(size_t &indir uint64_t stiCommandOffset = 0; std::vector patchInfoCopy = patchInfoCollection; - std::unique_ptr buffer(new char[indirectPatchCommandsSize]); + std::unique_ptr buffer(new char[indirectPatchCommandsSize]); LinearStream indirectPatchCommandStream(buffer.get(), indirectPatchCommandsSize); patchInfoCollection.clear(); diff --git a/shared/test/unit_test/command_stream/aub_command_stream_receiver_2_tests.cpp b/shared/test/unit_test/command_stream/aub_command_stream_receiver_2_tests.cpp index 930e8f6b34..a10e4ff0a7 100644 --- a/shared/test/unit_test/command_stream/aub_command_stream_receiver_2_tests.cpp +++ b/shared/test/unit_test/command_stream/aub_command_stream_receiver_2_tests.cpp @@ -170,7 +170,7 @@ HWTEST_F(FlatBatchBufferHelperAubTests, givenAubCommandStreamReceiverWhenAddGucS auto aubCsr = aubExecutionEnvironment->template getCsr>(); LinearStream cs(aubExecutionEnvironment->commandBuffer); - std::unique_ptr batchBuffer(new char[1024]); + std::unique_ptr batchBuffer(new char[1024]); aubCsr->addGUCStartMessage(static_cast(reinterpret_cast(batchBuffer.get()))); auto &patchInfoCollection = aubCsr->getFlatBatchBufferHelper().getPatchInfoCollection(); @@ -192,20 +192,20 @@ HWTEST_F(FlatBatchBufferHelperAubTests, givenAubCommandStreamReceiverWhenForcedB CommandChunk chunk2; CommandChunk chunk3; - std::unique_ptr commands1(new char[0x100u]); + std::unique_ptr commands1(new char[0x100u]); commands1.get()[0] = 0x1; chunk1.baseAddressCpu = chunk1.baseAddressGpu = reinterpret_cast(commands1.get()); chunk1.startOffset = 0u; chunk1.endOffset = 0x50u; - std::unique_ptr commands2(new char[0x100u]); + std::unique_ptr commands2(new char[0x100u]); commands2.get()[0] = 0x2; chunk2.baseAddressCpu = chunk2.baseAddressGpu = reinterpret_cast(commands2.get()); chunk2.startOffset = 0u; chunk2.endOffset = 0x50u; aubCsr->getFlatBatchBufferHelper().registerBatchBufferStartAddress(reinterpret_cast(commands2.get() + 0x40), reinterpret_cast(commands1.get())); - std::unique_ptr commands3(new char[0x100u]); + std::unique_ptr commands3(new char[0x100u]); commands3.get()[0] = 0x3; chunk3.baseAddressCpu = chunk3.baseAddressGpu = reinterpret_cast(commands3.get()); chunk3.startOffset = 0u; @@ -454,7 +454,7 @@ HWTEST_F(FlatBatchBufferHelperAubTests, givenAubCommandStreamReceiverWhenGetIndi size_t indirectPatchCommandsSize = 0u; std::vector indirectPatchInfo; - std::unique_ptr commandBuffer(aubCsr->getFlatBatchBufferHelper().getIndirectPatchCommands(indirectPatchCommandsSize, indirectPatchInfo)); + std::unique_ptr commandBuffer(aubCsr->getFlatBatchBufferHelper().getIndirectPatchCommands(indirectPatchCommandsSize, indirectPatchInfo)); EXPECT_EQ(0u, indirectPatchCommandsSize); EXPECT_EQ(0u, indirectPatchInfo.size()); } @@ -476,7 +476,7 @@ HWTEST_F(FlatBatchBufferHelperAubTests, givenAubCommandStreamReceiverWhenGetIndi size_t indirectPatchCommandsSize = 0u; std::vector indirectPatchInfo; - std::unique_ptr commandBuffer(aubCsr->getFlatBatchBufferHelper().getIndirectPatchCommands(indirectPatchCommandsSize, indirectPatchInfo)); + std::unique_ptr commandBuffer(aubCsr->getFlatBatchBufferHelper().getIndirectPatchCommands(indirectPatchCommandsSize, indirectPatchInfo)); EXPECT_EQ(4u, indirectPatchInfo.size()); EXPECT_EQ(2u * sizeof(MI_STORE_DATA_IMM), indirectPatchCommandsSize); } @@ -491,7 +491,7 @@ HWTEST_F(FlatBatchBufferHelperAubTests, GivenAubCommandStreamReceiverWhenGetIndi size_t indirectPatchCommandsSize = 0u; std::vector indirectPatchInfo; - std::unique_ptr commandBuffer(aubCsr->getFlatBatchBufferHelper().getIndirectPatchCommands(indirectPatchCommandsSize, indirectPatchInfo)); + std::unique_ptr commandBuffer(aubCsr->getFlatBatchBufferHelper().getIndirectPatchCommands(indirectPatchCommandsSize, indirectPatchInfo)); ASSERT_EQ(sizeof(MI_STORE_DATA_IMM), indirectPatchCommandsSize); ASSERT_EQ(2u, indirectPatchInfo.size()); @@ -510,7 +510,7 @@ HWTEST_F(FlatBatchBufferHelperAubTests, GivenAubCommandStreamReceiverWhenGetIndi size_t indirectPatchCommandsSize = 0u; std::vector indirectPatchInfo; - std::unique_ptr commandBuffer(aubCsr->getFlatBatchBufferHelper().getIndirectPatchCommands(indirectPatchCommandsSize, indirectPatchInfo)); + std::unique_ptr commandBuffer(aubCsr->getFlatBatchBufferHelper().getIndirectPatchCommands(indirectPatchCommandsSize, indirectPatchInfo)); ASSERT_EQ(sizeof(MI_STORE_DATA_IMM), indirectPatchCommandsSize); ASSERT_EQ(2u, indirectPatchInfo.size()); diff --git a/shared/test/unit_test/compiler_interface/compiler_cache_tests.cpp b/shared/test/unit_test/compiler_interface/compiler_cache_tests.cpp index 891f1de3f0..086fa5b744 100644 --- a/shared/test/unit_test/compiler_interface/compiler_cache_tests.cpp +++ b/shared/test/unit_test/compiler_interface/compiler_cache_tests.cpp @@ -157,10 +157,10 @@ TEST(CompilerCacheHashTests, GivenCompilingOptionsWhenGettingCacheThenCorrectCac std::string("--some --options"), std::string("--some --different --options")}}; - std::unique_ptr buf1(new char[bufSize]); - std::unique_ptr buf2(new char[bufSize]); - std::unique_ptr buf3(new char[bufSize]); - std::unique_ptr buf4(new char[bufSize]); + std::unique_ptr buf1(new char[bufSize]); + std::unique_ptr buf2(new char[bufSize]); + std::unique_ptr buf3(new char[bufSize]); + std::unique_ptr buf4(new char[bufSize]); ArrayRef src; ArrayRef apiOptions;