72 lines · plain
1// RUN: mlir-translate -mlir-to-llvmir %s | FileCheck %s2 3// Only check the overall shape of the code and the presence of relevant4// runtime calls. Actual IR checking is done at the OpenMPIRBuilder level.5 6omp.private {type = private} @_QFsimple_teams_reductionEindex__private_i32 : i327omp.declare_reduction @add_reduction_i32 : i32 init {8^bb0(%arg0: i32):9 %0 = llvm.mlir.constant(0 : i32) : i3210 omp.yield(%0 : i32)11} combiner {12^bb0(%arg0: i32, %arg1: i32):13 %0 = llvm.add %arg0, %arg1 : i3214 omp.yield(%0 : i32)15}16llvm.func @simple_teams_reduction_() attributes {fir.internal_name = "_QPsimple_teams_reduction", frame_pointer = #llvm.framePointerKind<all>, target_cpu = "x86-64"} {17 %0 = llvm.mlir.constant(1 : i64) : i6418 %1 = llvm.alloca %0 x i32 {bindc_name = "sum"} : (i64) -> !llvm.ptr19 %2 = llvm.mlir.constant(1 : i64) : i6420 %3 = llvm.alloca %2 x i32 {bindc_name = "index_"} : (i64) -> !llvm.ptr21 %4 = llvm.mlir.constant(10000 : i32) : i3222 %5 = llvm.mlir.constant(1 : i32) : i3223 %6 = llvm.mlir.constant(0 : i32) : i3224 %7 = llvm.mlir.constant(1 : i64) : i6425 %8 = llvm.mlir.constant(1 : i64) : i6426 llvm.store %6, %1 : i32, !llvm.ptr27 omp.teams reduction(@add_reduction_i32 %1 -> %arg0 : !llvm.ptr) {28 omp.distribute private(@_QFsimple_teams_reductionEindex__private_i32 %3 -> %arg1 : !llvm.ptr) {29 omp.loop_nest (%arg2) : i32 = (%5) to (%4) inclusive step (%5) {30 llvm.store %arg2, %arg1 : i32, !llvm.ptr31 %9 = llvm.load %arg0 : !llvm.ptr -> i3232 %10 = llvm.load %arg1 : !llvm.ptr -> i3233 %11 = llvm.add %9, %10 : i3234 llvm.store %11, %arg0 : i32, !llvm.ptr35 omp.yield36 }37 }38 omp.terminator39 }40 llvm.return41}42// Call to outlined function43// CHECK: call void (ptr, i32, ptr, ...) @__kmpc_fork_teams44// CHECK-SAME: @[[OUTLINED:[A-Za-z_.][A-Za-z0-9_.]*]]45 46// Outlined function.47// CHECK: define internal void @[[OUTLINED]]48 49// Private reduction variable and its initialization.50// CHECK: %[[PRIVATE:.+]] = alloca i3251// CHECK: store i32 0, ptr %[[PRIVATE]]52 53// Call to the reduction function.54// CHECK: call i32 @__kmpc_reduce55// CHECK-SAME: @[[REDFUNC:[A-Za-z_.][A-Za-z0-9_.]*]]56 57// Atomic version not generated58// CHECK: unreachable59 60// Non atomic version61// CHECK: call void @__kmpc_end_reduce62 63// Finalize64// CHECK: br label %[[FINALIZE:.+]]65 66// CHECK: [[FINALIZE]]:67// CHECK: call void @__kmpc_barrier68 69// Reduction function.70// CHECK: define internal void @[[REDFUNC]]71// CHECK: add i3272