Skip to content

Commit 0998da2

Browse files
committed
Revert "[MLIR][OpenMP] Add a new AutomapToTargetData conversion pass in FIR (#151989)"
This reverts commit 5a5e8ba.
1 parent e20dd94 commit 0998da2

File tree

9 files changed

+39
-283
lines changed

9 files changed

+39
-283
lines changed

flang/include/flang/Optimizer/OpenMP/Passes.td

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,4 @@ def GenericLoopConversionPass
112112
];
113113
}
114114

115-
def AutomapToTargetDataPass
116-
: Pass<"omp-automap-to-target-data", "::mlir::ModuleOp"> {
117-
let summary = "Insert OpenMP target data operations for AUTOMAP variables";
118-
let description = [{
119-
Inserts `omp.target_enter_data` and `omp.target_exit_data` operations to
120-
map variables marked with the `AUTOMAP` modifier when their allocation
121-
or deallocation is detected in the FIR.
122-
}];
123-
let dependentDialects = ["mlir::omp::OpenMPDialect"];
124-
}
125-
126115
#endif //FORTRAN_OPTIMIZER_OPENMP_PASSES

flang/include/flang/Support/OpenMP-utils.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
#ifndef FORTRAN_SUPPORT_OPENMP_UTILS_H_
1010
#define FORTRAN_SUPPORT_OPENMP_UTILS_H_
1111

12-
#include "flang/Optimizer/Builder/FIRBuilder.h"
13-
#include "flang/Optimizer/Dialect/FIRType.h"
1412
#include "flang/Semantics/symbol.h"
1513

1614
#include "mlir/IR/Builders.h"
@@ -74,14 +72,6 @@ struct EntryBlockArgs {
7472
/// \param [in] region - Empty region in which to create the entry block.
7573
mlir::Block *genEntryBlock(
7674
mlir::OpBuilder &builder, const EntryBlockArgs &args, mlir::Region &region);
77-
78-
// Returns true if the variable has a dynamic size and therefore requires
79-
// bounds operations to describe its extents.
80-
bool needsBoundsOps(mlir::Value var);
81-
82-
// Generate MapBoundsOp operations for the variable if required.
83-
void genBoundsOps(fir::FirOpBuilder &builder, mlir::Value var,
84-
llvm::SmallVectorImpl<mlir::Value> &boundsOps);
8575
} // namespace Fortran::common::openmp
8676

8777
#endif // FORTRAN_SUPPORT_OPENMP_UTILS_H_

flang/lib/Optimizer/OpenMP/AutomapToTargetData.cpp

Lines changed: 0 additions & 130 deletions
This file was deleted.

flang/lib/Optimizer/OpenMP/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
22

33
add_flang_library(FlangOpenMPTransforms
4-
AutomapToTargetData.cpp
54
DoConcurrentConversion.cpp
65
FunctionFiltering.cpp
76
GenericLoopConversion.cpp

flang/lib/Optimizer/OpenMP/MapsForPrivatizedSymbols.cpp

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#include "flang/Optimizer/Dialect/Support/KindMapping.h"
3030
#include "flang/Optimizer/HLFIR/HLFIROps.h"
3131
#include "flang/Optimizer/OpenMP/Passes.h"
32-
#include "flang/Support/OpenMP-utils.h"
3332

3433
#include "mlir/Dialect/Func/IR/FuncOps.h"
3534
#include "mlir/Dialect/OpenMP/OpenMPDialect.h"
@@ -48,7 +47,6 @@ namespace flangomp {
4847
} // namespace flangomp
4948

5049
using namespace mlir;
51-
using namespace Fortran::common::openmp;
5250

5351
namespace {
5452
class MapsForPrivatizedSymbolsPass
@@ -195,5 +193,38 @@ class MapsForPrivatizedSymbolsPass
195193
}
196194
}
197195
}
196+
// As the name suggests, this function examines var to determine if
197+
// it has dynamic size. If true, this pass'll have to extract these
198+
// bounds from descriptor of var and add the bounds to the resultant
199+
// MapInfoOp.
200+
bool needsBoundsOps(mlir::Value var) {
201+
assert(mlir::isa<omp::PointerLikeType>(var.getType()) &&
202+
"needsBoundsOps can deal only with pointer types");
203+
mlir::Type t = fir::unwrapRefType(var.getType());
204+
// t could be a box, so look inside the box
205+
auto innerType = fir::dyn_cast_ptrOrBoxEleTy(t);
206+
if (innerType)
207+
return fir::hasDynamicSize(innerType);
208+
return fir::hasDynamicSize(t);
209+
}
210+
211+
void genBoundsOps(fir::FirOpBuilder &builder, mlir::Value var,
212+
llvm::SmallVector<mlir::Value> &boundsOps) {
213+
mlir::Location loc = var.getLoc();
214+
fir::factory::AddrAndBoundsInfo info =
215+
fir::factory::getDataOperandBaseAddr(builder, var,
216+
/*isOptional=*/false, loc);
217+
fir::ExtendedValue extendedValue =
218+
hlfir::translateToExtendedValue(loc, builder, hlfir::Entity{info.addr},
219+
/*continguousHint=*/true)
220+
.first;
221+
llvm::SmallVector<mlir::Value> boundsOpsVec =
222+
fir::factory::genImplicitBoundsOps<mlir::omp::MapBoundsOp,
223+
mlir::omp::MapBoundsType>(
224+
builder, info, extendedValue,
225+
/*dataExvIsAssumedSize=*/false, loc);
226+
for (auto bounds : boundsOpsVec)
227+
boundsOps.push_back(bounds);
228+
}
198229
};
199230
} // namespace

flang/lib/Optimizer/Passes/Pipelines.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -316,13 +316,13 @@ void createOpenMPFIRPassPipeline(mlir::PassManager &pm,
316316
pm.addPass(flangomp::createDoConcurrentConversionPass(
317317
opts.doConcurrentMappingKind == DoConcurrentMappingKind::DCMK_Device));
318318

319-
// The MapsForPrivatizedSymbols and AutomapToTargetDataPass pass need to run
320-
// before MapInfoFinalizationPass because they create new MapInfoOp
321-
// instances, typically for descriptors. MapInfoFinalizationPass adds
322-
// MapInfoOp instances for the descriptors underlying data which is necessary
323-
// to access the data on the offload target device.
319+
// The MapsForPrivatizedSymbols pass needs to run before
320+
// MapInfoFinalizationPass because the former creates new
321+
// MapInfoOp instances, typically for descriptors.
322+
// MapInfoFinalizationPass adds MapInfoOp instances for the descriptors
323+
// underlying data which is necessary to access the data on the offload
324+
// target device.
324325
pm.addPass(flangomp::createMapsForPrivatizedSymbolsPass());
325-
pm.addPass(flangomp::createAutomapToTargetDataPass());
326326
pm.addPass(flangomp::createMapInfoFinalizationPass());
327327
pm.addPass(flangomp::createMarkDeclareTargetPass());
328328
pm.addPass(flangomp::createGenericLoopConversionPass());

flang/lib/Support/OpenMP-utils.cpp

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "flang/Support/OpenMP-utils.h"
10-
#include "flang/Optimizer/Builder/DirectivesCommon.h"
11-
#include "flang/Optimizer/Builder/HLFIRTools.h"
1210

13-
#include "mlir/Dialect/OpenMP/OpenMPDialect.h"
1411
#include "mlir/IR/OpDefinition.h"
1512

1613
namespace Fortran::common::openmp {
@@ -50,30 +47,4 @@ mlir::Block *genEntryBlock(mlir::OpBuilder &builder, const EntryBlockArgs &args,
5047

5148
return builder.createBlock(&region, {}, types, locs);
5249
}
53-
54-
bool needsBoundsOps(mlir::Value var) {
55-
assert(mlir::isa<mlir::omp::PointerLikeType>(var.getType()) &&
56-
"only pointer like types expected");
57-
mlir::Type t = fir::unwrapRefType(var.getType());
58-
if (mlir::Type inner = fir::dyn_cast_ptrOrBoxEleTy(t))
59-
return fir::hasDynamicSize(inner);
60-
return fir::hasDynamicSize(t);
61-
}
62-
63-
void genBoundsOps(fir::FirOpBuilder &builder, mlir::Value var,
64-
llvm::SmallVectorImpl<mlir::Value> &boundsOps) {
65-
mlir::Location loc = var.getLoc();
66-
fir::factory::AddrAndBoundsInfo info =
67-
fir::factory::getDataOperandBaseAddr(builder, var,
68-
/*isOptional=*/false, loc);
69-
fir::ExtendedValue exv =
70-
hlfir::translateToExtendedValue(loc, builder, hlfir::Entity{info.addr},
71-
/*contiguousHint=*/true)
72-
.first;
73-
llvm::SmallVector<mlir::Value> tmp =
74-
fir::factory::genImplicitBoundsOps<mlir::omp::MapBoundsOp,
75-
mlir::omp::MapBoundsType>(
76-
builder, info, exv, /*dataExvIsAssumedSize=*/false, loc);
77-
llvm::append_range(boundsOps, tmp);
78-
}
7950
} // namespace Fortran::common::openmp

flang/test/Transforms/omp-automap-to-target-data.fir

Lines changed: 0 additions & 58 deletions
This file was deleted.

offload/test/offloading/fortran/declare-target-automap.f90

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)