Skip to content

Commit c241804

Browse files
committed
merge main into amd-staging
2 parents ca6337f + 1c7720e commit c241804

File tree

8 files changed

+39
-292
lines changed

8 files changed

+39
-292
lines changed

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

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,4 @@ def GenericLoopConversionPass
129129
];
130130
}
131131

132-
def AutomapToTargetDataPass
133-
: Pass<"omp-automap-to-target-data", "::mlir::ModuleOp"> {
134-
let summary = "Insert OpenMP target data operations for AUTOMAP variables";
135-
let description = [{
136-
Inserts `omp.target_enter_data` and `omp.target_exit_data` operations to
137-
map variables marked with the `AUTOMAP` modifier when their allocation
138-
or deallocation is detected in the FIR.
139-
}];
140-
let dependentDialects = ["mlir::omp::OpenMPDialect"];
141-
}
142-
143132
#endif //FORTRAN_OPTIMIZER_OPENMP_PASSES

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

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

12-
#include "flang/Optimizer/Builder/DirectivesCommon.h"
13-
#include "flang/Optimizer/Builder/FIRBuilder.h"
14-
#include "flang/Optimizer/Builder/HLFIRTools.h"
15-
#include "flang/Optimizer/Dialect/FIRType.h"
1612
#include "flang/Semantics/symbol.h"
1713

18-
#include "mlir/Dialect/OpenMP/OpenMPDialect.h"
1914
#include "mlir/IR/Builders.h"
2015
#include "mlir/IR/Value.h"
2116

@@ -77,49 +72,6 @@ struct EntryBlockArgs {
7772
/// \param [in] region - Empty region in which to create the entry block.
7873
mlir::Block *genEntryBlock(
7974
mlir::OpBuilder &builder, const EntryBlockArgs &args, mlir::Region &region);
80-
81-
mlir::omp::MapInfoOp createMapInfoOp(mlir::OpBuilder &builder,
82-
mlir::Location loc, mlir::Value baseAddr, mlir::Value varPtrPtr,
83-
llvm::StringRef name, llvm::ArrayRef<mlir::Value> bounds,
84-
llvm::ArrayRef<mlir::Value> members, mlir::ArrayAttr membersIndex,
85-
uint64_t mapType, mlir::omp::VariableCaptureKind mapCaptureType,
86-
mlir::Type retTy, bool partialMap = false,
87-
mlir::FlatSymbolRefAttr mapperId = mlir::FlatSymbolRefAttr());
88-
89-
mlir::Value mapTemporaryValue(fir::FirOpBuilder &firOpBuilder,
90-
mlir::omp::TargetOp targetOp, mlir::Value val, llvm::StringRef name);
91-
92-
void cloneOrMapRegionOutsiders(
93-
fir::FirOpBuilder &firOpBuilder, mlir::omp::TargetOp targetOp);
94-
95-
// Returns true if the variable has a dynamic size and therefore requires
96-
// bounds operations to describe its extents.
97-
inline bool needsBoundsOps(mlir::Value var) {
98-
assert(mlir::isa<mlir::omp::PointerLikeType>(var.getType()) &&
99-
"only pointer like types expected");
100-
mlir::Type t = fir::unwrapRefType(var.getType());
101-
if (mlir::Type inner = fir::dyn_cast_ptrOrBoxEleTy(t))
102-
return fir::hasDynamicSize(inner);
103-
return fir::hasDynamicSize(t);
104-
}
105-
106-
// Generate MapBoundsOp operations for the variable if required.
107-
inline void genBoundsOps(fir::FirOpBuilder &builder, mlir::Value var,
108-
llvm::SmallVectorImpl<mlir::Value> &boundsOps) {
109-
mlir::Location loc = var.getLoc();
110-
fir::factory::AddrAndBoundsInfo info =
111-
fir::factory::getDataOperandBaseAddr(builder, var,
112-
/*isOptional=*/false, loc);
113-
fir::ExtendedValue exv =
114-
hlfir::translateToExtendedValue(loc, builder, hlfir::Entity{info.addr},
115-
/*contiguousHint=*/true)
116-
.first;
117-
llvm::SmallVector<mlir::Value> tmp =
118-
fir::factory::genImplicitBoundsOps<mlir::omp::MapBoundsOp,
119-
mlir::omp::MapBoundsType>(
120-
builder, info, exv, /*dataExvIsAssumedSize=*/false, loc);
121-
llvm::append_range(boundsOps, tmp);
122-
}
12375
} // namespace Fortran::common::openmp
12476

12577
#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(opts.deferDescMap));
327327
pm.addPass(flangomp::createMarkDeclareTargetPass());
328328
pm.addPass(flangomp::createGenericLoopConversionPass());

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)