From f90932cca7f50e0ebea3d153156dff5fb0121f4b Mon Sep 17 00:00:00 2001 From: Zbigniew Zdanowicz Date: Thu, 11 Nov 2021 01:35:57 +0000 Subject: [PATCH] Use references instead copy ctors Signed-off-by: Zbigniew Zdanowicz --- level_zero/core/source/cmdlist/cmdlist_hw.inl | 2 +- level_zero/core/source/device/device_imp.cpp | 2 +- .../gen12lp/definitions/cache_flush_gen12lp.inl | 2 +- level_zero/core/source/kernel/kernel_imp.cpp | 5 +++-- level_zero/tools/source/debug/debug_session.cpp | 12 ++++++------ opencl/source/kernel/kernel.cpp | 4 ++-- .../command_stream_receiver_hw_xehp_and_later.inl | 6 +++--- .../command_stream/preemption_xehp_and_later.inl | 4 ++-- 8 files changed, 19 insertions(+), 18 deletions(-) diff --git a/level_zero/core/source/cmdlist/cmdlist_hw.inl b/level_zero/core/source/cmdlist/cmdlist_hw.inl index f010ee708b..8df4138aae 100644 --- a/level_zero/core/source/cmdlist/cmdlist_hw.inl +++ b/level_zero/core/source/cmdlist/cmdlist_hw.inl @@ -332,7 +332,7 @@ ze_result_t CommandListCoreFamily::appendEventReset(ze_event_hand POST_SYNC_OPERATION::POST_SYNC_OPERATION_WRITE_IMMEDIATE_DATA, baseAddr, Event::STATE_CLEARED, - commandContainer.getDevice()->getHardwareInfo(), + hwInfo, args); baseAddr += event->getSinglePacketSize(); } diff --git a/level_zero/core/source/device/device_imp.cpp b/level_zero/core/source/device/device_imp.cpp index a97ea24c75..dbb79c40c8 100644 --- a/level_zero/core/source/device/device_imp.cpp +++ b/level_zero/core/source/device/device_imp.cpp @@ -821,7 +821,7 @@ Device *Device::create(DriverHandle *driverHandle, NEO::Device *neoDevice, bool stateSaveAreaHeader.size()); } - for (auto &neoSubDevice : device->neoDevice->getSubDevices()) { + for (auto &neoSubDevice : neoDevice->getSubDevices()) { if (!neoSubDevice) { continue; } diff --git a/level_zero/core/source/gen12lp/definitions/cache_flush_gen12lp.inl b/level_zero/core/source/gen12lp/definitions/cache_flush_gen12lp.inl index e4a5c130d1..0968934f6d 100644 --- a/level_zero/core/source/gen12lp/definitions/cache_flush_gen12lp.inl +++ b/level_zero/core/source/gen12lp/definitions/cache_flush_gen12lp.inl @@ -70,7 +70,7 @@ void CommandListCoreFamily::applyMemoryRangesBarrier(uint32_t num NEO::flushGpuCache(commandStream, subranges, postSyncAddressToFlush, - device->getHwInfo()); + hwInfo); } } } diff --git a/level_zero/core/source/kernel/kernel_imp.cpp b/level_zero/core/source/kernel/kernel_imp.cpp index 22689e7535..f7446471ec 100644 --- a/level_zero/core/source/kernel/kernel_imp.cpp +++ b/level_zero/core/source/kernel/kernel_imp.cpp @@ -406,8 +406,9 @@ ze_result_t KernelImp::suggestGroupSize(uint32_t globalSizeX, uint32_t globalSiz if (NEO::DebugManager.flags.EnableComputeWorkSizeND.get()) { auto usesImages = getImmutableData()->getDescriptor().kernelAttributes.flags.usesImages; - const auto hwInfo = &module->getDevice()->getNEODevice()->getHardwareInfo(); - const auto &deviceInfo = module->getDevice()->getNEODevice()->getDeviceInfo(); + auto neoDevice = module->getDevice()->getNEODevice(); + const auto hwInfo = &neoDevice->getHardwareInfo(); + const auto &deviceInfo = neoDevice->getDeviceInfo(); uint32_t numThreadsPerSubSlice = (uint32_t)deviceInfo.maxNumEUsPerSubSlice * deviceInfo.numThreadsPerEU; uint32_t localMemSize = (uint32_t)deviceInfo.localMemSize; diff --git a/level_zero/tools/source/debug/debug_session.cpp b/level_zero/tools/source/debug/debug_session.cpp index 7d5a22f02b..a34f1a2b4f 100644 --- a/level_zero/tools/source/debug/debug_session.cpp +++ b/level_zero/tools/source/debug/debug_session.cpp @@ -14,7 +14,7 @@ namespace L0 { ze_device_thread_t DebugSession::convertToPhysical(ze_device_thread_t thread, uint32_t &deviceIndex) { - auto hwInfo = connectedDevice->getHwInfo(); + auto &hwInfo = connectedDevice->getHwInfo(); auto deviceBitfield = connectedDevice->getNEODevice()->getDeviceBitfield(); if (connectedDevice->getNEODevice()->isSubDevice()) { @@ -28,7 +28,7 @@ ze_device_thread_t DebugSession::convertToPhysical(ze_device_thread_t thread, ui } EuThread::ThreadId DebugSession::convertToThreadId(ze_device_thread_t thread) { - auto hwInfo = connectedDevice->getHwInfo(); + auto &hwInfo = connectedDevice->getHwInfo(); auto deviceBitfield = connectedDevice->getNEODevice()->getDeviceBitfield(); UNRECOVERABLE_IF(!DebugSession::isSingleThread(thread)); @@ -46,7 +46,7 @@ EuThread::ThreadId DebugSession::convertToThreadId(ze_device_thread_t thread) { } ze_device_thread_t DebugSession::convertToApi(EuThread::ThreadId threadId) { - auto hwInfo = connectedDevice->getHwInfo(); + auto &hwInfo = connectedDevice->getHwInfo(); ze_device_thread_t thread = {static_cast(threadId.slice), static_cast(threadId.subslice), static_cast(threadId.eu), static_cast(threadId.thread)}; @@ -59,7 +59,7 @@ ze_device_thread_t DebugSession::convertToApi(EuThread::ThreadId threadId) { DebugSession::DebugSession(const zet_debug_config_t &config, Device *device) : connectedDevice(device) { if (connectedDevice) { - auto hwInfo = connectedDevice->getHwInfo(); + auto &hwInfo = connectedDevice->getHwInfo(); const uint32_t numSubslicesPerSlice = hwInfo.gtSystemInfo.MaxSubSlicesSupported / hwInfo.gtSystemInfo.MaxSlicesSupported; const uint32_t numEuPerSubslice = hwInfo.gtSystemInfo.MaxEuPerSubSlice; const uint32_t numThreadsPerEu = (hwInfo.gtSystemInfo.ThreadCount / hwInfo.gtSystemInfo.EUCount); @@ -140,7 +140,7 @@ std::vector DebugSession::getSingleThreadsForDevice(uint32_t } bool DebugSession::areRequestedThreadsStopped(ze_device_thread_t thread) { - auto hwInfo = connectedDevice->getHwInfo(); + auto &hwInfo = connectedDevice->getHwInfo(); uint32_t deviceIndex = 0; auto physicalThread = convertToPhysical(thread, deviceIndex); auto singleThreads = getSingleThreadsForDevice(deviceIndex, physicalThread, hwInfo); @@ -204,7 +204,7 @@ bool DebugSession::isBindlessSystemRoutine() { } size_t DebugSession::getPerThreadScratchOffset(size_t ptss, EuThread::ThreadId threadId) { - auto hwInfo = connectedDevice->getHwInfo(); + auto &hwInfo = connectedDevice->getHwInfo(); const uint32_t numSubslicesPerSlice = hwInfo.gtSystemInfo.MaxSubSlicesSupported / hwInfo.gtSystemInfo.MaxSlicesSupported; const uint32_t numEuPerSubslice = hwInfo.gtSystemInfo.MaxEuPerSubSlice; const uint32_t numThreadsPerEu = (hwInfo.gtSystemInfo.ThreadCount / hwInfo.gtSystemInfo.EUCount); diff --git a/opencl/source/kernel/kernel.cpp b/opencl/source/kernel/kernel.cpp index fb50f40adc..fccf2ae4eb 100644 --- a/opencl/source/kernel/kernel.cpp +++ b/opencl/source/kernel/kernel.cpp @@ -77,12 +77,12 @@ Kernel::Kernel(Program *programArg, const KernelInfo &kernelInfoArg, ClDevice &c program->retain(); program->retainForKernel(); imageTransformer.reset(new ImageTransformer); + auto &deviceInfo = getDevice().getDevice().getDeviceInfo(); if (kernelInfoArg.kernelDescriptor.kernelAttributes.simdSize == 1u) { - auto deviceInfo = getDevice().getDevice().getDeviceInfo(); auto &hwInfoConfig = *HwInfoConfig::get(getHardwareInfo().platform.eProductFamily); maxKernelWorkGroupSize = hwInfoConfig.getMaxThreadsForWorkgroupInDSSOrSS(getHardwareInfo(), static_cast(deviceInfo.maxNumEUsPerSubSlice), static_cast(deviceInfo.maxNumEUsPerDualSubSlice)); } else { - maxKernelWorkGroupSize = static_cast(clDevice.getSharedDeviceInfo().maxWorkGroupSize); + maxKernelWorkGroupSize = static_cast(deviceInfo.maxWorkGroupSize); } slmTotalSize = kernelInfoArg.kernelDescriptor.kernelAttributes.slmInlineSize; } diff --git a/shared/source/command_stream/command_stream_receiver_hw_xehp_and_later.inl b/shared/source/command_stream/command_stream_receiver_hw_xehp_and_later.inl index dce43e3ecb..feaad76369 100644 --- a/shared/source/command_stream/command_stream_receiver_hw_xehp_and_later.inl +++ b/shared/source/command_stream/command_stream_receiver_hw_xehp_and_later.inl @@ -56,7 +56,7 @@ size_t CommandStreamReceiverHw::getCmdSizeForComputeMode() { } size_t size = 0; - auto hwInfo = peekHwInfo(); + auto &hwInfo = peekHwInfo(); if (isComputeModeNeeded()) { auto hwInfoConfig = HwInfoConfig::get(hwInfo.platform.eProductFamily); if (hwInfoConfig->isPipeControlPriorToNonPipelinedStateCommandsWARequired(hwInfo, isRcs())) { @@ -168,7 +168,7 @@ void CommandStreamReceiverHw::programActivePartitionConfig() { template inline void CommandStreamReceiverHw::addPipeControlPriorToNonPipelinedStateCommand(LinearStream &commandStream, PipeControlArgs args) { - auto hwInfo = peekHwInfo(); + auto &hwInfo = peekHwInfo(); auto hwInfoConfig = HwInfoConfig::get(hwInfo.platform.eProductFamily); if (hwInfoConfig->isPipeControlPriorToNonPipelinedStateCommandsWARequired(hwInfo, isRcs())) { @@ -189,7 +189,7 @@ inline void CommandStreamReceiverHw::addPipeControlPriorToNonPipeline template inline void CommandStreamReceiverHw::addPipeControlBeforeStateSip(LinearStream &commandStream, Device &device) { - auto hwInfo = peekHwInfo(); + auto &hwInfo = peekHwInfo(); HwHelper &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily); auto hwInfoConfig = HwInfoConfig::get(hwInfo.platform.eProductFamily); bool debuggingEnabled = device.getDebugger() != nullptr; diff --git a/shared/source/command_stream/preemption_xehp_and_later.inl b/shared/source/command_stream/preemption_xehp_and_later.inl index 11dd97c6ec..a867edcaf0 100644 --- a/shared/source/command_stream/preemption_xehp_and_later.inl +++ b/shared/source/command_stream/preemption_xehp_and_later.inl @@ -14,7 +14,7 @@ void PreemptionHelper::programStateSip(LinearStream &preambleCmdStrea using STATE_SIP = typename GfxFamily::STATE_SIP; using MI_LOAD_REGISTER_IMM = typename GfxFamily::MI_LOAD_REGISTER_IMM; - auto hwInfo = device.getHardwareInfo(); + auto &hwInfo = device.getHardwareInfo(); bool debuggingEnabled = device.getDebugger() != nullptr; if (debuggingEnabled) { @@ -73,7 +73,7 @@ template <> size_t PreemptionHelper::getRequiredStateSipCmdSize(Device &device, bool isRcs) { size_t size = 0; bool debuggingEnabled = device.getDebugger() != nullptr || device.isDebuggerActive(); - auto hwInfo = device.getHardwareInfo(); + auto &hwInfo = device.getHardwareInfo(); if (debuggingEnabled) { HwHelper &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily);