[Openmp-commits] [llvm] [openmp] [OFFLOAD][OPENMP] 6.0 compatible interop interface (PR #143491)

Kevin Sala Penades via Openmp-commits openmp-commits at lists.llvm.org
Wed Jul 16 11:16:36 PDT 2025


================
@@ -34,10 +87,96 @@ typedef struct omp_interop_val_t {
   __tgt_device_info device_info;
   const kmp_interop_type_t interop_type;
   const intptr_t device_id;
-  const omp_foreign_runtime_ids_t vendor_id = cuda;
-  const intptr_t backend_type_id = omp_interop_backend_type_cuda_1;
+  omp_vendor_id_t vendor_id = omp_vendor_llvm;
+  omp_foreign_runtime_id_t fr_id = omp_fr_none;
+  interop_attrs_t attrs{false, 0}; // Common prefer specification attributes
+  int64_t impl_attrs = 0; // Implementation prefer specification attributes
+
+  void *RTLProperty = nullptr; // Plugin dependent information
+  // For implicitly created Interop objects (e.g., from a dispatch construct)
+  // who owns the object
+  int OwnerGtid = -1;
+  // Marks whether the object was requested since the last time it was synced
+  bool Clean = true;
+
+  typedef llvm::SmallVector<omp_interop_cb_instance_t> callback_list_t;
+
+  callback_list_t CompletionCbs;
+
+  void reset() {
+    OwnerGtid = -1;
+    markClean();
+    clearCompletionCbs();
+  }
+
+  bool hasOwner() const { return OwnerGtid != -1; }
+
+  void setOwner(int gtid) { OwnerGtid = gtid; }
+  bool isOwnedBy(int gtid) { return OwnerGtid == gtid; }
+  bool isCompatibleWith(int32_t InteropType, const interop_spec_t &Spec);
+  bool isCompatibleWith(int32_t InteropType, const interop_spec_t &Spec,
+                        int64_t DeviceNum, int gtid);
+  void markClean() { Clean = true; }
+  void markDirty() { Clean = false; }
+  bool isClean() const { return Clean; }
+
+  int32_t flush(DeviceTy &Device);
+  int32_t sync_barrier(DeviceTy &Device);
+  int32_t async_barrier(DeviceTy &Device);
+  int32_t release(DeviceTy &Device);
+
+  int32_t flush();
+  int32_t syncBarrier();
+  int32_t asyncBarrier();
+  int32_t release();
+
+  void addCompletionCb(ompx_interop_cb_t *cb, void *data) {
+    CompletionCbs.push_back(omp_interop_cb_instance_t(cb, data));
+  }
+
+  int numCompletionCbs() const { return CompletionCbs.size(); }
+  void clearCompletionCbs() { CompletionCbs.clear(); }
+
+  void runCompletionCbs() {
+    for (auto &cbInstance : CompletionCbs)
+      cbInstance(this);
+    clearCompletionCbs();
+  }
 } omp_interop_val_t;
 
 } // extern "C"
 
+struct InteropTableEntry {
+  using ContainerTy = typename std::vector<omp_interop_val_t *>;
+  using iterator = typename ContainerTy::iterator;
+
+  ContainerTy Interops;
+
+  const int reservedEntriesPerThread =
----------------
kevinsala wrote:

Can be ```constexpr```?

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


More information about the Openmp-commits mailing list