Skip to content

Commit

Permalink
refactor: replace push to emplace C++11
Browse files Browse the repository at this point in the history
  • Loading branch information
GermanAizek committed Jan 1, 2025
1 parent c5d541d commit 1763c96
Show file tree
Hide file tree
Showing 20 changed files with 36 additions and 38 deletions.
2 changes: 1 addition & 1 deletion opencl/source/context/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ bool Context::createImpl(const cl_context_properties *properties,
engine.commandStreamReceiver->ensureTagAllocationForRootDeviceIndex(rootDeviceIndex);
}
}
deviceBitfields.insert({rootDeviceIndex, deviceBitfield});
deviceBitfields.emplace(rootDeviceIndex, deviceBitfield);
}

if (devices.size() > 0) {
Expand Down
2 changes: 1 addition & 1 deletion opencl/source/helpers/destructor_callbacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class DestructorCallbacks {

public:
inline void add(CallbackType *callback, void *userData) {
callbacks.push_back({callback, userData});
callbacks.emplace_back(callback, userData);
}
inline bool empty() {
return callbacks.empty();
Expand Down
2 changes: 1 addition & 1 deletion opencl/source/kernel/kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@ void Kernel::markArgPatchedAndResolveArgs(uint32_t argIndex) {
auto migrateRequiredForArg = memObj->getMultiGraphicsAllocation().requiresMigrations();

if (migratableArgsMap.find(argIndex) == migratableArgsMap.end() && migrateRequiredForArg) {
migratableArgsMap.insert({argIndex, memObj});
migratableArgsMap.emplace(argIndex, memObj);
} else if (migrateRequiredForArg) {
migratableArgsMap[argIndex] = memObj;
} else {
Expand Down
4 changes: 2 additions & 2 deletions opencl/source/platform/platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,8 @@ std::vector<DeviceVector> Platform::groupDevices(DeviceVector devices) {
auto productFamily = device->getHardwareInfo().platform.eProductFamily;
auto result = platformsMap.find(productFamily);
if (result == platformsMap.end()) {
platformsMap.insert({productFamily, platformsMap.size()});
outDevices.push_back(DeviceVector{});
platformsMap.emplace(productFamily, platformsMap.size());
outDevices.emplace_back();
}
auto platformId = platformsMap[productFamily];
outDevices[platformId].push_back(std::move(device));
Expand Down
4 changes: 2 additions & 2 deletions opencl/source/program/process_device_binary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ cl_int Program::linkBinary(Device *pDevice, const void *constantsInitData, size_
for (const auto &kernelInfo : kernelInfoArray) {
auto &kernHeapInfo = kernelInfo->heapInfo;
const char *originalIsa = reinterpret_cast<const char *>(kernHeapInfo.pKernelHeap);
patchedIsaTempStorage.push_back(std::vector<char>(originalIsa, originalIsa + kernHeapInfo.kernelHeapSize));
patchedIsaTempStorage.emplace_back(originalIsa, originalIsa + kernHeapInfo.kernelHeapSize);
DEBUG_BREAK_IF(nullptr == kernelInfo->getGraphicsAllocation());
isaSegmentsForPatching.push_back(Linker::PatchableSegment{patchedIsaTempStorage.rbegin()->data(), static_cast<uintptr_t>(kernelInfo->getGraphicsAllocation()->getGpuAddressToPatch()), kernHeapInfo.kernelHeapSize});
kernelDescriptors.push_back(&kernelInfo->kernelDescriptor);
Expand All @@ -142,7 +142,7 @@ cl_int Program::linkBinary(Device *pDevice, const void *constantsInitData, size_
if (false == linkSuccess) {
std::vector<std::string> kernelNames;
for (const auto &kernelInfo : kernelInfoArray) {
kernelNames.push_back("kernel : " + kernelInfo->kernelDescriptor.kernelMetadata.kernelName);
kernelNames.emplace_back("kernel : " + kernelInfo->kernelDescriptor.kernelMetadata.kernelName);
}
auto error = constructLinkerErrorMessage(unresolvedExternalsInfo, kernelNames);
updateBuildLog(pDevice->getRootDeviceIndex(), error.c_str(), error.size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ SupportedDevicesHelper::SupportedDevicesData SupportedDevicesHelper::collectSupp
}

for (const auto &acronym : device.deviceAcronyms) {
data.acronyms.push_back({acronym.data(), device.aotConfig.value});
data.acronyms.emplace_back(acronym.data(), device.aotConfig.value);
}
}

Expand All @@ -45,7 +45,7 @@ SupportedDevicesHelper::SupportedDevicesData SupportedDevicesHelper::collectSupp
groupedDevices[device.family].push_back(device.aotConfig.value);
}
for (const auto &entry : groupedDevices) {
data.familyGroups.push_back({productConfigHelper->getAcronymFromAFamily(entry.first).data(), entry.second});
data.familyGroups.emplace_back(productConfigHelper->getAcronymFromAFamily(entry.first).data(), entry.second);
}

// Populate Release groups
Expand All @@ -56,7 +56,7 @@ SupportedDevicesHelper::SupportedDevicesData SupportedDevicesHelper::collectSupp
for (const auto &entry : groupedReleases) {
auto name = productConfigHelper->getAcronymFromARelease(entry.first);
if (!name.empty()) {
data.releaseGroups.push_back({name.data(), entry.second});
data.releaseGroups.emplace_back(name.data(), entry.second);
}
}

Expand Down Expand Up @@ -161,7 +161,7 @@ std::map<std::string, SupportedDevicesHelper::SupportedDevicesData> SupportedDev
std::string acronym = parser.readKey(acrNode).str();
uint32_t ipVersion;
if (parser.readValueChecked(acrNode, ipVersion)) {
data.acronyms.push_back({acronym, ipVersion});
data.acronyms.emplace_back(acronym, ipVersion);
}
}
}
Expand All @@ -178,7 +178,7 @@ std::map<std::string, SupportedDevicesHelper::SupportedDevicesData> SupportedDev
}
}
if (!ipVersions.empty()) {
data.familyGroups.push_back({family, ipVersions});
data.familyGroups.emplace_back(family, ipVersions);
}
}
}
Expand All @@ -195,7 +195,7 @@ std::map<std::string, SupportedDevicesHelper::SupportedDevicesData> SupportedDev
}
}
if (!ipVersions.empty()) {
data.releaseGroups.push_back({release, ipVersions});
data.releaseGroups.emplace_back(release, ipVersions);
}
}
}
Expand Down Expand Up @@ -272,14 +272,14 @@ SupportedDevicesHelper::SupportedDevicesData SupportedDevicesHelper::mergeOclocD

// Sort FamilyGroups (alphabetically by group name)
for (const auto &[family, ipVersions] : uniqueFamilyGroups) {
mergedData.familyGroups.push_back({family, std::vector<uint32_t>(ipVersions.begin(), ipVersions.end())});
mergedData.familyGroups.emplace_back(family, std::vector<uint32_t>(ipVersions.begin(), ipVersions.end()));
}
std::sort(mergedData.familyGroups.begin(), mergedData.familyGroups.end(),
[](const auto &a, const auto &b) { return a.first < b.first; });

// Sort ReleaseGroups (alphabetically by group name)
for (const auto &[release, ipVersions] : uniqueReleaseGroups) {
mergedData.releaseGroups.push_back({release, std::vector<uint32_t>(ipVersions.begin(), ipVersions.end())});
mergedData.releaseGroups.emplace_back(release, std::vector<uint32_t>(ipVersions.begin(), ipVersions.end()));
}
std::sort(mergedData.releaseGroups.begin(), mergedData.releaseGroups.end(),
[](const auto &a, const auto &b) { return a.first < b.first; });
Expand Down
4 changes: 2 additions & 2 deletions shared/offline_compiler/source/offline_compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ std::vector<NameVersionPair> OfflineCompiler::getOpenCLCFeatures(ConstStringRef

std::vector<NameVersionPair> allSupportedFeatures;
for (auto &feature : availableFeatures) {
allSupportedFeatures.push_back({feature.name, feature.version});
allSupportedFeatures.emplace_back(feature.name, feature.version);
}
return allSupportedFeatures;
}
Expand Down Expand Up @@ -245,7 +245,7 @@ std::string formatNameVersionString(std::vector<NameVersionPair> extensions, boo
std::vector<std::string> formatedExtensions;
formatedExtensions.reserve(extensions.size());
for (const auto &ext : extensions) {
formatedExtensions.push_back({});
formatedExtensions.emplace_back();
auto it = formatedExtensions.rbegin();
bool needsQuoutes = (nullptr != strstr(ext.name, " "));
it->reserve(strnlen_s(ext.name, sizeof(ext.name)) + (needsQuoutes ? 2 : 0) + (needVersions ? 16 : 0));
Expand Down
2 changes: 1 addition & 1 deletion shared/source/aub/aub_helper_add_mmio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ MMIOList AubHelper::splitMMIORegisters(const std::string &registers, char delimi
}
token.clear();
if (!firstElementInPair) {
result.push_back(std::pair<uint32_t, uint32_t>(registerOffset, registerValue));
result.emplace_back(registerOffset, registerValue);
registerValue = 0;
registerOffset = 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,13 +398,11 @@ bool AUBCommandStreamReceiverHw<GfxFamily>::addPatchInfoComments() {
str << std::endl;

if (patchInfoData.sourceAllocation) {
allocationsMap.insert(std::pair<uint64_t, uint64_t>(patchInfoData.sourceAllocation,
ppgtt->map(static_cast<uintptr_t>(patchInfoData.sourceAllocation), 1, 0, MemoryBanks::mainBank)));
allocationsMap.emplace(patchInfoData.sourceAllocation, ppgtt->map(static_cast<uintptr_t>(patchInfoData.sourceAllocation), 1, 0, MemoryBanks::mainBank));
}

if (patchInfoData.targetAllocation) {
allocationsMap.insert(std::pair<uint64_t, uintptr_t>(patchInfoData.targetAllocation,
ppgtt->map(static_cast<uintptr_t>(patchInfoData.targetAllocation), 1, 0, MemoryBanks::mainBank)));
allocationsMap.emplace(patchInfoData.targetAllocation, ppgtt->map(static_cast<uintptr_t>(patchInfoData.targetAllocation), 1, 0, MemoryBanks::mainBank));
}
}
bool result = getAubStream()->addComment(str.str().c_str());
Expand Down
2 changes: 1 addition & 1 deletion shared/source/compiler_interface/linker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ bool LinkerInput::addSymbol(Elf::Elf<numBits> &elf, const SectionNameToSegmentId

traits.exportsFunctions = true;
exportedFunctionsSegmentId = static_cast<int32_t>(symbolInfo.instructionSegmentId);
extFuncSymbols.push_back({symbolName, symbolInfo});
extFuncSymbols.emplace_back(symbolName, symbolInfo);
}
} else {
return false;
Expand Down
12 changes: 6 additions & 6 deletions shared/source/debugger/debugger_l0_tgllp_and_later.inl
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,22 @@ void DebuggerL0Hw<GfxFamily>::programSbaTrackingCommandsSingleAddressSpace(NEO::
std::vector<std::pair<size_t, uint64_t>> fieldOffsetAndValue;

if (sba.generalStateBaseAddress) {
fieldOffsetAndValue.push_back({offsetof(SbaTrackedAddresses, generalStateBaseAddress), sba.generalStateBaseAddress});
fieldOffsetAndValue.emplace_back(offsetof(SbaTrackedAddresses, generalStateBaseAddress), sba.generalStateBaseAddress);
}
if (sba.surfaceStateBaseAddress) {
fieldOffsetAndValue.push_back({offsetof(SbaTrackedAddresses, surfaceStateBaseAddress), sba.surfaceStateBaseAddress});
fieldOffsetAndValue.emplace_back(offsetof(SbaTrackedAddresses, surfaceStateBaseAddress), sba.surfaceStateBaseAddress);
}
if (sba.dynamicStateBaseAddress) {
fieldOffsetAndValue.push_back({offsetof(SbaTrackedAddresses, dynamicStateBaseAddress), sba.dynamicStateBaseAddress});
fieldOffsetAndValue.emplace_back(offsetof(SbaTrackedAddresses, dynamicStateBaseAddress), sba.dynamicStateBaseAddress);
}
if (sba.indirectObjectBaseAddress) {
fieldOffsetAndValue.push_back({offsetof(SbaTrackedAddresses, indirectObjectBaseAddress), sba.indirectObjectBaseAddress});
fieldOffsetAndValue.emplace_back(offsetof(SbaTrackedAddresses, indirectObjectBaseAddress), sba.indirectObjectBaseAddress);
}
if (sba.instructionBaseAddress) {
fieldOffsetAndValue.push_back({offsetof(SbaTrackedAddresses, instructionBaseAddress), sba.instructionBaseAddress});
fieldOffsetAndValue.emplace_back(offsetof(SbaTrackedAddresses, instructionBaseAddress), sba.instructionBaseAddress);
}
if (sba.bindlessSurfaceStateBaseAddress) {
fieldOffsetAndValue.push_back({offsetof(SbaTrackedAddresses, bindlessSurfaceStateBaseAddress), sba.bindlessSurfaceStateBaseAddress});
fieldOffsetAndValue.emplace_back(offsetof(SbaTrackedAddresses, bindlessSurfaceStateBaseAddress), sba.bindlessSurfaceStateBaseAddress);
}
const auto cmdStreamGpuBase = cmdStream.getGpuBase();
const auto cmdStreamCpuBase = reinterpret_cast<uint64_t>(cmdStream.getCpuBase());
Expand Down
2 changes: 1 addition & 1 deletion shared/source/device_binary_format/zebin/debug_zebin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Segments::Segments(const GraphicsAllocation *globalVarAlloc, const GraphicsAlloc
stringData = {reinterpret_cast<uintptr_t>(globalStrings.begin()), globalStrings.size()};
}
for (auto &[kernelName, isaSegment] : kernels) {
nameToSegMap.insert(std::pair(kernelName, isaSegment));
nameToSegMap.emplace(kernelName, isaSegment);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ DecodeError readZeInfoAttributes(const Yaml::YamlParser &parser, const Yaml::Nod
} else if (key == Tags::Kernel::Attributes::vecTypeHint) {
outAttributes.vecTypeHint = parser.readValue(attributesMetadataNd);
} else if (key.contains(Tags::Kernel::Attributes::hintSuffix.data())) {
outAttributes.otherHints.push_back({key, parser.readValue(attributesMetadataNd)});
outAttributes.otherHints.emplace_back(key, parser.readValue(attributesMetadataNd));
} else {
encounterUnknownZeInfoAttribute("\"" + key.str() + "\" in context of " + context.str(), outErrReason, outWarning, err);
}
Expand Down
2 changes: 1 addition & 1 deletion shared/source/helpers/flat_batch_buffer_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ bool FlatBatchBufferHelper::registerCommandChunk(CommandChunk &commandChunk) {
}

bool FlatBatchBufferHelper::registerBatchBufferStartAddress(uint64_t commandAddress, uint64_t startAddress) {
batchBufferStartAddressSequence.insert(std::pair<uint64_t, uint64_t>(commandAddress, startAddress));
batchBufferStartAddressSequence.emplace(commandAddress, startAddress);
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion shared/source/memory_manager/host_ptr_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ void HostPtrManager::storeFragment(uint32_t rootDeviceIndex, FragmentStorage &fr
element->second.refCount++;
} else {
fragment.refCount++;
partialAllocations.insert(std::pair<HostPtrEntryKey, FragmentStorage>(key, fragment));
partialAllocations.emplace(key, fragment);
}
}

Expand Down
2 changes: 1 addition & 1 deletion shared/source/memory_manager/memory_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ bool MemoryManager::isMemoryBudgetExhausted() const {

void MemoryManager::updateLatestContextIdForRootDevice(uint32_t rootDeviceIndex) {
// rootDeviceIndexToContextId map would contain the first entry for context for each rootDevice
auto entry = rootDeviceIndexToContextId.insert(std::pair<uint32_t, uint32_t>(rootDeviceIndex, latestContextId));
auto entry = rootDeviceIndexToContextId.emplace(rootDeviceIndex, latestContextId);
if (entry.second == false) {
if (latestContextId == std::numeric_limits<uint32_t>::max()) {
// If we are here, it means we are reinitializing the contextId.
Expand Down
2 changes: 1 addition & 1 deletion shared/source/memory_manager/unified_memory_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,7 @@ void SVMAllocsManager::insertSVMAlloc(void *svmPtr, const SvmAllocationData &all
UNRECOVERABLE_IF(internalAllocationsMap.count(allocData.getAllocId()) > 0);
for (auto alloc : allocData.gpuAllocations.getGraphicsAllocations()) {
if (alloc != nullptr) {
internalAllocationsMap.insert({allocData.getAllocId(), alloc});
internalAllocationsMap.emplace(allocData.getAllocId(), alloc);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion shared/source/program/program_initialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ GraphicsAllocation *allocateGlobalsSurface(NEO::SVMAllocsManager *const svmAlloc
RootDeviceIndicesContainer rootDeviceIndices;
rootDeviceIndices.pushUnique(rootDeviceIndex);
std::map<uint32_t, DeviceBitfield> subDeviceBitfields;
subDeviceBitfields.insert({rootDeviceIndex, deviceBitfield});
subDeviceBitfields.emplace(rootDeviceIndex, deviceBitfield);
NEO::SVMAllocsManager::UnifiedMemoryProperties unifiedMemoryProperties(InternalMemoryType::deviceUnifiedMemory, 1, rootDeviceIndices, subDeviceBitfields);
unifiedMemoryProperties.device = &device;
unifiedMemoryProperties.requestedAllocationType = allocationType;
Expand Down
2 changes: 1 addition & 1 deletion shared/source/utilities/buffer_pool_allocator.inl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ AbstractBuffersPool<PoolT, BufferType, BufferParentType>::AbstractBuffersPool(Ab
template <typename PoolT, typename BufferType, typename BufferParentType>
void AbstractBuffersPool<PoolT, BufferType, BufferParentType>::tryFreeFromPoolBuffer(BufferParentType *possiblePoolBuffer, size_t offset, size_t size) {
if (this->isPoolBuffer(possiblePoolBuffer)) {
this->chunksToFree.push_back({offset, size});
this->chunksToFree.emplace_back(offset, size);
}
}

Expand Down
2 changes: 1 addition & 1 deletion shared/source/utilities/debug_file_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ void SettingsFileReader::parseStream(std::istream &inputStream) {
}
}

settingStringMap.insert(std::pair<std::string, std::string>(key, value));
settingStringMap.emplace(key, value);
}
}
}; // namespace NEO

0 comments on commit 1763c96

Please sign in to comment.