[flang-commits] [clang] [flang] [flang][OpenMP] Upstream first part of `do concurrent` mapping (PR #126026)
Kiran Chandramohan via flang-commits
flang-commits at lists.llvm.org
Thu Feb 13 02:51:36 PST 2025
================
@@ -0,0 +1,99 @@
+//===- DoConcurrentConversion.cpp -- map `DO CONCURRENT` to OpenMP loops --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "flang/Optimizer/Dialect/FIROps.h"
+#include "flang/Optimizer/OpenMP/Passes.h"
+#include "mlir/Dialect/Func/IR/FuncOps.h"
+#include "mlir/Dialect/OpenMP/OpenMPDialect.h"
+#include "mlir/IR/Diagnostics.h"
+#include "mlir/Pass/Pass.h"
+#include "mlir/Transforms/DialectConversion.h"
+
+#include <memory>
+#include <utility>
+
+namespace flangomp {
+#define GEN_PASS_DEF_DOCONCURRENTCONVERSIONPASS
+#include "flang/Optimizer/OpenMP/Passes.h.inc"
+} // namespace flangomp
+
+#define DEBUG_TYPE "do-concurrent-conversion"
+#define DBGS() (llvm::dbgs() << "[" DEBUG_TYPE << "]: ")
+
+namespace {
+class DoConcurrentConversion : public mlir::OpConversionPattern<fir::DoLoopOp> {
+public:
+ using mlir::OpConversionPattern<fir::DoLoopOp>::OpConversionPattern;
+
+ DoConcurrentConversion(mlir::MLIRContext *context, bool mapToDevice)
+ : OpConversionPattern(context), mapToDevice(mapToDevice) {}
+
+ mlir::LogicalResult
+ matchAndRewrite(fir::DoLoopOp doLoop, OpAdaptor adaptor,
+ mlir::ConversionPatternRewriter &rewriter) const override {
+ // TODO This will be filled in with the next PRs that upstreams the rest of
+ // the ROCm implementaion.
+ return mlir::success();
+ }
+
+ bool mapToDevice;
+};
+
+class DoConcurrentConversionPass
+ : public flangomp::impl::DoConcurrentConversionPassBase<
+ DoConcurrentConversionPass> {
+public:
+ DoConcurrentConversionPass() = default;
+
+ DoConcurrentConversionPass(
+ const flangomp::DoConcurrentConversionPassOptions &options)
+ : DoConcurrentConversionPassBase(options) {}
+
+ void runOnOperation() override {
+ mlir::func::FuncOp func = getOperation();
+
+ if (func.isDeclaration())
+ return;
+
+ auto *context = &getContext();
----------------
kiranchandramohan wrote:
Nit: Expand this auto.
https://github.com/llvm/llvm-project/pull/126026
More information about the flang-commits
mailing list