[Mlir-commits] [mlir] [OpenMP][mlir] Add translation for `if` in `omp.teams` (PR #69404)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Wed Oct 18 11:24:01 PDT 2023


================
@@ -235,3 +235,51 @@ llvm.func @omp_teams_num_teams_and_thread_limit(%numTeamsLower: i32, %numTeamsUp
 // CHECK: define internal void [[OUTLINED_FN]](ptr {{.+}}, ptr {{.+}})
 // CHECK: call void @duringTeams()
 // CHECK: ret void
+
+// -----
+
+llvm.func @beforeTeams()
+llvm.func @duringTeams()
+llvm.func @afterTeams()
+
+// CHECK-LABEL: @teams_if
+// CHECK-SAME: (i1 [[ARG:.+]])
+llvm.func @teams_if(%arg : i1) {
+    // CHECK-NEXT: call void @beforeTeams()
+    llvm.call @beforeTeams() : () -> ()
+    // CHECK: [[NUM_TEAMS_UPPER:%.+]] = select i1 [[ARG]], i32 0, i32 1
+    // CHECK: [[NUM_TEAMS_LOWER:%.+]] = select i1 [[ARG]], i32 0, i32 1
----------------
shraiysh wrote:

Zero does not mean zero teams. The runtime call interprets zero as "not-specified". So, in that case, an "implementation-defined" number of teams are created.

When the condition is true, and there is no num_teams clause, the number of teams should be whatever they would be without the if clause - which in this case falls to the implementation defined number of teams. For LLVM OpenMP library, internally, it sets number of teams to one if zero is passed here.

https://github.com/llvm/llvm-project/pull/69404


More information about the Mlir-commits mailing list