brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.1 KiB · 0b1f45a Raw
81 lines · plain
1// RUN: mlir-translate -mlir-to-llvmir -split-input-file %s | FileCheck %s2 3// tests a wsloop private + firstprivate + reduction to make sure block structure4// is handled properly.5 6omp.private {type = private} @_QFwsloop_privateEi_private_ref_i32 : i327 8llvm.func @foo_free(!llvm.ptr)9 10omp.private {type = firstprivate} @_QFwsloop_privateEc_firstprivate_ref_c8 : !llvm.array<1 x i8> copy {11^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr):12  %0 = llvm.load %arg0 : !llvm.ptr -> !llvm.array<1 x i8>13  llvm.store %0, %arg1 : !llvm.array<1 x i8>, !llvm.ptr14  omp.yield(%arg1 : !llvm.ptr)15} dealloc {16^bb0(%arg0: !llvm.ptr):17  llvm.call @foo_free(%arg0) : (!llvm.ptr) -> ()18  omp.yield19}20 21omp.declare_reduction @max_f32 : f32 init {22^bb0(%arg0: f32):23  %0 = llvm.mlir.constant(-3.40282347E+38 : f32) : f3224  omp.yield(%0 : f32)25} combiner {26^bb0(%arg0: f32, %arg1: f32):27  %0 = llvm.intr.maxnum(%arg0, %arg1) {fastmathFlags = #llvm.fastmath<contract>} : (f32, f32) -> f3228  omp.yield(%0 : f32)29}30 31llvm.func @wsloop_private_(%arg0: !llvm.ptr {fir.bindc_name = "y"}) attributes {fir.internal_name = "_QPwsloop_private", frame_pointer = #llvm.framePointerKind<all>, target_cpu = "x86-64"} {32  %0 = llvm.mlir.constant(1 : i64) : i6433  %1 = llvm.alloca %0 x f32 {bindc_name = "x"} : (i64) -> !llvm.ptr34  %3 = llvm.alloca %0 x i32 {bindc_name = "i"} : (i64) -> !llvm.ptr35  %5 = llvm.alloca %0 x !llvm.array<1 x i8> {bindc_name = "c"} : (i64) -> !llvm.ptr36  %6 = llvm.mlir.constant(1 : i32) : i3237  %7 = llvm.mlir.constant(10 : i32) : i3238  %8 = llvm.mlir.constant(0 : i32) : i3239  omp.parallel {40    omp.wsloop private(@_QFwsloop_privateEc_firstprivate_ref_c8 %5 -> %arg1, @_QFwsloop_privateEi_private_ref_i32 %3 -> %arg2 : !llvm.ptr, !llvm.ptr) private_barrier reduction(@max_f32 %1 -> %arg3 : !llvm.ptr) {41      omp.loop_nest (%arg4) : i32 = (%8) to (%7) inclusive step (%6) {42        omp.yield43      }44    }45    omp.terminator46  }47  llvm.return48}49 50// CHECK: call void {{.*}} @__kmpc_fork_call(ptr @1, i32 1, ptr @[[OUTLINED:.*]], ptr %{{.*}})51 52// CHECK: define internal void @[[OUTLINED:.*]]{{.*}} {53 54// First, check that all memory for privates and reductions is allocated.55// CHECK: omp.par.entry:56// CHECK:   %[[CHR:.*]] = alloca [1 x i8], align 157// CHECK:   %[[INT:.*]] = alloca i32, align 458// CHECK:   %[[FLT:.*]] = alloca float, align 459// CHECK:   %[[RED_ARR:.*]] = alloca [1 x ptr], align 860// CHECK:   br label %[[LATE_ALLOC_BB:.*]]61 62// CHECK: [[LATE_ALLOC_BB]]:63// CHECK:   br label %[[PRIVATE_CPY_BB:.*]]64 65// Second, check that first private was properly copied.66// CHECK: [[PRIVATE_CPY_BB:.*]]:67// CHECK:   %[[CHR_VAL:.*]] = load [1 x i8], ptr %{{.*}}, align 168// CHECK:   store [1 x i8] %[[CHR_VAL]], ptr %[[CHR]], align 169// CHECK:   %[[THREAD_NUM:.*]] = call i32 @__kmpc_global_thread_num({{.*}})70// CHECK:   call void @__kmpc_barrier({{.*}}, i32 %[[THREAD_NUM]])71// CHECK:   br label %[[RED_INIT_BB:.*]]72 73// Third, check that reduction init took place.74// CHECK: [[RED_INIT_BB]]:75// CHECK:   store float 0x{{.*}}, ptr %[[FLT]], align 476 77// Finally, check for the private dealloc region78// CHECK:   call void @foo_free(ptr %[[CHR]])79 80// CHECK: }81