diff --git a/level_zero/core/source/cmdlist/cmdlist.cpp b/level_zero/core/source/cmdlist/cmdlist.cpp index db628a859c..6663fc06fb 100644 --- a/level_zero/core/source/cmdlist/cmdlist.cpp +++ b/level_zero/core/source/cmdlist/cmdlist.cpp @@ -122,7 +122,7 @@ void CommandList::removeDeallocationContainerData() { auto memoryManager = device ? device->getNEODevice()->getMemoryManager() : nullptr; auto container = commandContainer.getDeallocationContainer(); - for (auto deallocation : container) { + for (auto &deallocation : container) { DEBUG_BREAK_IF(deallocation == nullptr); UNRECOVERABLE_IF(memoryManager == nullptr); NEO::SvmAllocationData *allocData = device->getDriverHandle()->getSvmAllocsManager()->getSVMAlloc(reinterpret_cast(deallocation->getGpuAddress())); @@ -162,7 +162,7 @@ void CommandList::migrateSharedAllocations() { DriverHandleImp *driverHandleImp = static_cast(deviceImp->getDriverHandle()); std::lock_guard lock(driverHandleImp->sharedMakeResidentAllocationsLock); auto pageFaultManager = device->getDriverHandle()->getMemoryManager()->getPageFaultManager(); - for (auto alloc : driverHandleImp->sharedMakeResidentAllocations) { + for (auto &alloc : driverHandleImp->sharedMakeResidentAllocations) { pageFaultManager->moveAllocationToGpuDomain(reinterpret_cast(alloc.second->getGpuAddress())); } if (this->unifiedMemoryControls.indirectSharedAllocationsAllowed) { diff --git a/level_zero/core/source/context/context_imp.cpp b/level_zero/core/source/context/context_imp.cpp index a41285f637..f81cfd9b6e 100644 --- a/level_zero/core/source/context/context_imp.cpp +++ b/level_zero/core/source/context/context_imp.cpp @@ -44,7 +44,7 @@ ze_result_t ContextImp::destroy() { ze_result_t ContextImp::getStatus() { DriverHandleImp *driverHandleImp = static_cast(this->driverHandle); - for (auto device : driverHandleImp->devices) { + for (auto &device : driverHandleImp->devices) { DeviceImp *deviceImp = static_cast(device); if (deviceImp->resourcesReleased) { return ZE_RESULT_ERROR_DEVICE_LOST; @@ -391,7 +391,7 @@ void ContextImp::freePeerAllocations(const void *ptr, bool blocking, Device *dev deviceImp->peerAllocations.allocations.erase(iter); } - for (auto subDevice : deviceImp->subDevices) { + for (auto &subDevice : deviceImp->subDevices) { this->freePeerAllocations(ptr, blocking, subDevice); } } @@ -420,7 +420,7 @@ ze_result_t ContextImp::freeMem(const void *ptr, bool blocking) { ipcHandleIterator++; } - for (auto pairDevice : this->devices) { + for (auto &pairDevice : this->devices) { this->freePeerAllocations(ptr, blocking, Device::fromHandle(pairDevice.second)); } this->driverHandle->svmAllocsManager->freeSVMAlloc(const_cast(ptr), blocking); @@ -440,7 +440,7 @@ ze_result_t ContextImp::freeMemExt(const ze_memory_free_ext_desc_t *pMemFreeDesc return ZE_RESULT_ERROR_INVALID_ARGUMENT; } - for (auto pairDevice : this->devices) { + for (auto &pairDevice : this->devices) { this->freePeerAllocations(ptr, false, Device::fromHandle(pairDevice.second)); } diff --git a/level_zero/core/source/device/device_imp.cpp b/level_zero/core/source/device/device_imp.cpp index 1b0fc17398..c350af833a 100644 --- a/level_zero/core/source/device/device_imp.cpp +++ b/level_zero/core/source/device/device_imp.cpp @@ -83,7 +83,7 @@ ze_result_t DeviceImp::getStatus() { return ZE_RESULT_ERROR_DEVICE_LOST; } auto engines = neoDevice->getAllEngines(); - for (auto engine : engines) { + for (auto &engine : engines) { auto csr = engine.commandStreamReceiver; if (csr->isGpuHangDetected()) { return ZE_RESULT_ERROR_DEVICE_LOST; @@ -1105,7 +1105,7 @@ ze_result_t DeviceImp::systemBarrier() { return ZE_RESULT_ERROR_UNSUPPORTED_FEAT ze_result_t DeviceImp::activateMetricGroupsDeferred(uint32_t count, zet_metric_group_handle_t *phMetricGroups) { if (!this->isSubdevice && this->isImplicitScalingCapable()) { - for (auto subDevice : this->subDevices) { + for (auto &subDevice : this->subDevices) { subDevice->getMetricDeviceContext().activateMetricGroupsDeferred(count, phMetricGroups); } } else { @@ -1410,7 +1410,7 @@ NEO::GraphicsAllocation *DeviceImp::allocateManagedMemoryFromHostPtr(void *buffe if (!allocDataArray.empty()) { UNRECOVERABLE_IF(commandList == nullptr); - for (auto allocData : allocDataArray) { + for (auto &allocData : allocDataArray) { allocation = allocData->gpuAllocations.getGraphicsAllocation(getRootDeviceIndex()); char *allocAddress = reinterpret_cast(allocation->getGpuAddress()); size_t allocSize = allocData->size; diff --git a/level_zero/core/source/device/device_imp_drm/device_imp_peer.cpp b/level_zero/core/source/device/device_imp_drm/device_imp_peer.cpp index 001a2bb7a2..7625e5516d 100644 --- a/level_zero/core/source/device/device_imp_drm/device_imp_peer.cpp +++ b/level_zero/core/source/device/device_imp_drm/device_imp_peer.cpp @@ -35,7 +35,7 @@ ze_result_t DeviceImp::queryFabricStats(DeviceImp *pPeerDevice, uint32_t &latenc std::string fabricPath; fabricPath.clear(); std::vector list = NEO::Directory::getFiles(peerDevicePath + "/device"); - for (auto entry : list) { + for (auto &entry : list) { if ((entry.find(iafDirectory) != std::string::npos) || (entry.find(iafDirectoryLegacy) != std::string::npos)) { fabricPath = entry + fabricIdFile; break; @@ -71,4 +71,4 @@ ze_result_t DeviceImp::queryFabricStats(DeviceImp *pPeerDevice, uint32_t &latenc return ZE_RESULT_SUCCESS; } -} // namespace L0 \ No newline at end of file +} // namespace L0 diff --git a/level_zero/core/source/fabric/linux/fabric_device_iaf.cpp b/level_zero/core/source/fabric/linux/fabric_device_iaf.cpp index 8056caa283..f987996570 100644 --- a/level_zero/core/source/fabric/linux/fabric_device_iaf.cpp +++ b/level_zero/core/source/fabric/linux/fabric_device_iaf.cpp @@ -136,7 +136,7 @@ ze_result_t FabricSubDeviceIaf::enumerate() { } // Get Connections - for (auto iafPort : iafPorts) { + for (auto &iafPort : iafPorts) { FabricPortConnection connection = {}; ze_result_t result = getConnection(iafPort, connection); if (result != ZE_RESULT_SUCCESS) { diff --git a/level_zero/sysman/source/fabric_port/linux/sysman_fabric_device_access_imp.cpp b/level_zero/sysman/source/fabric_port/linux/sysman_fabric_device_access_imp.cpp index ac1996c9c9..42e8fa356c 100644 --- a/level_zero/sysman/source/fabric_port/linux/sysman_fabric_device_access_imp.cpp +++ b/level_zero/sysman/source/fabric_port/linux/sysman_fabric_device_access_imp.cpp @@ -175,7 +175,7 @@ ze_result_t FabricDeviceAccessNl::getPorts(std::vector &po } ports.clear(); - for (auto port : fabricPorts) { + for (auto &port : fabricPorts) { ports.push_back(port.portId); } return ZE_RESULT_SUCCESS; @@ -183,7 +183,7 @@ ze_result_t FabricDeviceAccessNl::getPorts(std::vector &po void FabricDeviceAccessNl::getProperties(const zes_fabric_port_id_t portId, std::string &model, bool &onSubdevice, uint32_t &subdeviceId, zes_fabric_port_speed_t &maxRxSpeed, zes_fabric_port_speed_t &maxTxSpeed) { - for (auto port : fabricPorts) { + for (auto &port : fabricPorts) { UNRECOVERABLE_IF(portId.fabricId != port.portId.fabricId); if (portId.attachId == port.portId.attachId && portId.portNumber == port.portId.portNumber) { model = port.model; @@ -214,7 +214,7 @@ void FabricDeviceAccessNl::populateGuidMap() { if (ZE_RESULT_SUCCESS != getAllFabricIds(fabricIds)) { return; } - for (auto fabricId : fabricIds) { + for (auto &fabricId : fabricIds) { uint32_t numSubdevices = 0; if (ZE_RESULT_SUCCESS != getNumSubdevices(fabricId, numSubdevices)) { diff --git a/level_zero/sysman/source/linux/nl_api/sysman_iaf_nl_api.cpp b/level_zero/sysman/source/linux/nl_api/sysman_iaf_nl_api.cpp index 492939704c..262c0c03cc 100644 --- a/level_zero/sysman/source/linux/nl_api/sysman_iaf_nl_api.cpp +++ b/level_zero/sysman/source/linux/nl_api/sysman_iaf_nl_api.cpp @@ -621,7 +621,7 @@ int IafNlApi::nlOperation(struct nl_cache_ops *ops, struct genl_cmd *cmd, struct if (info->attrs[IAF_ATTR_CMD_OP_CONTEXT]) { uint64_t context = pNlApi->nlaGetU64(info->attrs[IAF_ATTR_CMD_OP_CONTEXT]); bool found = false; - for (auto i : validContexts) { + for (auto &i : validContexts) { if (context == i) { found = true; break; @@ -700,7 +700,7 @@ ze_result_t IafNlApi::initPorts(const uint32_t fabricId, std::vector &i iafPorts.clear(); return ZE_RESULT_ERROR_UNKNOWN; } - for (auto port : ports) { + for (auto &port : ports) { IafPort p = {}; IafPortSpeed rxSpeed, txSpeed; uint8_t neighbourPortNumber = 0; @@ -726,7 +726,7 @@ ze_result_t IafNlApi::getPorts(const std::string &devicePciPath, std::vector list = NEO::Directory::getFiles(devicePciPath); - for (auto entry : list) { + for (auto &entry : list) { if ((entry.find(iafDirectory) != std::string::npos) || (entry.find(iafDirectoryLegacy) != std::string::npos)) { path = entry + fabricIdFile; diff --git a/level_zero/tools/source/debug/linux/prelim/debug_session.cpp b/level_zero/tools/source/debug/linux/prelim/debug_session.cpp index cb854aa72a..b61f81b354 100644 --- a/level_zero/tools/source/debug/linux/prelim/debug_session.cpp +++ b/level_zero/tools/source/debug/linux/prelim/debug_session.cpp @@ -1419,12 +1419,12 @@ void DebugSessionLinux::handlePageFaultEvent(prelim_drm_i915_debug_event_page_fa } else { lock = std::unique_lock(threadStateMutex); } - for (auto threadId : threadsWithPF) { + for (auto &threadId : threadsWithPF) { PRINT_DEBUGGER_INFO_LOG("PageFault event for thread %s", EuThread::toString(threadId).c_str()); allThreads[threadId]->setPageFault(true); } - for (auto threadId : stoppedThreads) { + for (auto &threadId : stoppedThreads) { if (tileSessionsEnabled) { static_cast(tileSessions[tileIndex].first)->addThreadToNewlyStoppedFromRaisedAttention(threadId, vmHandle, stateSaveAreaMemory.data()); } else { diff --git a/level_zero/tools/source/sysman/fabric_port/linux/fabric_device_access_imp.cpp b/level_zero/tools/source/sysman/fabric_port/linux/fabric_device_access_imp.cpp index 3cb97503c6..5c9d3e43d5 100644 --- a/level_zero/tools/source/sysman/fabric_port/linux/fabric_device_access_imp.cpp +++ b/level_zero/tools/source/sysman/fabric_port/linux/fabric_device_access_imp.cpp @@ -174,7 +174,7 @@ ze_result_t FabricDeviceAccessNl::getPorts(std::vector &po } ports.clear(); - for (auto port : fabricPorts) { + for (auto &port : fabricPorts) { ports.push_back(port.portId); } return ZE_RESULT_SUCCESS; @@ -182,7 +182,7 @@ ze_result_t FabricDeviceAccessNl::getPorts(std::vector &po void FabricDeviceAccessNl::getProperties(const zes_fabric_port_id_t portId, std::string &model, bool &onSubdevice, uint32_t &subdeviceId, zes_fabric_port_speed_t &maxRxSpeed, zes_fabric_port_speed_t &maxTxSpeed) { - for (auto port : fabricPorts) { + for (auto &port : fabricPorts) { UNRECOVERABLE_IF(portId.fabricId != port.portId.fabricId); if (portId.attachId == port.portId.attachId && portId.portNumber == port.portId.portNumber) { model = port.model; @@ -213,7 +213,7 @@ void FabricDeviceAccessNl::populateGuidMap() { if (ZE_RESULT_SUCCESS != getAllFabricIds(fabricIds)) { return; } - for (auto fabricId : fabricIds) { + for (auto &fabricId : fabricIds) { uint32_t numSubdevices = 0; if (ZE_RESULT_SUCCESS != getNumSubdevices(fabricId, numSubdevices)) { diff --git a/level_zero/tools/source/sysman/linux/nl_api/iaf_nl_api.cpp b/level_zero/tools/source/sysman/linux/nl_api/iaf_nl_api.cpp index 6e9a269727..712ed6ccc9 100644 --- a/level_zero/tools/source/sysman/linux/nl_api/iaf_nl_api.cpp +++ b/level_zero/tools/source/sysman/linux/nl_api/iaf_nl_api.cpp @@ -620,7 +620,7 @@ int IafNlApi::nlOperation(struct nl_cache_ops *ops, struct genl_cmd *cmd, struct if (info->attrs[IAF_ATTR_CMD_OP_CONTEXT]) { uint64_t context = pNlApi->nlaGetU64(info->attrs[IAF_ATTR_CMD_OP_CONTEXT]); bool found = false; - for (auto i : validContexts) { + for (auto &i : validContexts) { if (context == i) { found = true; break; @@ -699,7 +699,7 @@ ze_result_t IafNlApi::initPorts(const uint32_t fabricId, std::vector &i iafPorts.clear(); return ZE_RESULT_ERROR_UNKNOWN; } - for (auto port : ports) { + for (auto &port : ports) { IafPort p = {}; IafPortSpeed rxSpeed, txSpeed; uint8_t neighbourPortNumber = 0; @@ -725,7 +725,7 @@ ze_result_t IafNlApi::getPorts(const std::string &devicePciPath, std::vector list = NEO::Directory::getFiles(devicePciPath); - for (auto entry : list) { + for (auto &entry : list) { if ((entry.find(iafDirectory) != std::string::npos) || (entry.find(iafDirectoryLegacy) != std::string::npos)) { path = entry + fabricIdFile; diff --git a/opencl/source/cl_device/cl_device_caps.cpp b/opencl/source/cl_device/cl_device_caps.cpp index 474ff8eed7..2ce1101676 100644 --- a/opencl/source/cl_device/cl_device_caps.cpp +++ b/opencl/source/cl_device/cl_device_caps.cpp @@ -229,7 +229,7 @@ void ClDevice::initializeCaps() { exposedBuiltinKernelsVector.push_back("block_advanced_motion_estimate_check_intel"); exposedBuiltinKernelsVector.push_back("block_advanced_motion_estimate_bidirectional_check_intel"); } - for (auto builtInKernel : exposedBuiltinKernelsVector) { + for (auto &builtInKernel : exposedBuiltinKernelsVector) { exposedBuiltinKernels.append(builtInKernel); exposedBuiltinKernels.append(";"); @@ -433,7 +433,7 @@ void ClDevice::initializeExtensionsWithVersion() { std::vector deviceExtensionsVector{ std::istream_iterator{deviceExtensionsStringStream}, std::istream_iterator{}}; deviceInfo.extensionsWithVersion.reserve(deviceExtensionsVector.size()); - for (auto deviceExtension : deviceExtensionsVector) { + for (auto &deviceExtension : deviceExtensionsVector) { cl_name_version deviceExtensionWithVersion; deviceExtensionWithVersion.version = getExtensionVersion(deviceExtension); strcpy_s(deviceExtensionWithVersion.name, CL_NAME_VERSION_MAX_NAME_SIZE, deviceExtension.c_str()); diff --git a/opencl/source/command_queue/resource_barrier.cpp b/opencl/source/command_queue/resource_barrier.cpp index 62e1182a8f..8c85f161db 100644 --- a/opencl/source/command_queue/resource_barrier.cpp +++ b/opencl/source/command_queue/resource_barrier.cpp @@ -18,7 +18,7 @@ namespace NEO { BarrierCommand::BarrierCommand(CommandQueue *commandQueue, const cl_resource_barrier_descriptor_intel *descriptors, uint32_t numDescriptors) : numSurfaces(numDescriptors) { - for (auto description : createRange(descriptors, numDescriptors)) { + for (auto &description : createRange(descriptors, numDescriptors)) { GraphicsAllocation *allocation; if (description.memObject) { MemObj *memObj = nullptr; diff --git a/shared/source/compiler_interface/compiler_options.h b/shared/source/compiler_interface/compiler_options.h index e6d2d467a0..ed8bcdcd10 100644 --- a/shared/source/compiler_interface/compiler_options.h +++ b/shared/source/compiler_interface/compiler_options.h @@ -114,7 +114,7 @@ inline std::string concatenate(T &&arg, RestT &&...rest) { template constexpr size_t concatenationLength(const ConstStringRef (&options)[NumOptions]) { size_t ret = 0U; - for (auto opt : options) { + for (auto &opt : options) { ret += spaceSeparatorSize + opt.length(); } return (ret != 0U) ? ret - nullterminateSize : 0U; @@ -141,7 +141,7 @@ class ConstConcatenation { template constexpr ConstConcatenation(const ConstStringRef (&options)[NumOptions]) { size_t i = 0U; - for (auto opt : options) { + for (auto &opt : options) { for (size_t j = 0U, e = opt.length(); j < e; ++j, ++i) { storage[i] = opt[j]; } diff --git a/shared/source/memory_manager/memory_manager.cpp b/shared/source/memory_manager/memory_manager.cpp index 0055f6e0cd..cfc49365ee 100644 --- a/shared/source/memory_manager/memory_manager.cpp +++ b/shared/source/memory_manager/memory_manager.cpp @@ -216,7 +216,7 @@ void *MemoryManager::createMultiGraphicsAllocationInSystemMemoryPool(RootDeviceI auto graphicsAllocation = createGraphicsAllocationFromExistingStorage(properties, ptr, multiGraphicsAllocation); if (!graphicsAllocation) { - for (auto gpuAllocation : multiGraphicsAllocation.getGraphicsAllocations()) { + for (auto &gpuAllocation : multiGraphicsAllocation.getGraphicsAllocations()) { freeGraphicsMemory(gpuAllocation); } return nullptr; diff --git a/shared/source/os_interface/linux/drm_debug.cpp b/shared/source/os_interface/linux/drm_debug.cpp index c61917a746..f87281a092 100644 --- a/shared/source/os_interface/linux/drm_debug.cpp +++ b/shared/source/os_interface/linux/drm_debug.cpp @@ -19,7 +19,7 @@ namespace NEO { bool Drm::registerResourceClasses() { - for (auto classNameUUID : classNamesToUuid) { + for (auto &classNameUUID : classNamesToUuid) { auto className = classNameUUID.first; auto uuid = classNameUUID.second; diff --git a/shared/source/os_interface/linux/memory_info.cpp b/shared/source/os_interface/linux/memory_info.cpp index 80ddb6f045..174e8fc52c 100644 --- a/shared/source/os_interface/linux/memory_info.cpp +++ b/shared/source/os_interface/linux/memory_info.cpp @@ -102,7 +102,7 @@ size_t MemoryInfo::getMemoryRegionSize(uint32_t memoryBank) { } void MemoryInfo::printRegionSizes() { - for (auto region : drmQueryRegions) { + for (auto ®ion : drmQueryRegions) { std::cout << "Memory type: " << region.region.memoryClass << ", memory instance: " << region.region.memoryInstance << ", region size: " << region.probedSize << std::endl;