[Openmp-commits] [flang] [llvm] [mlir] [openmp] [Flang][OpenMP] Add support for interop construct (PR #203959)

Sunil Shrestha via Openmp-commits openmp-commits at lists.llvm.org
Wed Jul 8 09:57:32 PDT 2026


================
@@ -3711,6 +3711,98 @@ convertOmpTaskgroupOp(omp::TaskgroupOp tgOp, llvm::IRBuilderBase &builder,
   return success();
 }
 
+static LogicalResult
+convertOmpInteropInitOp(omp::InteropInitOp initOp, llvm::IRBuilderBase &builder,
+                        LLVM::ModuleTranslation &moduleTranslation) {
+  if (!initOp.getDependVars().empty() || initOp.getDependKinds() ||
+      !initOp.getDependIterated().empty() || initOp.getDependIteratedKinds())
+    return initOp.emitError()
+           << "not yet implemented: Unhandled clause depend in "
+           << omp::InteropInitOp::getOperationName() << " operation";
+
+  llvm::OpenMPIRBuilder *ompBuilder = moduleTranslation.getOpenMPBuilder();
+  llvm::Value *interopVar =
+      moduleTranslation.lookupValue(initOp.getInteropVar());
+  llvm::Value *device = initOp.getDevice()
+                            ? moduleTranslation.lookupValue(initOp.getDevice())
+                            : nullptr;
+
+  // TODO: Handle depend clauses when supported.
+  llvm::Value *numDeps = llvm::ConstantInt::get(builder.getInt32Ty(), 0);
+  llvm::Value *depArray = llvm::ConstantPointerNull::get(builder.getPtrTy());
+  bool hasNowait = initOp.getNowait();
+
+  // Emit one call per interop type. The runtime expects a single type per call.
+  for (auto typeAttr : initOp.getInteropTypes()) {
----------------
sshrestha-aa wrote:

I updated the lowering to match Clang: one init clause now produces a single `__tgt_interop_init call`. When a clause lists both `target` and `targetsync`, it collapses to `target`, because the runtime's interop type is a single value and can't represent both. I can follow up with a separate PR that extends the runtime to support both interop types.

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


More information about the Openmp-commits mailing list