50 lines · plain
1// RUN: mlir-translate -mlir-to-llvmir %s | FileCheck %s2 3// Tests `target ... nowait` when code gen targets the host rather than a4// device.5 6module attributes {omp.is_target_device = false} {7 llvm.func @omp_target_nowait_() {8 %0 = llvm.mlir.constant(1 : i64) : i649 %1 = llvm.alloca %0 x f32 {bindc_name = "x"} : (i64) -> !llvm.ptr10 %3 = omp.map.info var_ptr(%1 : !llvm.ptr, f32) map_clauses(tofrom) capture(ByRef) -> !llvm.ptr {name = "x"}11 omp.target nowait map_entries(%3 -> %arg0 : !llvm.ptr) {12 %4 = llvm.mlir.constant(5.000000e+00 : f32) : f3213 llvm.store %4, %arg0 : f32, !llvm.ptr14 omp.terminator15 }16 llvm.return17 }18}19 20// CHECK: define void @omp_target_nowait_()21// CHECK-NOT: define {{.*}} @22// CHECK-NOT: call ptr @__kmpc_omp_target_task_alloc({{.*}})23// CHECK: call void @__kmpc_omp_task_begin_if024// CHECK-NEXT: call void @.omp_target_task_proxy_func25// CHECK: call void @__kmpc_omp_task_complete_if026// https://github.com/llvm/llvm-project/issues/126949 exposes two issues27// 1. Empty target task proxy functions28// 2. When 1 fixed, it leads to a second problem of calling the omp target kernel twice29// Once via the target task proxy function and a second time after the target task is done.30// The following checks check problem #2.31// functions. The following checks tests the fix for this issue.32// CHECK-NEXT: br label %[[BLOCK_AFTER_OUTLINED_TARGET_TASK_BODY:.*]]33// CHECK:[[BLOCK_AFTER_OUTLINED_TARGET_TASK_BODY]]:34// CHECK-NEXT: ret void35 36// Verify that we directly emit a call to the "target" region's body from the37// parent function of the the `omp.target` op.38// CHECK: define internal void @omp_target_nowait_..omp_par39// CHECK: call void @__omp_offloading_[[DEV:.*]]_[[FIL:.*]]_omp_target_nowait__l[[LINE:.*]](ptr {{.*}})40// CHECK-NEXT: br label %[[BLOCK_AFTER_TARGET_TASK_BODY:.*]]41// CHECK: [[BLOCK_AFTER_TARGET_TASK_BODY]]:42// CHECK-NEXT: ret void43 44// CHECK: define internal void @__omp_offloading_[[DEV]]_[[FIL]]_omp_target_nowait__l[[LINE]](ptr %[[ADDR_X:.*]])45// CHECK: store float 5{{.*}}, ptr %[[ADDR_X]], align 446 47// The following check test for the fix of problem #1 as described in https://github.com/llvm/llvm-project/issues/12694948// CHECK: define internal void @.omp_target_task_proxy_func49// CHECK: call void @omp_target_nowait_..omp_par50