[Mlir-commits] [mlir] [flang][OpenMP] Process `omp.atomic.update` while translating scopes for target device (PR #132165)

Sergio Afonso llvmlistbot at llvm.org
Thu Mar 20 05:39:54 PDT 2025


================
@@ -5323,6 +5323,43 @@ convertTargetOpsInNest(Operation *op, llvm::IRBuilderBase &builder,
             if (auto blockArgsIface =
                     dyn_cast<omp::BlockArgOpenMPOpInterface>(oper))
               forwardArgs(moduleTranslation, blockArgsIface);
+            else {
+              // For non-BlockArgOpenMPOpInterface ops, we also want to map
+              // their entry block arguments to their operands, if any. For the
+              // current support in the OpenMP dialect, the table below lists
+              // all ops that have arguments (SSA operands and/or attributes)
+              // and not target-related. Of all these ops, we need to only
+              // process `omp.atomic.update` since it is the only op that has
+              // SSA operands & an attached region. Therefore, the region's
+              // entry block arguments must be mapped to the op's operands in
+              // case they are referenced inside the region.
+              //
+              // clang-format off
+              // =============================================================================
+              // | op                | operands? | region(s)? | parent is func? | processed? |
+              // =============================================================================
+              // | atomic.read       | yes       | no         | yes             | no         |
+              // | atomic.write      | yes       | no         | yes             | no         |
+              // | atomic.update     | yes       | yes        | yes             | yes        |
+              // | critical          | no        | no         | yes             | no         |
+              // | declare_mapper    | no        | yes        | no              | no         |
+              // | declare_reduction | no        | yes        | no              | no         |
+              // | flush             | yes       | no         | yes             | no         |
+              // | private           | no        | yes        | yes             | no         |
+              // | threadprivate     | yes       | no         | yes             | no         |
+              // | yield             | yes       | no         | yes             | no         |
+              // =============================================================================
+              // clang-format on
----------------
skatrak wrote:

I think having this detailed description of how things are at this point in time is very good information for the commit message. However, I don't think we want this as a comment in the code because it can very easily become outdated. The comment could be summarized to something along the lines of "Here we map entry block arguments of non-BlockArgOpenMPOpInterface ops if they can be encountered inside of a function and they define any of these arguments.".

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


More information about the Mlir-commits mailing list