MLIR

Multi-Level IR Compiler Framework

'acc' Dialect

An OpenACC dialect for MLIR.

This dialect models the construct from the OpenACC 3.0 directive language.

Operation definition 

acc.data (::mlir::acc::DataOp) 

data construct

The “acc.data” operation represents a data construct. It defines vars to be allocated in the current device memory for the duration of the region, whether data should be copied from local memory to the current device memory upon region entry , and copied from device memory to local memory upon region exit.

Example:

acc.data present(%a: memref<10x10xf32>, %b: memref<10x10xf32>,
    %c: memref<10xf32>, %d: memref<10xf32>) {
  // data region
}

Operands: 

OperandDescription
presentOperandsany type
copyOperandsany type
copyinOperandsany type
copyinReadonlyOperandsany type
copyoutOperandsany type
copyoutZeroOperandsany type
createOperandsany type
createZeroOperandsany type
noCreateOperandsany type
deleteOperandsany type
attachOperandsany type
detachOperandsany type

acc.loop (::mlir::acc::LoopOp) 

loop construct

The “acc.loop” operation represents the OpenACC loop construct.

Example:

acc.loop gang vector {
  scf.for %arg3 = %c0 to %c10 step %c1 {
    scf.for %arg4 = %c0 to %c10 step %c1 {
      scf.for %arg5 = %c0 to %c10 step %c1 {
        // ... body
      }
    }
  }
  acc.yield
} attributes { collapse = 3 }

Attributes: 

AttributeMLIR TypeDescription
collapse::mlir::IntegerAttr64-bit signless integer attribute
seq::mlir::UnitAttrunit attribute
independent::mlir::UnitAttrunit attribute
auto_::mlir::UnitAttrunit attribute
reductionOp::mlir::StringAttrbuilt-in reduction operations supported by OpenACC
exec_mapping::mlir::IntegerAttr64-bit signless integer attribute

Operands: 

OperandDescription
gangNuminteger or index
gangStaticinteger or index
workerNuminteger or index
vectorLengthinteger or index
tileOperandsinteger or index
privateOperandsany type
reductionOperandsany type

Results: 

ResultDescription
resultsany type

acc.parallel (::mlir::acc::ParallelOp) 

parallel construct

The “acc.parallel” operation represents a parallel construct block. It has one region to be executued in parallel on the current device.

Example:

acc.parallel num_gangs(%c10) num_workers(%c10)
    private(%c : memref<10xf32>) {
  // parallel region
}

Attributes: 

AttributeMLIR TypeDescription
reductionOp::mlir::StringAttrbuilt-in reduction operations supported by OpenACC
defaultAttr::mlir::StringAttrdefault attribute value for parallel op

Operands: 

OperandDescription
asyncinteger or index
waitOperandsinteger or index
numGangsinteger or index
numWorkersinteger or index
vectorLengthinteger or index
ifCond1-bit signless integer
selfCond1-bit signless integer
reductionOperandsany type
copyOperandsany type
copyinOperandsany type
copyinReadonlyOperandsany type
copyoutOperandsany type
copyoutZeroOperandsany type
createOperandsany type
createZeroOperandsany type
noCreateOperandsany type
presentOperandsany type
devicePtrOperandsany type
attachOperandsany type
gangPrivateOperandsany type
gangFirstPrivateOperandsany type

acc.terminator (::mlir::acc::TerminatorOp) 

Generic terminator for OpenACC regions

Syntax:

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

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

acc.yield (::mlir::acc::YieldOp) 

Acc yield and termination operation

Syntax:

operation ::= `acc.yield` attr-dict ($operands^ `:` type($operands))?

acc.yield is a special terminator operation for block inside regions in acc ops (parallel and loop). It returns values to the immediately enclosing acc op.

Operands: 

OperandDescription
operandsany type