76 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 6module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry<"dlti.alloca_memory_space", 5 : ui32>>, llvm.data_layout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-p7:160:256:256:32-p8:128:128:128:48-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1-ni:7:8", llvm.target_triple = "amdgcn-amd-amdhsa", omp.is_gpu = true, omp.is_target_device = true } {7 omp.private {type = private} @_QFsimple_target_teams_only_reductionEindex__private_i32 : i328 omp.declare_reduction @add_reduction_i32 : i32 init {9 ^bb0(%arg0: i32):10 %0 = llvm.mlir.constant(0 : i32) : i3211 omp.yield(%0 : i32)12 } combiner {13 ^bb0(%arg0: i32, %arg1: i32):14 %0 = llvm.add %arg0, %arg1 : i3215 omp.yield(%0 : i32)16 }17 llvm.func @simple_target_teams_only_reduction_() attributes {fir.internal_name = "_QPsimple_target_teams_only_reduction", frame_pointer = #llvm.framePointerKind<all>, omp.declare_target = #omp.declaretarget<device_type = (host), capture_clause = (to)>, target_cpu = "gfx1030", target_features = #llvm.target_features<["+16-bit-insts", "+ci-insts", "+dl-insts", "+dot1-insts", "+dot10-insts", "+dot2-insts", "+dot5-insts", "+dot6-insts", "+dot7-insts", "+dpp", "+gfx10-3-insts", "+gfx10-insts", "+gfx8-insts", "+gfx9-insts", "+gws", "+image-insts", "+s-memrealtime", "+s-memtime-inst", "+wavefrontsize32"]>} {18 %0 = llvm.mlir.constant(1 : i64) : i6419 %1 = llvm.alloca %0 x i32 {bindc_name = "sum"} : (i64) -> !llvm.ptr<5>20 %2 = llvm.addrspacecast %1 : !llvm.ptr<5> to !llvm.ptr21 %3 = llvm.mlir.constant(1 : i64) : i6422 %4 = llvm.alloca %3 x i32 {bindc_name = "index_"} : (i64) -> !llvm.ptr<5>23 %5 = llvm.addrspacecast %4 : !llvm.ptr<5> to !llvm.ptr24 %6 = llvm.mlir.constant(0 : i32) : i3225 %7 = llvm.mlir.constant(1 : i64) : i6426 %8 = llvm.mlir.constant(1 : i64) : i6427 llvm.store %6, %2 : i32, !llvm.ptr28 %9 = omp.map.info var_ptr(%2 : !llvm.ptr, i32) map_clauses(tofrom) capture(ByRef) -> !llvm.ptr {name = "sum"}29 %10 = omp.map.info var_ptr(%5 : !llvm.ptr, i32) map_clauses(implicit, exit_release_or_enter_alloc) capture(ByCopy) -> !llvm.ptr {name = "index_"}30 omp.target map_entries(%9 -> %arg0, %10 -> %arg1 : !llvm.ptr, !llvm.ptr) {31 %11 = llvm.mlir.constant(10000 : i32) : i3232 %12 = llvm.mlir.constant(1 : i32) : i3233 omp.teams reduction(@add_reduction_i32 %arg0 -> %arg2 : !llvm.ptr) {34 omp.distribute private(@_QFsimple_target_teams_only_reductionEindex__private_i32 %arg1 -> %arg3 : !llvm.ptr) {35 omp.loop_nest (%arg4) : i32 = (%12) to (%11) inclusive step (%12) {36 llvm.store %arg4, %arg3 : i32, !llvm.ptr37 %13 = llvm.load %arg2 : !llvm.ptr -> i3238 %14 = llvm.load %arg3 : !llvm.ptr -> i3239 %15 = llvm.add %13, %14 : i3240 llvm.store %15, %arg2 : i32, !llvm.ptr41 omp.yield42 }43 }44 omp.terminator45 }46 omp.terminator47 }48 llvm.return49 }50}51 52// CHECK: call i32 @__kmpc_target_init53// CHECK: call void @[[OUTLINED:__omp_offloading_[A-Za-z0-9_.]*]]54// CHECK: define internal void @[[OUTLINED]]55// CHECK: %[[MASTER:.+]] = call i32 @__kmpc_nvptx_teams_reduce_nowait_v256// CHECK: icmp eq i32 %[[MASTER]], 157// CHECK: i1 %{{.+}}, label %[[THEN:[A-Za-z0-9_.]*]], label %[[DONE:[A-Za-z0-9_.]*]]58 59// CHECK: call void @__kmpc_barrier60 61// CHECK: [[THEN]]:62// CHECK-NEXT: %[[FINAL_LHS:[A-Za-z0-9_.]*]] = load i3263// CHECK-NEXT: %[[FINAL_RHS:[A-Za-z0-9_.]*]] = load i3264// CHECK-NEXT: %[[FINAL_RESULT:[A-Za-z0-9_.]*]] = add i32 %[[FINAL_LHS]], %[[FINAL_RHS]]65// CHECK-NEXT: store i32 %[[FINAL_RESULT]]66 67 68// CHECK: call void @__kmpc_distribute_static_loop_4u69// CHECK-SAME: [[OUTLINED2:__omp_offloading_[A-Za-z0-9_.]*]]70 71// CHECK: define internal void @[[OUTLINED2]]72// CHECK: %[[TEAM_RHS:[A-Za-z0-9_.]*]] = load i3273// CHECK-NEXT: %[[TEAM_LHS:[A-Za-z0-9_.]*]] = load i3274// CHECK-NEXT: %[[TEAM_RESULT:[A-Za-z0-9_.]*]] = add i32 %[[TEAM_RHS]], %[[TEAM_LHS]]75// CHECK-NEXT: store i32 %[[TEAM_RESULT]]76