From bbe59e19b60b0efa8cc200fb3260fe572e188b26 Mon Sep 17 00:00:00 2001 From: Kewen12 Date: Wed, 11 Jun 2025 11:12:54 -0700 Subject: [PATCH] [OpenMP][Offload] Update the Logic for Configuring Auto Zero-Copy (#143638) Summary: Currently the Auto Zero-Copy is enabled by checking every initialized device to ensure that no dGPU is attached to an APU. However, an APU is designed to comprise a homogeneous set of GPUs, therefore, it should be sufficient to check any device for configuring Auto Zero-Copy. In this PR, it checks the first initialized device in the list. The changes in this PR are to clearly reflect the design and logic of enabling the feature for further improving the readibility. --- offload/libomptarget/PluginManager.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/offload/libomptarget/PluginManager.cpp b/offload/libomptarget/PluginManager.cpp index 93589960a426..c4d99dfa9f10 100644 --- a/offload/libomptarget/PluginManager.cpp +++ b/offload/libomptarget/PluginManager.cpp @@ -286,16 +286,16 @@ void PluginManager::registerLib(__tgt_bin_desc *Desc) { } PM->RTLsMtx.unlock(); - bool UseAutoZeroCopy = Plugins.size() > 0; + bool UseAutoZeroCopy = false; auto ExclusiveDevicesAccessor = getExclusiveDevicesAccessor(); - for (const auto &Device : *ExclusiveDevicesAccessor) - UseAutoZeroCopy &= Device->useAutoZeroCopy(); + // APUs are homogeneous set of GPUs. Check the first device for + // configuring Auto Zero-Copy. + if (ExclusiveDevicesAccessor->size() > 0) { + auto &Device = *(*ExclusiveDevicesAccessor)[0]; + UseAutoZeroCopy = Device.useAutoZeroCopy(); + } - // Auto Zero-Copy can only be currently triggered when the system is an - // homogeneous APU architecture without attached discrete GPUs. - // If all devices suggest to use it, change requirement flags to trigger - // zero-copy behavior when mapping memory. if (UseAutoZeroCopy) addRequirements(OMPX_REQ_AUTO_ZERO_COPY);