86 lines · plain
1!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=52 %s -o - | FileCheck %s2!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=52 -fopenmp-is-device %s -o - | FileCheck %s --check-prefix=DEVICE3!RUN: bbc -emit-hlfir -fopenmp -fopenmp-version=52 %s -o - | FileCheck %s4!RUN: bbc -emit-hlfir -fopenmp -fopenmp-version=52 -fopenmp-is-target-device %s -o - | FileCheck %s --check-prefix=DEVICE5 6! DEVICE-LABEL: func.func @_QPimplicit_capture7! DEVICE-SAME: {{.*}}attributes {omp.declare_target = #omp.declaretarget<device_type = (nohost), capture_clause = (to), automap = false>{{.*}}}8function implicit_capture() result(i)9 implicit none10 integer :: i11 i = 112end function implicit_capture13 14subroutine subr_target()15 integer :: n16!$omp target map(tofrom:n)17 n = implicit_capture()18!$omp end target19end subroutine20 21!! -----22 23! CHECK-LABEL: func.func @_QPimplicitly_captured_nest_twice24! CHECK-SAME: {{.*}}attributes {omp.declare_target = #omp.declaretarget<device_type = (any), capture_clause = (to), automap = false>{{.*}}}25function implicitly_captured_nest_twice() result(i)26 integer :: i27 i = 1028end function implicitly_captured_nest_twice29 30! CHECK-LABEL: func.func @_QPimplicitly_captured_one_twice31! CHECK-SAME: {{.*}}attributes {omp.declare_target = #omp.declaretarget<device_type = (any), capture_clause = (to), automap = false>{{.*}}}32function implicitly_captured_one_twice() result(k)33!$omp declare target to(implicitly_captured_one_twice) device_type(host)34 k = implicitly_captured_nest_twice()35end function implicitly_captured_one_twice36 37! CHECK-LABEL: func.func @_QPimplicitly_captured_nest_twice_enter38! CHECK-SAME: {{.*}}attributes {omp.declare_target = #omp.declaretarget<device_type = (host), capture_clause = (enter), automap = false>{{.*}}}39function implicitly_captured_nest_twice_enter() result(i)40 integer :: i41 i = 1042end function implicitly_captured_nest_twice_enter43 44! CHECK-LABEL: func.func @_QPimplicitly_captured_one_twice_enter45! CHECK-SAME: {{.*}}attributes {omp.declare_target = #omp.declaretarget<device_type = (host), capture_clause = (enter), automap = false>{{.*}}}46function implicitly_captured_one_twice_enter() result(k)47!$omp declare target enter(implicitly_captured_one_twice_enter) device_type(host)48 k = implicitly_captured_nest_twice_enter()49end function implicitly_captured_one_twice_enter50 51! DEVICE-LABEL: func.func @_QPimplicitly_captured_two_twice52! DEVICE-SAME: {{.*}}attributes {omp.declare_target = #omp.declaretarget<device_type = (nohost), capture_clause = (to), automap = false>{{.*}}}53function implicitly_captured_two_twice() result(y)54 integer :: y55 y = 556end function implicitly_captured_two_twice57 58 59function target_function_test_device() result(j)60 integer :: i, j61 !$omp target map(tofrom: i, j)62 i = implicitly_captured_one_twice()63 j = implicitly_captured_two_twice() + i64 !$omp end target65end function target_function_test_device66 67!! -----68 69! DEVICE-LABEL: func.func @_QPimplicitly_captured_recursive70! DEVICE-SAME: {{.*}}attributes {omp.declare_target = #omp.declaretarget<device_type = (nohost), capture_clause = (to), automap = false>{{.*}}}71recursive function implicitly_captured_recursive(increment) result(k)72 integer :: increment, k73 if (increment == 10) then74 k = increment75 else76 k = implicitly_captured_recursive(increment + 1)77 end if78end function implicitly_captured_recursive79 80function target_function_recurse() result(i)81 integer :: i82 !$omp target map(tofrom: i)83 i = implicitly_captured_recursive(0)84 !$omp end target85end function target_function_recurse86