Skip to content

[Flang][OpenMP] Lowering of host-evaluated clauses #116219

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

Merged
merged 2 commits into from
Jan 14, 2025
Merged
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
20 changes: 14 additions & 6 deletions flang/include/flang/Common/OpenMP-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ struct EntryBlockArgsEntry {
/// Structure holding the information needed to create and bind entry block
/// arguments associated to all clauses that can define them.
struct EntryBlockArgs {
llvm::ArrayRef<mlir::Value> hostEvalVars;
EntryBlockArgsEntry inReduction;
EntryBlockArgsEntry map;
EntryBlockArgsEntry priv;
Expand All @@ -49,18 +50,25 @@ struct EntryBlockArgs {
}

auto getSyms() const {
return llvm::concat<const Fortran::semantics::Symbol *const>(
inReduction.syms, map.syms, priv.syms, reduction.syms,
taskReduction.syms, useDeviceAddr.syms, useDevicePtr.syms);
return llvm::concat<const semantics::Symbol *const>(inReduction.syms,
map.syms, priv.syms, reduction.syms, taskReduction.syms,
useDeviceAddr.syms, useDevicePtr.syms);
}

auto getVars() const {
return llvm::concat<const mlir::Value>(inReduction.vars, map.vars,
priv.vars, reduction.vars, taskReduction.vars, useDeviceAddr.vars,
useDevicePtr.vars);
return llvm::concat<const mlir::Value>(hostEvalVars, inReduction.vars,
map.vars, priv.vars, reduction.vars, taskReduction.vars,
useDeviceAddr.vars, useDevicePtr.vars);
}
};

/// Create an entry block for the given region, including the clause-defined
/// arguments specified.
///
/// \param [in] builder - MLIR operation builder.
/// \param [in] args - entry block arguments information for the given
/// operation.
/// \param [in] region - Empty region in which to create the entry block.
mlir::Block *genEntryBlock(
mlir::OpBuilder &builder, const EntryBlockArgs &args, mlir::Region &region);
} // namespace Fortran::common::openmp
Expand Down
9 changes: 5 additions & 4 deletions flang/lib/Common/OpenMP-utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ mlir::Block *genEntryBlock(mlir::OpBuilder &builder, const EntryBlockArgs &args,

llvm::SmallVector<mlir::Type> types;
llvm::SmallVector<mlir::Location> locs;
unsigned numVars = args.inReduction.vars.size() + args.map.vars.size() +
args.priv.vars.size() + args.reduction.vars.size() +
args.taskReduction.vars.size() + args.useDeviceAddr.vars.size() +
args.useDevicePtr.vars.size();
unsigned numVars = args.hostEvalVars.size() + args.inReduction.vars.size() +
args.map.vars.size() + args.priv.vars.size() +
args.reduction.vars.size() + args.taskReduction.vars.size() +
args.useDeviceAddr.vars.size() + args.useDevicePtr.vars.size();
types.reserve(numVars);
locs.reserve(numVars);

Expand All @@ -34,6 +34,7 @@ mlir::Block *genEntryBlock(mlir::OpBuilder &builder, const EntryBlockArgs &args,

// Populate block arguments in clause name alphabetical order to match
// expected order by the BlockArgOpenMPOpInterface.
extractTypeLoc(args.hostEvalVars);
extractTypeLoc(args.inReduction.vars);
extractTypeLoc(args.map.vars);
extractTypeLoc(args.priv.vars);
Expand Down
Loading
Loading