fix mismatched-new-delete when using unique_ptr

Related-To: NEO-6511
Signed-off-by: Pawel Cieslak <pawel.cieslak@intel.com>
This commit is contained in:
Pawel Cieslak 2023-02-14 00:47:39 +00:00 committed by Compute-Runtime-Automation
parent dcea913fbc
commit 31d68c42e6
7 changed files with 24 additions and 24 deletions

View File

@ -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<char> event(new char[sizeof(Event)]);
std::unique_ptr<char[]> event(new char[sizeof(Event)]);
memset(event.get(), 0, sizeof(Event));
retVal = clSetEventCallback(reinterpret_cast<cl_event>(event.get()), CL_COMPLETE, eventCallBack, nullptr);
EXPECT_EQ(CL_INVALID_EVENT, retVal);

View File

@ -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<char> buffer(new char[cmdSize]);
std::unique_ptr<char[]> 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<char> buffer(new char[cmdSize]);
std::unique_ptr<char[]> buffer(new char[cmdSize]);
LinearStream cs(buffer.get(), cmdSize);
DispatchFlags dispatchFlags = DispatchFlagsHelper::createDefaultDispatchFlags();
dispatchFlags.usePerDssBackedBuffer = true;

View File

@ -842,7 +842,7 @@ HWTEST2_F(CommandStreamReceiverHwTestXeHPAndLater, givenXeHpWhenRayTracingEnable
MockCsrHw<FamilyType> commandStreamReceiver(*pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
auto cmdSize = commandStreamReceiver.getCmdSizeForPerDssBackedBuffer(pDevice->getHardwareInfo());
EXPECT_EQ(0u, cmdSize);
std::unique_ptr<char> buffer(new char[cmdSize]);
std::unique_ptr<char[]> buffer(new char[cmdSize]);
LinearStream cs(buffer.get(), cmdSize);
DispatchFlags dispatchFlags = DispatchFlagsHelper::createDefaultDispatchFlags();
@ -857,7 +857,7 @@ HWTEST2_F(CommandStreamReceiverHwTestXeHPAndLater, givenStaticPartitionEnabledWh
MockCsrHw<FamilyType> commandStreamReceiver(*pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
constexpr size_t cmdSize = 256;
std::unique_ptr<char> buffer(new char[cmdSize]);
std::unique_ptr<char[]> buffer(new char[cmdSize]);
LinearStream cs(buffer.get(), cmdSize);
commandStreamReceiver.staticWorkPartitioningEnabled = true;
@ -878,7 +878,7 @@ HWTEST2_F(CommandStreamReceiverHwTestXeHPAndLater, givenStaticPartitionDisabledW
MockCsrHw<FamilyType> commandStreamReceiver(*pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
constexpr size_t cmdSize = 256;
std::unique_ptr<char> buffer(new char[cmdSize]);
std::unique_ptr<char[]> buffer(new char[cmdSize]);
LinearStream cs(buffer.get(), cmdSize);
commandStreamReceiver.staticWorkPartitioningEnabled = false;
@ -902,7 +902,7 @@ HWTEST2_F(CommandStreamReceiverHwTestXeHPAndLater, givenStaticPartitionEnabledWh
MockCsrHw<FamilyType> commandStreamReceiver(*pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
constexpr size_t cmdSize = 256;
std::unique_ptr<char> buffer(new char[cmdSize]);
std::unique_ptr<char[]> buffer(new char[cmdSize]);
MockGraphicsAllocation allocation(buffer.get(), cmdSize);
allocation.gpuAddress = 0xFF000;
LinearStream cs(buffer.get(), cmdSize);

View File

@ -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<char> data(new char[32]);
std::unique_ptr<char[]> data(new char[32]);
for (size_t i = 0; i < 32; i++)
data.get()[i] = static_cast<char>(i);

View File

@ -29,7 +29,7 @@ GraphicsAllocation *FlatBatchBufferHelperHw<GfxFamily>::flattenBatchBuffer(uint3
size_t indirectPatchCommandsSize = 0u;
std::vector<PatchInfoData> indirectPatchInfo;
std::unique_ptr<char> indirectPatchCommands(getIndirectPatchCommands(indirectPatchCommandsSize, indirectPatchInfo));
std::unique_ptr<char[]> indirectPatchCommands(getIndirectPatchCommands(indirectPatchCommandsSize, indirectPatchInfo));
if (dispatchMode == DispatchMode::ImmediateDispatch) {
if (batchBuffer.chainedBatchBuffer) {
@ -158,7 +158,7 @@ char *FlatBatchBufferHelperHw<GfxFamily>::getIndirectPatchCommands(size_t &indir
uint64_t stiCommandOffset = 0;
std::vector<PatchInfoData> patchInfoCopy = patchInfoCollection;
std::unique_ptr<char> buffer(new char[indirectPatchCommandsSize]);
std::unique_ptr<char[]> buffer(new char[indirectPatchCommandsSize]);
LinearStream indirectPatchCommandStream(buffer.get(), indirectPatchCommandsSize);
patchInfoCollection.clear();

View File

@ -170,7 +170,7 @@ HWTEST_F(FlatBatchBufferHelperAubTests, givenAubCommandStreamReceiverWhenAddGucS
auto aubCsr = aubExecutionEnvironment->template getCsr<AUBCommandStreamReceiverHw<FamilyType>>();
LinearStream cs(aubExecutionEnvironment->commandBuffer);
std::unique_ptr<char> batchBuffer(new char[1024]);
std::unique_ptr<char[]> batchBuffer(new char[1024]);
aubCsr->addGUCStartMessage(static_cast<uint64_t>(reinterpret_cast<std::uintptr_t>(batchBuffer.get())));
auto &patchInfoCollection = aubCsr->getFlatBatchBufferHelper().getPatchInfoCollection();
@ -192,20 +192,20 @@ HWTEST_F(FlatBatchBufferHelperAubTests, givenAubCommandStreamReceiverWhenForcedB
CommandChunk chunk2;
CommandChunk chunk3;
std::unique_ptr<char> commands1(new char[0x100u]);
std::unique_ptr<char[]> commands1(new char[0x100u]);
commands1.get()[0] = 0x1;
chunk1.baseAddressCpu = chunk1.baseAddressGpu = reinterpret_cast<uint64_t>(commands1.get());
chunk1.startOffset = 0u;
chunk1.endOffset = 0x50u;
std::unique_ptr<char> commands2(new char[0x100u]);
std::unique_ptr<char[]> commands2(new char[0x100u]);
commands2.get()[0] = 0x2;
chunk2.baseAddressCpu = chunk2.baseAddressGpu = reinterpret_cast<uint64_t>(commands2.get());
chunk2.startOffset = 0u;
chunk2.endOffset = 0x50u;
aubCsr->getFlatBatchBufferHelper().registerBatchBufferStartAddress(reinterpret_cast<uint64_t>(commands2.get() + 0x40), reinterpret_cast<uint64_t>(commands1.get()));
std::unique_ptr<char> commands3(new char[0x100u]);
std::unique_ptr<char[]> commands3(new char[0x100u]);
commands3.get()[0] = 0x3;
chunk3.baseAddressCpu = chunk3.baseAddressGpu = reinterpret_cast<uint64_t>(commands3.get());
chunk3.startOffset = 0u;
@ -454,7 +454,7 @@ HWTEST_F(FlatBatchBufferHelperAubTests, givenAubCommandStreamReceiverWhenGetIndi
size_t indirectPatchCommandsSize = 0u;
std::vector<PatchInfoData> indirectPatchInfo;
std::unique_ptr<char> commandBuffer(aubCsr->getFlatBatchBufferHelper().getIndirectPatchCommands(indirectPatchCommandsSize, indirectPatchInfo));
std::unique_ptr<char[]> 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<PatchInfoData> indirectPatchInfo;
std::unique_ptr<char> commandBuffer(aubCsr->getFlatBatchBufferHelper().getIndirectPatchCommands(indirectPatchCommandsSize, indirectPatchInfo));
std::unique_ptr<char[]> 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<PatchInfoData> indirectPatchInfo;
std::unique_ptr<char> commandBuffer(aubCsr->getFlatBatchBufferHelper().getIndirectPatchCommands(indirectPatchCommandsSize, indirectPatchInfo));
std::unique_ptr<char[]> 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<PatchInfoData> indirectPatchInfo;
std::unique_ptr<char> commandBuffer(aubCsr->getFlatBatchBufferHelper().getIndirectPatchCommands(indirectPatchCommandsSize, indirectPatchInfo));
std::unique_ptr<char[]> commandBuffer(aubCsr->getFlatBatchBufferHelper().getIndirectPatchCommands(indirectPatchCommandsSize, indirectPatchInfo));
ASSERT_EQ(sizeof(MI_STORE_DATA_IMM), indirectPatchCommandsSize);
ASSERT_EQ(2u, indirectPatchInfo.size());

View File

@ -157,10 +157,10 @@ TEST(CompilerCacheHashTests, GivenCompilingOptionsWhenGettingCacheThenCorrectCac
std::string("--some --options"),
std::string("--some --different --options")}};
std::unique_ptr<char> buf1(new char[bufSize]);
std::unique_ptr<char> buf2(new char[bufSize]);
std::unique_ptr<char> buf3(new char[bufSize]);
std::unique_ptr<char> buf4(new char[bufSize]);
std::unique_ptr<char[]> buf1(new char[bufSize]);
std::unique_ptr<char[]> buf2(new char[bufSize]);
std::unique_ptr<char[]> buf3(new char[bufSize]);
std::unique_ptr<char[]> buf4(new char[bufSize]);
ArrayRef<char> src;
ArrayRef<char> apiOptions;