Multi-Level IR Compiler Framework

'omp' Dialect

Operation definition 

omp.barrier (::mlir::omp::BarrierOp) 

barrier construct


operation ::= `omp.barrier` attr-dict

The barrier construct specifies an explicit barrier at the point at which the construct appears.

omp.critical.declare (::mlir::omp::CriticalDeclareOp) 

declares a named critical section.


operation ::= `omp.critical.declare` $sym_name attr-dict

Declares a named critical section.

The name can be used in critical constructs in the dialect.


AttributeMLIR TypeDescription
sym_name::mlir::StringAttrstring attribute

omp.critical (::mlir::omp::CriticalOp) 

critical construct


operation ::= `omp.critical` (`(` $name^ `)`)? (`hint` `(` $hint^ `)`)? $region attr-dict

The critical construct imposes a restriction on the associated structured block (region) to be executed by only a single thread at a time.


AttributeMLIR TypeDescription
name::mlir::FlatSymbolRefAttrflat symbol reference attribute
hint::mlir::omp::SyncHintKindAttrOpenMP Sync Hint Kind

omp.flush (::mlir::omp::FlushOp) 

flush construct


operation ::= `omp.flush` ( `(` $varList^ `:` type($varList) `)` )? attr-dict

The flush construct executes the OpenMP flush operation. This operation makes a thread’s temporary view of memory consistent with memory and enforces an order on the memory operations of the variables explicitly specified or implied.


varListany type

omp.master (::mlir::omp::MasterOp) 

master construct


operation ::= `omp.master` $region attr-dict

The master construct specifies a structured block that is executed by the master thread of the team.

omp.parallel (::mlir::omp::ParallelOp) 

parallel construct

The parallel construct includes a region of code which is to be executed by a team of threads.

The optional $if_expr_var parameter specifies a boolean result of a conditional check. If this value is 1 or is not provided then the parallel region runs as normal, if it is 0 then the parallel region is executed with one thread.

The optional $num_threads_var parameter specifies the number of threads which should be used to execute the parallel region.

The optional $default_val attribute specifies the default data sharing attribute of values used in the parallel region that are not passed explicitly as parameters to the operation.

The $private_vars, $firstprivate_vars, $shared_vars and $copyin_vars parameters are a variadic list of values that specify the data sharing attribute of those values.

The $allocators_vars and $allocate_vars parameters are a variadic list of values that specify the memory allocator to be used to obtain storage for private values.

The optional $proc_bind_val attribute controls the thread affinity for the execution of the parallel region.


AttributeMLIR TypeDescription
default_val::mlir::StringAttrdefault clause
proc_bind_val::mlir::StringAttrProcBindKind Clause


if_expr_varany type
num_threads_varany type
private_varsany type
firstprivate_varsany type
shared_varsany type
copyin_varsany type
allocate_varsany type
allocators_varsany type

omp.reduction.declare (::mlir::omp::ReductionDeclareOp) 

declares a reduction kind


operation ::= `omp.reduction.declare` $sym_name `:` $type attr-dict-with-keyword `init` $initializerRegion `combiner` $reductionRegion custom<AtomicReductionRegion>($atomicReductionRegion)

Declares an OpenMP reduction kind. This requires two mandatory and one optional region.

  1. The initializer region specifies how to initialize the thread-local reduction value. This is usually the neutral element of the reduction. For convenience, the region has an argument that contains the value of the reduction accumulator at the start of the reduction. It is expected to omp.yield the new value on all control flow paths.
  2. The reduction region specifies how to combine two values into one, i.e. the reduction operator. It accepts the two values as arguments and is expected to omp.yield the combined value on all control flow paths.
  3. The atomic reduction region is optional and specifies how two values can be combined atomically given local accumulator variables. It is expected to store the combined value in the first accumulator variable.

Note that the MLIR type system does not allow for type-polymorphic reductions. Separate reduction declarations should be created for different element and accumulator types.


AttributeMLIR TypeDescription
sym_name::mlir::StringAttrstring attribute
type::mlir::TypeAttrany type attribute

omp.reduction (::mlir::omp::ReductionOp) 

reduction construct


operation ::= `omp.reduction` $operand `,` $accumulator attr-dict `:` type($accumulator)

Indicates the value that is produced by the current reduction-participating entity for a reduction requested in some ancestor. The reduction is identified by the accumulator, but the value of the accumulator may not be updated immediately.


operandany type
accumulatorOpenMP-compatible variable type (::mlir::omp::TargetOp) 

target construct

The target construct includes a region of code which is to be executed on a device.

The optional $if_expr parameter specifies a boolean result of a conditional check. If this value is 1 or is not provided then the target region runs on a device, if it is 0 then the target region is executed on the host device.

The optional $device parameter specifies the device number for the target region.

The optional $thread_limit specifies the limit on the number of threads

The optional $nowait elliminates the implicit barrier so the parent task can make progress even if the target task is not yet completed.

TODO: private, map, is_device_ptr, firstprivate, depend, defaultmap, in_reduction


AttributeMLIR TypeDescription
nowait::mlir::UnitAttrunit attribute


if_expr1-bit signless integer

omp.taskwait (::mlir::omp::TaskwaitOp) 

taskwait construct


operation ::= `omp.taskwait` attr-dict

The taskwait construct specifies a wait on the completion of child tasks of the current task.

omp.taskyield (::mlir::omp::TaskyieldOp) 

taskyield construct


operation ::= `omp.taskyield` attr-dict

The taskyield construct specifies that the current task can be suspended in favor of execution of a different task.

omp.terminator (::mlir::omp::TerminatorOp) 

terminator for OpenMP regions


operation ::= `omp.terminator` attr-dict

A terminator operation for regions that appear in the body of OpenMP operation. These regions are not expected to return any value so the terminator takes no operands. The terminator op returns control to the enclosing op.

omp.wsloop (::mlir::omp::WsLoopOp) 

workshare loop construct

The workshare loop construct specifies that the iterations of the loop(s) will be executed in parallel by threads in the current context. These iterations are spread across threads that already exist in the enclosing parallel region. The lower and upper bounds specify a half-open range: the range includes the lower bound but does not include the upper bound. If the inclusive attribute is specified then the upper bound is also included.

The body region can contain any number of blocks. The region is terminated by “omp.yield” instruction without operands.

omp.wsloop (%i1, %i2) : index = (%c0, %c0) to (%c10, %c10) step (%c1, %c1) {
  %a = load %arrA[%i1, %i2] : memref<?x?xf32>
  %b = load %arrB[%i1, %i2] : memref<?x?xf32>
  %sum = addf %a, %b : f32
  store %sum, %arrC[%i1, %i2] : memref<?x?xf32>

private_vars, firstprivate_vars, lastprivate_vars and linear_vars arguments are variadic list of operands that specify the data sharing attributes of the list of values. The linear_step_vars operand additionally specifies the step for each associated linear operand. Note that the linear_vars and linear_step_vars variadic lists should contain the same number of elements.

Reductions can be performed in a workshare loop by specifying reduction accumulator variables in reduction_vars and symbols referring to reduction declarations in the reductions attribute. Each reduction is identified by the accumulator it uses and accumulators must not be repeated in the same reduction. The omp.reduction operation accepts the accumulator and a partial value which is considered to be produced by the current loop iteration for the given reduction. If multiple values are produced for the same accumulator, i.e. there are multiple omp.reductions, the last value is taken. The reduction declaration specifies how to combine the values from each iteration into the final value, which is available in the accumulator after the loop completes.

The optional schedule_val attribute specifies the loop schedule for this loop, determining how the loop is distributed across the parallel threads. The optional schedule_chunk_var associated with this determines further controls this distribution.

The optional collapse_val attribute specifies the number of loops which are collapsed to form the worksharing loop.

The nowait attribute, when present, signifies that there should be no implicit barrier at the end of the loop.

The optional ordered_val attribute specifies how many loops are associated with the do loop construct.

The optional order attribute specifies which order the iterations of the associate loops are executed in. Currently the only option for this attribute is “concurrent”.


AttributeMLIR TypeDescription
reductions::mlir::ArrayAttrarray of symbol references
schedule_val::mlir::StringAttrScheduleKind Clause
collapse_val::mlir::IntegerAttr64-bit signless integer attribute whose minimum value is 0
nowait::mlir::UnitAttrunit attribute
ordered_val::mlir::IntegerAttr64-bit signless integer attribute whose minimum value is 0
order_val::mlir::StringAttrOrderKind Clause
inclusive::mlir::UnitAttrunit attribute


lowerBoundinteger or index
upperBoundinteger or index
stepinteger or index
private_varsany type
firstprivate_varsany type
lastprivate_varsany type
linear_varsany type
linear_step_varsany type
reduction_varsOpenMP-compatible variable type
schedule_chunk_varany type

omp.yield (::mlir::omp::YieldOp) 

loop yield and termination operation


operation ::= `omp.yield` ( `(` $results^ `:` type($results) `)` )? attr-dict

“omp.yield” yields SSA values from the OpenMP dialect op region and terminates the region. The semantics of how the values are yielded is defined by the parent operation. If “omp.yield” has any operands, the operands must match the parent operation’s results.


resultsany type