From e1084dfdd89fad603ff245ea91319a9ea2b01b48 Mon Sep 17 00:00:00 2001 From: Kamil Kopryk Date: Fri, 5 Sep 2025 13:35:31 +0000 Subject: [PATCH] performance: optimize checking if ga is imported 2/2 Related-To: NEO-13163 Signed-off-by: Kamil Kopryk --- .../source/cmdlist/cmdlist_hw_xehp_and_later.inl | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/level_zero/core/source/cmdlist/cmdlist_hw_xehp_and_later.inl b/level_zero/core/source/cmdlist/cmdlist_hw_xehp_and_later.inl index 6f44f2b8ae..01248f723f 100644 --- a/level_zero/core/source/cmdlist/cmdlist_hw_xehp_and_later.inl +++ b/level_zero/core/source/cmdlist/cmdlist_hw_xehp_and_later.inl @@ -220,11 +220,12 @@ ze_result_t CommandListCoreFamily::appendLaunchKernelWithParams(K } } + constexpr bool checkIfImported = checkIfAllocationImportedRequired(); bool isKernelUsingSystemAllocation = false; bool isKernelUsingExternalAllocation = false; if (!launchParams.isBuiltInKernel) { - auto verifyKernelUsingSystemAllocations = [&](const NEO::ResidencyContainer &kernelResidencyContainer) { + auto verifyKernelUsingSystemAllocations = [&](const NEO::ResidencyContainer &kernelResidencyContainer) { for (const auto &allocation : kernelResidencyContainer) { if (allocation == nullptr) { continue; @@ -235,18 +236,20 @@ ze_result_t CommandListCoreFamily::appendLaunchKernelWithParams(K isKernelUsingSystemAllocation = true; } - if constexpr (checkIfAllocationImportedRequired()) { + if constexpr (checkImported) { isKernelUsingExternalAllocation = allocation->getIsImported(); } } }; - verifyKernelUsingSystemAllocations(kernel->getArgumentsResidencyContainer()); - verifyKernelUsingSystemAllocations(kernel->getInternalResidencyContainer()); + verifyKernelUsingSystemAllocations.template operator()(kernel->getArgumentsResidencyContainer()); + verifyKernelUsingSystemAllocations.template operator()(kernel->getInternalResidencyContainer()); } else { isKernelUsingSystemAllocation = launchParams.isDestinationAllocationInSystemMemory; - isKernelUsingExternalAllocation = launchParams.isDestinationAllocationImported; + if constexpr (checkIfImported) { + isKernelUsingExternalAllocation = launchParams.isDestinationAllocationImported; + } } if (kernel->hasIndirectAllocationsAllowed()) {