Skip to content

Commit 87d9e25

Browse files
committed
refactor: migration to std::make_unique C++17
Signed-off-by: Semenov Herman (Семенов Герман) <[email protected]>
1 parent c5d541d commit 87d9e25

File tree

17 files changed

+48
-49
lines changed

17 files changed

+48
-49
lines changed

opencl/source/command_queue/command_queue.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018-2024 Intel Corporation
2+
* Copyright (C) 2018-2025 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -903,7 +903,7 @@ void CommandQueue::enqueueBlockedMapUnmapOperation(const cl_event *eventWaitList
903903
}
904904

905905
// store task data in event
906-
auto cmd = std::unique_ptr<Command>(new CommandMapUnmap(opType, *memObj, copySize, copyOffset, readOnly, *this));
906+
auto cmd = std::make_unique<CommandMapUnmap>(opType, *memObj, copySize, copyOffset, readOnly, *this);
907907
eventBuilder->getEvent()->setCommand(std::move(cmd));
908908

909909
// bind output event with input events

opencl/source/sharings/va/va_sharing_functions.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018-2023 Intel Corporation
2+
* Copyright (C) 2018-2025 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -78,7 +78,7 @@ void VASharingFunctions::initFunctions() {
7878
void VASharingFunctions::querySupportedVaImageFormats(VADisplay vaDisplay) {
7979
int maxFormats = this->maxNumImageFormats(vaDisplay);
8080
if (maxFormats > 0) {
81-
std::unique_ptr<VAImageFormat[]> allVaFormats(new VAImageFormat[maxFormats]);
81+
auto allVaFormats = std::make_unique<VAImageFormat[]>(maxFormats);
8282
auto result = this->queryImageFormats(vaDisplay, allVaFormats.get(), &maxFormats);
8383
if (result == VA_STATUS_SUCCESS) {
8484
for (int i = 0; i < maxFormats; i++) {

opencl/source/utilities/cl_logger.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2021-2023 Intel Corporation
2+
* Copyright (C) 2021-2025 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -79,7 +79,7 @@ void ClFileLogger<debugLevel>::dumpKernelArgs(const MultiDispatchInfo *multiDisp
7979
type = "immediate";
8080
auto crossThreadData = kernel->getCrossThreadData();
8181
auto crossThreadDataSize = kernel->getCrossThreadDataSize();
82-
argVal = std::unique_ptr<char[]>(new char[crossThreadDataSize]);
82+
argVal = std::make_unique<char[]>(crossThreadDataSize);
8383

8484
size_t totalArgSize = 0;
8585
for (const auto &element : arg.as<ArgDescValue>().elements) {

shared/offline_compiler/source/ocloc_arg_helper.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020-2024 Intel Corporation
2+
* Copyright (C) 2020-2025 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -143,7 +143,7 @@ std::vector<char> OclocArgHelper::readBinaryFile(const std::string &filename) {
143143
std::unique_ptr<char[]> OclocArgHelper::loadDataFromFile(const std::string &filename, size_t &retSize) {
144144
if (Source *s = findSourceFile(filename)) {
145145
auto size = s->length;
146-
std::unique_ptr<char[]> ret(new char[size]());
146+
auto ret = std::make_unique<char[]>(size);
147147
memcpy_s(ret.get(), size, s->data, s->length);
148148
retSize = s->length;
149149
return ret;

shared/source/ail/ail_configuration.h

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2021-2024 Intel Corporation
2+
* Copyright (C) 2021-2025 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -120,8 +120,7 @@ template <PRODUCT_FAMILY product>
120120
class AILConfigurationHw : public AILConfiguration {
121121
public:
122122
static std::unique_ptr<AILConfiguration> create() {
123-
auto ailConfiguration = std::unique_ptr<AILConfiguration>(new AILConfigurationHw());
124-
return ailConfiguration;
123+
return std::make_unique<AILConfigurationHw>();
125124
}
126125

127126
void applyExt(RuntimeCapabilityTable &runtimeCapabilityTable) override;

shared/source/built_ins/built_ins_storage.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018-2024 Intel Corporation
2+
* Copyright (C) 2018-2025 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -173,8 +173,8 @@ BuiltinResourceT EmbeddedStorage::loadImpl(const std::string &fullResourceName)
173173
}
174174

175175
BuiltinsLib::BuiltinsLib() {
176-
allStorages.push_back(std::unique_ptr<Storage>(new EmbeddedStorage("")));
177-
allStorages.push_back(std::unique_ptr<Storage>(new FileStorage(getDriverInstallationPath())));
176+
allStorages.push_back(std::make_unique<EmbeddedStorage>(""));
177+
allStorages.push_back(std::make_unique<FileStorage>(getDriverInstallationPath()));
178178
}
179179

180180
BuiltinCode BuiltinsLib::getBuiltinCode(EBuiltInOps::Type builtin, BuiltinCode::ECodeType requestedCodeType, Device &device) {

shared/source/command_container/cmdcontainer.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019-2024 Intel Corporation
2+
* Copyright (C) 2019-2025 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -120,7 +120,7 @@ CommandContainer::ErrorCode CommandContainer::initialize(Device *device, Allocat
120120

121121
addToResidencyContainer(cmdBufferAllocation);
122122
if (requireHeaps) {
123-
heapHelper = std::unique_ptr<HeapHelper>(new HeapHelper(device->getMemoryManager(), device->getDefaultEngine().commandStreamReceiver->getInternalAllocationStorage(), device->getNumGenericSubDevices() > 1u));
123+
heapHelper = std::make_unique<HeapHelper>(device->getMemoryManager(), device->getDefaultEngine().commandStreamReceiver->getInternalAllocationStorage(), device->getNumGenericSubDevices() > 1u);
124124

125125
for (uint32_t i = 0; i < IndirectHeap::Type::numTypes; i++) {
126126
auto heapType = static_cast<HeapType>(i);
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018-2022 Intel Corporation
2+
* Copyright (C) 2018-2025 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -9,6 +9,6 @@
99

1010
namespace NEO {
1111
std::unique_ptr<DeferredDeleter> createDeferredDeleter() {
12-
return std::unique_ptr<DeferredDeleter>(new DeferredDeleter());
12+
return std::make_unique<DeferredDeleter>();
1313
}
1414
} // namespace NEO

shared/source/os_interface/linux/drm_memory_manager.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018-2024 Intel Corporation
2+
* Copyright (C) 2018-2025 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -793,7 +793,7 @@ GraphicsAllocation *DrmMemoryManager::allocatePhysicalDeviceMemory(const Allocat
793793
auto isCoherent = productHelper.isCoherentAllocation(patIndex);
794794
uint32_t handle = ioctlHelper->createGem(bufferSize, static_cast<uint32_t>(allocationData.storageInfo.memoryBanks.to_ulong()), isCoherent);
795795

796-
std::unique_ptr<BufferObject, BufferObject::Deleter> bo(new BufferObject(allocationData.rootDeviceIndex, &drm, patIndex, handle, bufferSize, maxOsContextCount));
796+
auto bo = std::make_unique<BufferObject>(allocationData.rootDeviceIndex, &drm, patIndex, handle, bufferSize, maxOsContextCount);
797797

798798
auto allocation = new DrmAllocation(allocationData.rootDeviceIndex, 1u /*num gmms*/, allocationData.type, bo.get(), nullptr, 0u, bufferSize, memoryPool);
799799
allocation->setDefaultGmm(gmm.release());
@@ -842,7 +842,7 @@ GraphicsAllocation *DrmMemoryManager::allocateMemoryByKMD(const AllocationData &
842842
boType = BufferObject::BOType::legacy;
843843
}
844844

845-
std::unique_ptr<BufferObject, BufferObject::Deleter> bo(new BufferObject(allocationData.rootDeviceIndex, &drm, patIndex, handle, bufferSize, maxOsContextCount));
845+
auto bo = std::make_unique<BufferObject>(allocationData.rootDeviceIndex, &drm, patIndex, handle, bufferSize, maxOsContextCount);
846846
bo->setAddress(gpuRange);
847847
bo->setBOType(boType);
848848

@@ -2683,7 +2683,7 @@ GraphicsAllocation *DrmMemoryManager::createSharedUnifiedMemoryAllocation(const
26832683
return nullptr;
26842684
}
26852685

2686-
std::unique_ptr<BufferObject, BufferObject::Deleter> bo(new BufferObject(allocationData.rootDeviceIndex, &drm, patIndex, handle, currentSize, maxOsContextCount));
2686+
auto bo = std::make_unique<BufferObject>(allocationData.rootDeviceIndex, &drm, patIndex, handle, currentSize, maxOsContextCount);
26872687

26882688
if (vmAdviseAttribute.has_value() && !ioctlHelper->setVmBoAdvise(bo->peekHandle(), vmAdviseAttribute.value(), nullptr)) {
26892689
ioctlHelper->munmapFunction(*this, cpuBasePointer, totalSizeToAlloc);

shared/source/os_interface/linux/ioctl_helper_prelim.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2021-2024 Intel Corporation
2+
* Copyright (C) 2021-2025 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -503,7 +503,7 @@ std::unique_ptr<uint8_t[]> IoctlHelperPrelim20::prepareVmBindExt(const StackVec<
503503
"Alignment of a buffer returned via new[] operator must allow storing the required type!");
504504

505505
const auto bufferSize{sizeof(prelim_drm_i915_vm_bind_ext_uuid) * bindExtHandles.size()};
506-
std::unique_ptr<uint8_t[]> extensionsBuffer{new uint8_t[bufferSize]};
506+
auto extensionsBuffer = std::make_unique<uint8_t[]>(bufferSize);
507507

508508
auto extensions = new (extensionsBuffer.get()) prelim_drm_i915_vm_bind_ext_uuid[bindExtHandles.size()];
509509
std::memset(extensionsBuffer.get(), 0, bufferSize);

shared/source/os_interface/linux/os_thread_linux.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020-2024 Intel Corporation
2+
* Copyright (C) 2020-2025 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -17,7 +17,7 @@ decltype(&Thread::create) Thread::createFunc = Thread::create;
1717
std::unique_ptr<Thread> Thread::create(void *(*func)(void *), void *arg) {
1818
pthread_t threadId;
1919
pthread_create(&threadId, nullptr, func, arg);
20-
return std::unique_ptr<Thread>(new ThreadLinux(threadId));
20+
return std::make_unique<ThreadLinux>(threadId);
2121
}
2222

2323
void ThreadLinux::join() {

shared/source/os_interface/linux/os_time_linux.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018-2024 Intel Corporation
2+
* Copyright (C) 2018-2025 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -72,7 +72,7 @@ uint64_t OSTimeLinux::getCpuRawTimestamp() {
7272
}
7373

7474
std::unique_ptr<OSTime> OSTimeLinux::create(OSInterface &osInterface, std::unique_ptr<DeviceTime> deviceTime) {
75-
return std::unique_ptr<OSTime>(new OSTimeLinux(osInterface, std::move(deviceTime)));
75+
return std::make_unique<OSTimeLinux>(osInterface, std::move(deviceTime));
7676
}
7777

7878
} // namespace NEO

shared/source/os_interface/windows/wddm/wddm.cpp

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018-2024 Intel Corporation
2+
* Copyright (C) 2018-2025 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -67,7 +67,7 @@ Wddm::Wddm(std::unique_ptr<HwDeviceIdWddm> &&hwDeviceIdIn, RootDeviceEnvironment
6767
memset(gtSystemInfo.get(), 0, sizeof(*gtSystemInfo));
6868
memset(gfxPlatform.get(), 0, sizeof(*gfxPlatform));
6969
this->enablePreemptionRegValue = NEO::readEnablePreemptionRegKey();
70-
kmDafListener = std::unique_ptr<KmDafListener>(new KmDafListener);
70+
kmDafListener = std::make_unique<KmDafListener>();
7171
temporaryResources = std::make_unique<WddmResidentAllocationsContainer>(this);
7272
osMemory = OSMemory::create();
7373
bool forceCheck = false;
@@ -864,10 +864,10 @@ bool Wddm::openSharedHandle(const MemoryManager::OsHandleData &osHandleData, Wdd
864864
return false;
865865
}
866866

867-
std::unique_ptr<char[]> allocPrivateData(new char[queryResourceInfo.TotalPrivateDriverDataSize]);
868-
std::unique_ptr<char[]> resPrivateData(new char[queryResourceInfo.ResourcePrivateDriverDataSize]);
869-
std::unique_ptr<char[]> resPrivateRuntimeData(new char[queryResourceInfo.PrivateRuntimeDataSize]);
870-
std::unique_ptr<D3DDDI_OPENALLOCATIONINFO[]> allocationInfo(new D3DDDI_OPENALLOCATIONINFO[queryResourceInfo.NumAllocations]);
867+
auto allocPrivateData = std::make_unique<char[]>(queryResourceInfo.TotalPrivateDriverDataSize);
868+
auto resPrivateData = std::make_unique<char[]>(queryResourceInfo.ResourcePrivateDriverDataSize);
869+
auto resPrivateRuntimeData = std::make_unique<char[]>(queryResourceInfo.PrivateRuntimeDataSize);
870+
auto allocationInfo = std::make_unique<D3DDDI_OPENALLOCATIONINFO[]>(queryResourceInfo.NumAllocations);
871871

872872
D3DKMT_OPENRESOURCE openResource = {};
873873

@@ -914,10 +914,10 @@ bool Wddm::openNTHandle(const MemoryManager::OsHandleData &osHandleData, WddmAll
914914
return false;
915915
}
916916

917-
std::unique_ptr<char[]> allocPrivateData(new char[queryResourceInfoFromNtHandle.TotalPrivateDriverDataSize]);
918-
std::unique_ptr<char[]> resPrivateData(new char[queryResourceInfoFromNtHandle.ResourcePrivateDriverDataSize]);
919-
std::unique_ptr<char[]> resPrivateRuntimeData(new char[queryResourceInfoFromNtHandle.PrivateRuntimeDataSize]);
920-
std::unique_ptr<D3DDDI_OPENALLOCATIONINFO2[]> allocationInfo2(new D3DDDI_OPENALLOCATIONINFO2[queryResourceInfoFromNtHandle.NumAllocations]);
917+
auto allocPrivateData = std::make_unique<char>(queryResourceInfoFromNtHandle.TotalPrivateDriverDataSize);
918+
auto resPrivateData = std::make_unique<char>(queryResourceInfoFromNtHandle.ResourcePrivateDriverDataSize);
919+
auto resPrivateRuntimeData = std::make_unique<char>(queryResourceInfoFromNtHandle.PrivateRuntimeDataSize);
920+
auto allocationInfo2 = std::make_unique<D3DDDI_OPENALLOCATIONINFO2[]>(queryResourceInfoFromNtHandle.NumAllocations);
921921

922922
D3DKMT_OPENRESOURCEFROMNTHANDLE openResourceFromNtHandle = {};
923923

shared/source/program/print_formatter.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018-2023 Intel Corporation
2+
* Copyright (C) 2018-2025 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -59,7 +59,7 @@ void PrintFormatter::printString(const char *formatString, const std::function<v
5959
size_t length = strnlen_s(formatString, maxSinglePrintStringLength - 1);
6060

6161
size_t cursor = 0;
62-
std::unique_ptr<char[]> dataFormat(new char[length + 1]);
62+
auto dataFormat = std::make_unique<char[]>(length + 1);
6363

6464
for (size_t i = 0; i <= length; i++) {
6565
if (formatString[i] == '\\')

shared/source/utilities/idlist.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018-2023 Intel Corporation
2+
* Copyright (C) 2018-2025 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -463,7 +463,7 @@ template <typename NodeObjectType, bool threadSafe = true, bool ownsNodes = true
463463
class IDRefList : public IDList<IDNodeRef<NodeObjectType>, threadSafe, ownsNodes> {
464464
public:
465465
void pushRefFrontOne(NodeObjectType &node) {
466-
auto refNode = std::unique_ptr<IDNodeRef<NodeObjectType>>(new IDNodeRef<NodeObjectType>(&node));
466+
auto refNode = std::make_unique<IDNodeRef<NodeObjectType>>(&node);
467467
this->pushFrontOne(*refNode);
468468
refNode.release();
469469
}

shared/source/utilities/iflist.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018-2023 Intel Corporation
2+
* Copyright (C) 2018-2025 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -189,7 +189,7 @@ template <typename NodeObjectType, bool threadSafe = true, bool ownsNodes = true
189189
class IFRefList : public IFList<IFNodeRef<NodeObjectType>, threadSafe, ownsNodes> {
190190
public:
191191
void pushRefFrontOne(NodeObjectType &node) {
192-
auto up = std::unique_ptr<IFNodeRef<NodeObjectType>>(new IFNodeRef<NodeObjectType>(&node));
192+
auto up = std::make_unique<IFNodeRef<NodeObjectType>>(&node);
193193
this->pushFrontOne(*up);
194194
up.release();
195195
} // NOLINT(clang-analyzer-cplusplus.NewDeleteLeaks)

shared/source/utilities/perf_profiler.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018-2023 Intel Corporation
2+
* Copyright (C) 2018-2025 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -29,8 +29,8 @@ PerfProfiler *PerfProfiler::create(bool dumpToFile) {
2929
if (gPerfProfiler == nullptr) {
3030
int old = counter.fetch_add(1);
3131
if (!dumpToFile) {
32-
std::unique_ptr<std::stringstream> logs = std::unique_ptr<std::stringstream>(new std::stringstream());
33-
std::unique_ptr<std::stringstream> sysLogs = std::unique_ptr<std::stringstream>(new std::stringstream());
32+
auto logs = std::make_unique<std::stringstream>();
33+
auto sysLogs = std::make_unique<std::stringstream>();
3434
gPerfProfiler = new PerfProfiler(old, std::move(logs), std::move(sysLogs));
3535
} else {
3636
gPerfProfiler = new PerfProfiler(old);
@@ -63,7 +63,7 @@ PerfProfiler::PerfProfiler(int id, std::unique_ptr<std::ostream> &&logOut, std::
6363
std::stringstream filename;
6464
filename << "PerfReport_Thread_" << id << ".xml";
6565

66-
std::unique_ptr<std::ofstream> logToFile = std::unique_ptr<std::ofstream>(new std::ofstream());
66+
auto logToFile = std::make_unique<std::ofstream>();
6767
logToFile->exceptions(std::ios::failbit | std::ios::badbit);
6868
logToFile->open(filename.str().c_str(), std::ios::trunc);
6969
this->logFile = std::move(logToFile);
@@ -77,7 +77,7 @@ PerfProfiler::PerfProfiler(int id, std::unique_ptr<std::ostream> &&logOut, std::
7777
std::stringstream filename;
7878
filename << "SysPerfReport_Thread_" << id << ".xml";
7979

80-
std::unique_ptr<std::ofstream> sysLogToFile = std::unique_ptr<std::ofstream>(new std::ofstream());
80+
auto sysLogToFile = std::make_unique<std::ofstream>();
8181
sysLogToFile->exceptions(std::ios::failbit | std::ios::badbit);
8282
sysLogToFile->open(filename.str().c_str(), std::ios::trunc);
8383
this->sysLogFile = std::move(sysLogToFile);

0 commit comments

Comments
 (0)