MLIR 24.0.0git
mlir::omp Namespace Reference

Classes

struct  DeclareTargetDefaultModel
struct  DeviceTypeClauseOps
struct  OffloadModuleDefaultModel
struct  OffloadModuleOpts
 Offload-specific OpenMP module attributes, associated to the OffloadModuleInterface. More...
struct  TargetExtOperands
 Extended TargetOperands with kernel_type attribute. More...

Typedefs

using HostEvaluatedOperands
 Clauses that correspond to operations other than omp.target, but might have to be evaluated outside of a parent target region.
using DeclareTargetOperands = detail::Clauses<DeviceTypeClauseOps>
using TargetEnterExitUpdateDataOperands = TargetEnterDataOperands
 omp.target_enter_data, omp.target_exit_data and omp.target_update take the same clauses, so we give the structure to be shared by all of them a representative name.

Functions

std::tuple< NewCliOp, OpOperand *, OpOperand * > decodeCli (mlir::Value cli)
 Find the omp.new_cli, generator, and consumer of a canonical loop info.
ClauseProcBindKind convertProcBindKind (llvm::omp::ProcBindKind kind)
 Convert a proc_bind kind from the LLVM frontend enum to the corresponding OpenMP dialect enum.
void setOffloadModuleInterfaceAttributes (ModuleOp module, const OffloadModuleOpts &opts)
 Sets OpenMP offload module interface attributes on a ModuleOp, shared between Flang and Clang (CIR) frontends.
void setOpenMPVersionAttribute (ModuleOp module, int64_t version)
 Adds or updates the omp.version attribute.
int64_t getOpenMPVersionAttribute (ModuleOp module, int64_t fallback=-1)
 Returns the value of the omp.version attribute, if present, or the fallback.
bool isOpenMPModule (ModuleOp module)
 Checks whether this is an OpenMP-enabled module.
bool allocaUsesRequireSharedMem (Value alloc)
 Check whether the value representing an allocation, assumed to have been defined in a shared device context, is used in a manner that would require device shared memory for correctness.
bool opInSharedDeviceContext (Operation &op)
 Check whether the given operation is located in a context where an allocation to be used by multiple threads in a parallel region would have to be placed in device shared memory to be accessible.

Variables

constexpr int64_t kNullAllocator = 0
 Value of the omp_null_allocator handle.

Typedef Documentation

◆ DeclareTargetOperands

Definition at line 47 of file OpenMPClauseOperands.h.

◆ HostEvaluatedOperands

Initial value:
detail::Clauses<CollapseClauseOps, LoopRelatedClauseOps, NumTeamsClauseOps,
NumThreadsClauseOps, ThreadLimitClauseOps>

Clauses that correspond to operations other than omp.target, but might have to be evaluated outside of a parent target region.

Definition at line 42 of file OpenMPClauseOperands.h.

◆ TargetEnterExitUpdateDataOperands

using mlir::omp::TargetEnterExitUpdateDataOperands = TargetEnterDataOperands

omp.target_enter_data, omp.target_exit_data and omp.target_update take the same clauses, so we give the structure to be shared by all of them a representative name.

Definition at line 52 of file OpenMPClauseOperands.h.

Function Documentation

◆ allocaUsesRequireSharedMem()

bool mlir::omp::allocaUsesRequireSharedMem ( Value alloc)

Check whether the value representing an allocation, assumed to have been defined in a shared device context, is used in a manner that would require device shared memory for correctness.

When a use takes place inside an omp.parallel region and it's not as a private clause argument, or when it is a reduction argument passed to omp.parallel or a function call argument, then the defining allocation is eligible for replacement with shared memory.

See also
mlir::omp::opInSharedDeviceContext().

Definition at line 92 of file Utils.cpp.

References allocaUseRequiresSharedMem(), mlir::Operation::getResults(), mlir::Value::getUses(), and result.

Referenced by allocatePrivateVars(), cleanupPrivateVars(), and createDeviceArgumentAccessor().

◆ convertProcBindKind()

ClauseProcBindKind mlir::omp::convertProcBindKind ( llvm::omp::ProcBindKind kind)

Convert a proc_bind kind from the LLVM frontend enum to the corresponding OpenMP dialect enum.

The LLVM 'default' and 'unknown' kinds have no dialect counterpart and are not valid inputs.

Definition at line 4197 of file OpenMPDialect.cpp.

◆ decodeCli()

std::tuple< NewCliOp, OpOperand *, OpOperand * > mlir::omp::decodeCli ( mlir::Value cli)

Find the omp.new_cli, generator, and consumer of a canonical loop info.

Definition at line 4165 of file OpenMPDialect.cpp.

References mlir::Value::getContext(), mlir::Value::getDefiningOp(), mlir::Value::getType(), and mlir::Value::getUses().

Referenced by checkApplyeesNesting().

◆ getOpenMPVersionAttribute()

int64_t mlir::omp::getOpenMPVersionAttribute ( ModuleOp module,
int64_t fallback = -1 )

Returns the value of the omp.version attribute, if present, or the fallback.

Definition at line 50 of file Utils.cpp.

◆ isOpenMPModule()

bool mlir::omp::isOpenMPModule ( ModuleOp module)

Checks whether this is an OpenMP-enabled module.

Definition at line 57 of file Utils.cpp.

◆ opInSharedDeviceContext()

bool mlir::omp::opInSharedDeviceContext ( Operation & op)

Check whether the given operation is located in a context where an allocation to be used by multiple threads in a parallel region would have to be placed in device shared memory to be accessible.

That means that it is inside of a target device module, it is a non-SPMD target region, is inside of one or it's located in a device function, and it is not not inside of a parallel region.

This represents a necessary but not sufficient set of conditions to use device shared memory in place of regular allocas. For some variables, the associated OpenMP construct or their uses might also need to be taken into account.

See also
mlir::omp::allocaUsesRequireSharedMem().

Definition at line 107 of file Utils.cpp.

References mlir::Operation::getParentOfType().

Referenced by allocatePrivateVars(), allocReductionVars(), cleanupPrivateVars(), createDeviceArgumentAccessor(), createReductionsAndCleanup(), and shouldReplaceAllocaWithDeviceSharedMem().

◆ setOffloadModuleInterfaceAttributes()

◆ setOpenMPVersionAttribute()

void mlir::omp::setOpenMPVersionAttribute ( ModuleOp module,
int64_t version )

Adds or updates the omp.version attribute.

Definition at line 44 of file Utils.cpp.

Variable Documentation

◆ kNullAllocator

int64_t mlir::omp::kNullAllocator = 0
constexpr

Value of the omp_null_allocator handle.

Using it as an allocator operand selects the default allocator of the binding task.

Definition at line 55 of file OpenMPDialect.h.