Skip to content

Commit

Permalink
Add assembly format for wrapper and add test
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanradanov committed Aug 21, 2024
1 parent 8daabbe commit 1b97840
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -314,10 +314,10 @@ def WorkshareLoopWrapperOp : OpenMP_Op<"workshare_loop_wrapper", traits = [
RecursiveMemoryEffects, SingleBlock
], singleRegion = true> {
let summary = "contains loop nests to be parallelized by workshare";

let builders = [
OpBuilder<(ins), [{ build($_builder, $_state, {}); }]>
];
let assemblyFormat = "$region attr-dict";
}

//===----------------------------------------------------------------------===//
Expand Down
61 changes: 61 additions & 0 deletions mlir/test/Dialect/OpenMP/ops.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -2810,3 +2810,64 @@ func.func @omp_target_private(%map1: memref<?xi32>, %map2: memref<?xi32>, %priv_

return
}

// CHECK-LABEL: func @omp_workshare
func.func @omp_workshare() {
// CHECK: omp.workshare {
omp.workshare {
"test.payload"() : () -> ()
// CHECK: omp.terminator
omp.terminator
}
return
}

// CHECK-LABEL: func @omp_workshare_nowait
func.func @omp_workshare_nowait() {
// CHECK: omp.workshare nowait {
omp.workshare nowait {
"test.payload"() : () -> ()
// CHECK: omp.terminator
omp.terminator
}
return
}

// CHECK-LABEL: func @omp_workshare_multiple_blocks
func.func @omp_workshare_multiple_blocks() {
// CHECK: omp.workshare {
omp.workshare {
cf.br ^bb2
^bb2:
// CHECK: omp.terminator
omp.terminator
}
return
}

// CHECK-LABEL: func @omp_workshare_loop_wrapper
func.func @omp_workshare_loop_wrapper(%idx : index) {
// CHECK-NEXT: omp.workshare_loop_wrapper
omp.workshare_loop_wrapper {
// CHECK-NEXT: omp.loop_nest
omp.loop_nest (%iv) : index = (%idx) to (%idx) step (%idx) {
omp.yield
}
omp.terminator
}
return
}

// CHECK-LABEL: func @omp_workshare_loop_wrapper_attrs
func.func @omp_workshare_loop_wrapper_attrs(%idx : index) {
// CHECK-NEXT: omp.workshare_loop_wrapper {
omp.workshare_loop_wrapper {
// CHECK-NEXT: omp.loop_nest
omp.loop_nest (%iv) : index = (%idx) to (%idx) step (%idx) {
omp.yield
}
omp.terminator
// CHECK: } {attr_in_dict}
} {attr_in_dict}
return
}

0 comments on commit 1b97840

Please sign in to comment.