Skip to content

Commit 406415a

Browse files
ftynsekiranchandramohan
authored andcommitted
[mlir] support translating OpenMP loops with reductions
Use the recently introduced OpenMPIRBuilder facility to transate OpenMP workshare loops with reductions to LLVM IR calling OpenMP runtime. Most of the heavy lifting is done at the OpenMPIRBuilder. When other OpenMP dialect constructs grow support for reductions, the translation can be updated to operate on, e.g., an operation interface for all reduction containers instead of workshare loops specifically. Designing such a generic translation for the single operation that currently supports reductions is premature since we don't know how the reduction modeling itself will be generalized. Reviewed By: kiranchandramohan Differential Revision: https://reviews.llvm.org/D107343
1 parent 8379767 commit 406415a

File tree

6 files changed

+863
-49
lines changed

6 files changed

+863
-49
lines changed

mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ class ModuleTranslation {
8383
return valueMapping.lookup(value);
8484
}
8585

86+
/// Looks up remapped a list of remapped values.
87+
SmallVector<llvm::Value *> lookupValues(ValueRange values);
88+
8689
/// Stores the mapping between an MLIR block and LLVM IR basic block.
8790
void mapBlock(Block *mlir, llvm::BasicBlock *llvm) {
8891
auto result = blockMapping.try_emplace(mlir, llvm);
@@ -110,6 +113,10 @@ class ModuleTranslation {
110113
return branchMapping.lookup(op);
111114
}
112115

116+
/// Removes the mapping for blocks contained in the region and values defined
117+
/// in these blocks.
118+
void forgetMapping(Region &region);
119+
113120
/// Returns the LLVM metadata corresponding to a reference to an mlir LLVM
114121
/// dialect access group operation.
115122
llvm::MDNode *getAccessGroup(Operation &opInst,
@@ -134,9 +141,6 @@ class ModuleTranslation {
134141
/// Converts the type from MLIR LLVM dialect to LLVM.
135142
llvm::Type *convertType(Type type);
136143

137-
/// Looks up remapped a list of remapped values.
138-
SmallVector<llvm::Value *, 8> lookupValues(ValueRange values);
139-
140144
/// Returns the MLIR context of the module being translated.
141145
MLIRContext &getContext() { return *mlirModule->getContext(); }
142146

@@ -209,7 +213,7 @@ class ModuleTranslation {
209213
/// translated makes the frame available when translating ops within that
210214
/// region.
211215
template <typename T, typename... Args>
212-
void stackPush(Args &&... args) {
216+
void stackPush(Args &&...args) {
213217
static_assert(
214218
std::is_base_of<StackFrame, T>::value,
215219
"can only push instances of StackFrame on ModuleTranslation stack");

mlir/lib/Target/LLVMIR/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ add_mlir_translation_library(MLIRTargetLLVMIRExport
2727

2828
LINK_LIBS PUBLIC
2929
MLIRLLVMIR
30-
MLIROpenACC
31-
MLIROpenMP
3230
MLIRLLVMIRTransforms
3331
MLIRTranslation
3432
)

0 commit comments

Comments
 (0)