From 49e0811a4431478fdae33026454c20c06dbca2b0 Mon Sep 17 00:00:00 2001 From: Kewen Meng Date: Tue, 10 Jun 2025 17:07:51 -0500 Subject: [PATCH] [OpenMP][Offload] Update the Logic for Configuring Auto Zero-Copy 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 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 93589960a426d..c4d99dfa9f10c 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);