Skip to content

Commit bbe59e1

Browse files
authored
[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.
1 parent c2f0af5 commit bbe59e1

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

offload/libomptarget/PluginManager.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -286,16 +286,16 @@ void PluginManager::registerLib(__tgt_bin_desc *Desc) {
286286
}
287287
PM->RTLsMtx.unlock();
288288

289-
bool UseAutoZeroCopy = Plugins.size() > 0;
289+
bool UseAutoZeroCopy = false;
290290

291291
auto ExclusiveDevicesAccessor = getExclusiveDevicesAccessor();
292-
for (const auto &Device : *ExclusiveDevicesAccessor)
293-
UseAutoZeroCopy &= Device->useAutoZeroCopy();
292+
// APUs are homogeneous set of GPUs. Check the first device for
293+
// configuring Auto Zero-Copy.
294+
if (ExclusiveDevicesAccessor->size() > 0) {
295+
auto &Device = *(*ExclusiveDevicesAccessor)[0];
296+
UseAutoZeroCopy = Device.useAutoZeroCopy();
297+
}
294298

295-
// Auto Zero-Copy can only be currently triggered when the system is an
296-
// homogeneous APU architecture without attached discrete GPUs.
297-
// If all devices suggest to use it, change requirement flags to trigger
298-
// zero-copy behavior when mapping memory.
299299
if (UseAutoZeroCopy)
300300
addRequirements(OMPX_REQ_AUTO_ZERO_COPY);
301301

0 commit comments

Comments
 (0)