diff --git a/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td b/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td --- a/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td +++ b/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td @@ -113,6 +113,43 @@ let assemblyFormat = "attr-dict"; } +//===---------------------------------------------------------------------===// +// 2.7 teams Construct +//===---------------------------------------------------------------------===// + +def TeamsOp : OpenMP_Op<"teams", [AttrSizedOperandSegments]> { + let summary = "teams construct"; + let description = [{ + The teams construct creates a league of initial teams and the initial thread + in each team executes the region. + + 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 region that are not passed explicitly as parameters + + 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. + + }]; + + let arguments = (ins Optional:$num_threads_var, + OptionalAttr:$default_val, + Variadic:$private_vars, + Variadic:$firstprivate_vars, + Variadic:$shared_vars, + Variadic:$copyin_vars, + Variadic:$allocate_vars, + Variadic:$allocators_vars); + + let regions = (region AnyRegion:$region); +} + //===----------------------------------------------------------------------===// // 2.9.2 Workshare Loop Construct //===----------------------------------------------------------------------===// @@ -258,6 +295,7 @@ let assemblyFormat = [{ ( `(` $varList^ `:` type($varList) `)` )? attr-dict}]; } + //===----------------------------------------------------------------------===// // 2.14.5 target construct //===----------------------------------------------------------------------===// @@ -293,9 +331,9 @@ let builders = [ OpBuilder<(ins "IntegerAttr":$if_expr, - "IntegerAttr":$device, - "IntegerAttr":$thread_limit, - "UnitAttr":$nowait)> + "IntegerAttr":$device, + "IntegerAttr":$thread_limit, + "UnitAttr":$nowait)> ]; } diff --git a/mlir/test/Dialect/OpenMP/ops.mlir b/mlir/test/Dialect/OpenMP/ops.mlir --- a/mlir/test/Dialect/OpenMP/ops.mlir +++ b/mlir/test/Dialect/OpenMP/ops.mlir @@ -297,3 +297,20 @@ return } + + +// CHECK-LABEL: omp_teams +func @omp_teams(%data_var : memref, %num_threads : si32) -> () { + + // CHECK: omp.teams + "omp.teams"(%num_threads, %data_var, %data_var, %data_var, %data_var) ({ + // CHECK: omp.terminator + omp.terminator + }) {operand_segment_sizes = dense<[1,1,1,1,1,0,0]>: vector<7xi32>, default_val = "defshared"} : (si32, memref, memref, memref, memref) -> () + + // CHECK: omp.barrier + omp.barrier + + return +} +