[llvm-branch-commits] [llvm] [offload][omp] Use liboffload queues for memory operations (PR #221281)

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Sep 4 09:46:25 PDT 2026


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp,h -- offload/include/PluginManager.h offload/include/device.h offload/include/omptarget.h offload/liboffload/src/OffloadImpl.cpp offload/libompaccsupport/PluginManager.cpp offload/libompaccsupport/device.cpp offload/libomptarget/OpenMP/API.cpp offload/libomptarget/omptarget.cpp offload/plugins-nextgen/common/include/PluginInterface.h offload/plugins-nextgen/common/src/PluginInterface.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/offload/libompaccsupport/PluginManager.cpp b/offload/libompaccsupport/PluginManager.cpp
index 94f2beb6a..d20d4ec26 100644
--- a/offload/libompaccsupport/PluginManager.cpp
+++ b/offload/libompaccsupport/PluginManager.cpp
@@ -68,8 +68,8 @@ void PluginManager::deinit() {
   auto ExclusiveDevicesAccessor = getExclusiveDevicesAccessor();
   for (auto &Device : *ExclusiveDevicesAccessor)
     if (auto Err = Device->deinit())
-      REPORT() << "Failed to deinitialize device " << Device->DeviceID
-               << ": " << toString(std::move(Err));
+      REPORT() << "Failed to deinitialize device " << Device->DeviceID << ": "
+               << toString(std::move(Err));
 
   Plugins.clear();
   if (auto Res = olShutDown())
@@ -506,12 +506,10 @@ static int loadImagesOntoDevice(DeviceTy &Device) {
               ((PM->getRequirements() & OMP_REQ_UNIFIED_SHARED_MEMORY) ||
                (PM->getRequirements() & OMPX_REQ_AUTO_ZERO_COPY))) {
             AsyncInfoTy AsyncInfo(Device);
-            if (Device.submitData(DeviceEntry.Address,
-                                  Entry.Address,
-                                  Entry.Size,
-                                  AsyncInfo) != OFFLOAD_SUCCESS)
+            if (Device.submitData(DeviceEntry.Address, Entry.Address,
+                                  Entry.Size, AsyncInfo) != OFFLOAD_SUCCESS)
               REPORT() << "Failed to write symbol for USM " << Entry.SymbolName;
-           }
+          }
         } else if (Entry.Address) {
           if (Device.RTL->get_function(Binary, Entry.SymbolName,
                                        &DeviceEntry.Address) != OFFLOAD_SUCCESS)
diff --git a/offload/libompaccsupport/device.cpp b/offload/libompaccsupport/device.cpp
index 254021f30..7de4b23e9 100644
--- a/offload/libompaccsupport/device.cpp
+++ b/offload/libompaccsupport/device.cpp
@@ -122,9 +122,9 @@ llvm::Error DeviceTy::init() {
 
 llvm::Error DeviceTy::deinit() {
   if (olDestroyContext(Context)) {
-    return error::createOffloadError(error::ErrorCode::BACKEND_FAILURE,
-                                     "failed to destroy context for device %d\n",
-                                     DeviceID);
+    return error::createOffloadError(
+        error::ErrorCode::BACKEND_FAILURE,
+        "failed to destroy context for device %d\n", DeviceID);
   }
   return llvm::Error::success();
 }
diff --git a/offload/libomptarget/OpenMP/API.cpp b/offload/libomptarget/OpenMP/API.cpp
index 80a0325a7..0f1c0a685 100644
--- a/offload/libomptarget/OpenMP/API.cpp
+++ b/offload/libomptarget/OpenMP/API.cpp
@@ -340,8 +340,8 @@ EXTERN int omp_target_memcpy(void *Dst, const void *Src, size_t Length,
       FATAL_MESSAGE(DstDevice, "%s",
                     toString(DstDeviceOrErr.takeError()).c_str());
     AsyncInfoTy AsyncInfo(*SrcDeviceOrErr);
-    Rc = SrcDeviceOrErr->dataExchange(SrcAddr, *DstDeviceOrErr, DstAddr,
-                                        Length, AsyncInfo);
+    Rc = SrcDeviceOrErr->dataExchange(SrcAddr, *DstDeviceOrErr, DstAddr, Length,
+                                      AsyncInfo);
   }
 
   ODBG(ODT_Interface) << __func__ << " returns " << Rc;
@@ -470,7 +470,8 @@ EXTERN void *omp_target_memset(void *Ptr, int ByteVal, size_t NumBytes,
     AsyncInfoTy AsyncInfo(*DeviceOrErr);
     ol_queue_handle_t Queue = AsyncInfo.getQueue();
     if (!Queue) {
-      ODBG(ODT_Interface) << "Failed to get queue for async memset on device " << DeviceNum;
+      ODBG(ODT_Interface) << "Failed to get queue for async memset on device "
+                          << DeviceNum;
       return Ptr;
     }
     if (auto Res = olMemFill(Queue, Ptr, 1, &ByteVal, NumBytes)) {
diff --git a/offload/libomptarget/omptarget.cpp b/offload/libomptarget/omptarget.cpp
index 07286cd75..f5343fe61 100644
--- a/offload/libomptarget/omptarget.cpp
+++ b/offload/libomptarget/omptarget.cpp
@@ -44,7 +44,7 @@ using namespace llvm::omp::target::ompt;
 using namespace llvm::omp::target::debug;
 
 AsyncInfoTy::AsyncInfoTy(DeviceTy &Device, SyncTy SyncType)
-      : Device(Device), SyncType(SyncType) {
+    : Device(Device), SyncType(SyncType) {
 
   if (auto Res = olCreateQueue(Device.Context, Device.DeviceHandle, &Queue)) {
     REPORT() << "Failed to create queue for device " << Device.DeviceHandle

``````````

</details>


https://github.com/llvm/llvm-project/pull/221281


More information about the llvm-branch-commits mailing list