Changeset View
Changeset View
Standalone View
Standalone View
mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
Show First 20 Lines • Show All 302 Lines • ▼ Show 20 Lines | let description = [{ | ||||
} | } | ||||
``` | ``` | ||||
The `linear_step_vars` operand additionally specifies the step for each | The `linear_step_vars` operand additionally specifies the step for each | ||||
associated linear operand. Note that the `linear_vars` and | associated linear operand. Note that the `linear_vars` and | ||||
`linear_step_vars` variadic lists should contain the same number of | `linear_step_vars` variadic lists should contain the same number of | ||||
elements. | elements. | ||||
Reductions can be performed in a workshare loop by specifying reduction | Reductions can be performed in a worksharing-loop by specifying reduction | ||||
accumulator variables in `reduction_vars` and symbols referring to reduction | accumulator variables in `reduction_vars` and symbols referring to reduction | ||||
declarations in the `reductions` attribute. Each reduction is identified | declarations in the `reductions` attribute. Each reduction is identified | ||||
by the accumulator it uses and accumulators must not be repeated in the same | by the accumulator it uses and accumulators must not be repeated in the same | ||||
reduction. The `omp.reduction` operation accepts the accumulator and a | reduction. The `omp.reduction` operation accepts the accumulator and a | ||||
partial value which is considered to be produced by the current loop | partial value which is considered to be produced by the current loop | ||||
iteration for the given reduction. If multiple values are produced for the | iteration for the given reduction. If multiple values are produced for the | ||||
same accumulator, i.e. there are multiple `omp.reduction`s, the last value | same accumulator, i.e. there are multiple `omp.reduction`s, the last value | ||||
is taken. The reduction declaration specifies how to combine the values from | is taken. The reduction declaration specifies how to combine the values from | ||||
each iteration into the final value, which is available in the accumulator | each iteration into the final value, which is available in the accumulator | ||||
after the loop completes. | after the loop completes. | ||||
The optional `schedule_val` attribute specifies the loop schedule for this | The optional `schedule_val` attribute specifies the loop schedule for this | ||||
loop, determining how the loop is distributed across the parallel threads. | loop, determining how the loop is distributed across the parallel threads. | ||||
The optional `schedule_chunk_var` associated with this determines further | The optional `schedule_chunk_var` associated with this determines further | ||||
controls this distribution. | controls this distribution. | ||||
The optional `collapse_val` attribute specifies the number of loops which | |||||
kiranchandramohan: Nit: Can you instead add the following?
Collapsed loops are represented by the worksharing… | |||||
are collapsed to form the worksharing loop. | |||||
The `nowait` attribute, when present, signifies that there should be no | The `nowait` attribute, when present, signifies that there should be no | ||||
implicit barrier at the end of the loop. | implicit barrier at the end of the loop. | ||||
The optional `ordered_val` attribute specifies how many loops are associated | The optional `ordered_val` attribute specifies how many loops are associated | ||||
with the worksharing-loop construct. The value of zero refers to the ordered | with the worksharing-loop construct. The value of zero refers to the ordered | ||||
clause specified without parameter. | clause specified without parameter. | ||||
The optional `order` attribute specifies which order the iterations of the | The optional `order` attribute specifies which order the iterations of the | ||||
associate loops are executed in. Currently the only option for this | associate loops are executed in. Currently the only option for this | ||||
attribute is "concurrent". | attribute is "concurrent". | ||||
}]; | }]; | ||||
let arguments = (ins Variadic<IntLikeType>:$lowerBound, | let arguments = (ins Variadic<IntLikeType>:$lowerBound, | ||||
Variadic<IntLikeType>:$upperBound, | Variadic<IntLikeType>:$upperBound, | ||||
Variadic<IntLikeType>:$step, | Variadic<IntLikeType>:$step, | ||||
Variadic<AnyType>:$linear_vars, | Variadic<AnyType>:$linear_vars, | ||||
Variadic<I32>:$linear_step_vars, | Variadic<I32>:$linear_step_vars, | ||||
Variadic<OpenMP_PointerLikeType>:$reduction_vars, | Variadic<OpenMP_PointerLikeType>:$reduction_vars, | ||||
OptionalAttr<SymbolRefArrayAttr>:$reductions, | OptionalAttr<SymbolRefArrayAttr>:$reductions, | ||||
OptionalAttr<ScheduleKindAttr>:$schedule_val, | OptionalAttr<ScheduleKindAttr>:$schedule_val, | ||||
Optional<AnyType>:$schedule_chunk_var, | Optional<AnyType>:$schedule_chunk_var, | ||||
OptionalAttr<ScheduleModifierAttr>:$schedule_modifier, | OptionalAttr<ScheduleModifierAttr>:$schedule_modifier, | ||||
UnitAttr:$simd_modifier, | UnitAttr:$simd_modifier, | ||||
Confined<OptionalAttr<I64Attr>, [IntMinValue<0>]>:$collapse_val, | |||||
UnitAttr:$nowait, | UnitAttr:$nowait, | ||||
Confined<OptionalAttr<I64Attr>, [IntMinValue<0>]>:$ordered_val, | Confined<OptionalAttr<I64Attr>, [IntMinValue<0>]>:$ordered_val, | ||||
OptionalAttr<OrderKindAttr>:$order_val, | OptionalAttr<OrderKindAttr>:$order_val, | ||||
UnitAttr:$inclusive); | UnitAttr:$inclusive); | ||||
let builders = [ | let builders = [ | ||||
OpBuilder<(ins "ValueRange":$lowerBound, "ValueRange":$upperBound, | OpBuilder<(ins "ValueRange":$lowerBound, "ValueRange":$upperBound, | ||||
"ValueRange":$step, | "ValueRange":$step, | ||||
CArg<"ArrayRef<NamedAttribute>", "{}">:$attributes)>, | CArg<"ArrayRef<NamedAttribute>", "{}">:$attributes)>, | ||||
]; | ]; | ||||
let regions = (region AnyRegion:$region); | let regions = (region AnyRegion:$region); | ||||
let extraClassDeclaration = [{ | let extraClassDeclaration = [{ | ||||
/// Returns the number of loops in the workshape loop nest. | /// Returns the number of loops in the worksharing-loop nest. | ||||
unsigned getNumLoops() { return lowerBound().size(); } | unsigned getNumLoops() { return lowerBound().size(); } | ||||
/// Returns the number of reduction variables. | /// Returns the number of reduction variables. | ||||
unsigned getNumReductionVars() { return reduction_vars().size(); } | unsigned getNumReductionVars() { return reduction_vars().size(); } | ||||
// TODO: remove this once emitAccessorPrefix is set to | // TODO: remove this once emitAccessorPrefix is set to | ||||
// kEmitAccessorPrefix_Prefixed for the dialect. | // kEmitAccessorPrefix_Prefixed for the dialect. | ||||
/// Returns the reduction variables | /// Returns the reduction variables | ||||
operand_range getReductionVars() { return reduction_vars(); } | operand_range getReductionVars() { return reduction_vars(); } | ||||
}]; | }]; | ||||
let hasCustomAssemblyFormat = 1; | let hasCustomAssemblyFormat = 1; | ||||
let assemblyFormat = [{ | let assemblyFormat = [{ | ||||
oilist(`linear` `(` | oilist(`linear` `(` | ||||
custom<LinearClause>($linear_vars, type($linear_vars), | custom<LinearClause>($linear_vars, type($linear_vars), | ||||
$linear_step_vars) `)` | $linear_step_vars) `)` | ||||
|`schedule` `(` | |`schedule` `(` | ||||
custom<ScheduleClause>( | custom<ScheduleClause>( | ||||
$schedule_val, $schedule_modifier, $simd_modifier, | $schedule_val, $schedule_modifier, $simd_modifier, | ||||
$schedule_chunk_var, type($schedule_chunk_var)) `)` | $schedule_chunk_var, type($schedule_chunk_var)) `)` | ||||
|`collapse` `(` $collapse_val `)` | |||||
|`nowait` $nowait | |`nowait` $nowait | ||||
|`ordered` `(` $ordered_val `)` | |`ordered` `(` $ordered_val `)` | ||||
|`order` `(` custom<ClauseAttr>($order_val) `)` | |`order` `(` custom<ClauseAttr>($order_val) `)` | ||||
|`reduction` `(` | |`reduction` `(` | ||||
custom<ReductionVarList>( | custom<ReductionVarList>( | ||||
$reduction_vars, type($reduction_vars), $reductions | $reduction_vars, type($reduction_vars), $reductions | ||||
) `)` | ) `)` | ||||
) `for` custom<WsLoopControl>($region, $lowerBound, $upperBound, $step, | ) `for` custom<WsLoopControl>($region, $lowerBound, $upperBound, $step, | ||||
▲ Show 20 Lines • Show All 766 Lines • Show Last 20 Lines |
Nit: Can you instead add the following?
Collapsed loops are represented by the worksharing loop having a list of indices, bounds and steps where the size of the list is equal to the collapse value.