Skip to content

[PoC][flang] Modeling locality specifiers for do concurrent #137929

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions flang/include/flang/Lower/AbstractConverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,9 @@ class AbstractConverter {
virtual Fortran::lower::SymbolBox
lookupOneLevelUpSymbol(const Fortran::semantics::Symbol &sym) = 0;

virtual Fortran::lower::SymbolBox
shallowLookupSymbol(const Fortran::semantics::Symbol &sym) = 0;

/// Return the mlir::SymbolTable associated to the ModuleOp.
/// Look-ups are faster using it than using module.lookup<>,
/// but the module op should be queried in case of failure
Expand Down
4 changes: 2 additions & 2 deletions flang/include/flang/Optimizer/Dialect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ mlir_tablegen(FIRAttr.cpp.inc -gen-attrdef-defs)
set(LLVM_TARGET_DEFINITIONS FIROps.td)
mlir_tablegen(FIROps.h.inc -gen-op-decls)
mlir_tablegen(FIROps.cpp.inc -gen-op-defs)
mlir_tablegen(FIROpsTypes.h.inc --gen-typedef-decls)
mlir_tablegen(FIROpsTypes.cpp.inc --gen-typedef-defs)
mlir_tablegen(FIROpsTypes.h.inc --gen-typedef-decls -typedefs-dialect=fir)
mlir_tablegen(FIROpsTypes.cpp.inc --gen-typedef-defs -typedefs-dialect=fir)
add_public_tablegen_target(FIROpsIncGen)

set(LLVM_TARGET_DEFINITIONS FortranVariableInterface.td)
Expand Down
33 changes: 31 additions & 2 deletions flang/include/flang/Optimizer/Dialect/FIROps.td
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
include "mlir/Dialect/Arith/IR/ArithBase.td"
include "mlir/Dialect/Arith/IR/ArithOpsInterfaces.td"
include "mlir/Dialect/LLVMIR/LLVMAttrDefs.td"
include "mlir/Dialect/OpenMP/OpenMPClauses.td"
include "flang/Optimizer/Dialect/CUF/Attributes/CUFAttr.td"
include "flang/Optimizer/Dialect/FIRDialect.td"
include "flang/Optimizer/Dialect/FIRTypes.td"
Expand Down Expand Up @@ -3570,7 +3571,7 @@ def fir_DoConcurrentLoopOp : fir_Op<"do_concurrent.loop",
LLVM.
}];

let arguments = (ins
defvar opArgs = (ins
Variadic<Index>:$lowerBound,
Variadic<Index>:$upperBound,
Variadic<Index>:$step,
Expand All @@ -3579,17 +3580,45 @@ def fir_DoConcurrentLoopOp : fir_Op<"do_concurrent.loop",
OptionalAttr<LoopAnnotationAttr>:$loopAnnotation
);

let arguments = !con(opArgs, OpenMP_PrivateClause.arguments);

let regions = (region SizedRegion<1>:$region);

let hasCustomAssemblyFormat = 1;
let hasVerifier = 1;

let extraClassDeclaration = [{
defvar opExtraClassDeclaration = [{
unsigned getNumInductionVars() { return getLowerBound().size(); }

unsigned getNumPrivateOperands() { return getPrivateVars().size(); }

mlir::Block::BlockArgListType getInductionVars() {
return getBody()->getArguments().slice(0, getNumInductionVars());
}

mlir::Block::BlockArgListType getRegionPrivateArgs() {
return getBody()->getArguments().slice(getNumInductionVars(),
getNumPrivateOperands());
}

/// Number of operands controlling the loop
unsigned getNumControlOperands() { return getLowerBound().size() * 3; }

// Get Number of reduction operands
unsigned getNumReduceOperands() {
return getReduceOperands().size();
}

mlir::Operation::operand_range getPrivateOperands() {
return getOperands()
.slice(getNumControlOperands() + getNumReduceOperands(),
getNumPrivateOperands());
}
}];

let extraClassDeclaration =
!strconcat(opExtraClassDeclaration, "\n",
OpenMP_PrivateClause.extraClassDeclaration);
}

#endif
Loading
Loading