|
| 1 | +!RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s --check-prefixes ALL,HOST |
| 2 | +!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-is-device %s -o - | FileCheck %s --check-prefixes ALL,DEVICE |
| 3 | + |
| 4 | +! Check specification valid forms of declare target with functions |
| 5 | +! utilising device_type and to clauses as well as the default |
| 6 | +! zero clause declare target |
| 7 | + |
| 8 | +! DEVICE-LABEL: func.func @_QPfunc_t_device() |
| 9 | +! DEVICE-SAME: {{.*}}attributes {omp.declare_target = #omp.declaretarget<device_type = (nohost), capture_clause = (to)>{{.*}} |
| 10 | +FUNCTION FUNC_T_DEVICE() RESULT(I) |
| 11 | +!$omp declare target to(FUNC_T_DEVICE) device_type(nohost) |
| 12 | + INTEGER :: I |
| 13 | + I = 1 |
| 14 | +END FUNCTION FUNC_T_DEVICE |
| 15 | + |
| 16 | +! HOST-LABEL: func.func @_QPfunc_t_host() |
| 17 | +! HOST-SAME: {{.*}}attributes {omp.declare_target = #omp.declaretarget<device_type = (host), capture_clause = (to)>{{.*}} |
| 18 | +FUNCTION FUNC_T_HOST() RESULT(I) |
| 19 | +!$omp declare target to(FUNC_T_HOST) device_type(host) |
| 20 | + INTEGER :: I |
| 21 | + I = 1 |
| 22 | +END FUNCTION FUNC_T_HOST |
| 23 | + |
| 24 | +! ALL-LABEL: func.func @_QPfunc_t_any() |
| 25 | +! ALL-SAME: {{.*}}attributes {omp.declare_target = #omp.declaretarget<device_type = (any), capture_clause = (to)>{{.*}} |
| 26 | +FUNCTION FUNC_T_ANY() RESULT(I) |
| 27 | +!$omp declare target to(FUNC_T_ANY) device_type(any) |
| 28 | + INTEGER :: I |
| 29 | + I = 1 |
| 30 | +END FUNCTION FUNC_T_ANY |
| 31 | + |
| 32 | +! ALL-LABEL: func.func @_QPfunc_default_t_any() |
| 33 | +! ALL-SAME: {{.*}}attributes {omp.declare_target = #omp.declaretarget<device_type = (any), capture_clause = (to)>{{.*}} |
| 34 | +FUNCTION FUNC_DEFAULT_T_ANY() RESULT(I) |
| 35 | +!$omp declare target to(FUNC_DEFAULT_T_ANY) |
| 36 | + INTEGER :: I |
| 37 | + I = 1 |
| 38 | +END FUNCTION FUNC_DEFAULT_T_ANY |
| 39 | + |
| 40 | +! ALL-LABEL: func.func @_QPfunc_default_any() |
| 41 | +! ALL-SAME: {{.*}}attributes {omp.declare_target = #omp.declaretarget<device_type = (any), capture_clause = (to)>{{.*}} |
| 42 | +FUNCTION FUNC_DEFAULT_ANY() RESULT(I) |
| 43 | +!$omp declare target |
| 44 | + INTEGER :: I |
| 45 | + I = 1 |
| 46 | +END FUNCTION FUNC_DEFAULT_ANY |
| 47 | + |
| 48 | +! ALL-LABEL: func.func @_QPfunc_default_extendedlist() |
| 49 | +! ALL-SAME: {{.*}}attributes {omp.declare_target = #omp.declaretarget<device_type = (any), capture_clause = (to)>{{.*}} |
| 50 | +FUNCTION FUNC_DEFAULT_EXTENDEDLIST() RESULT(I) |
| 51 | +!$omp declare target(FUNC_DEFAULT_EXTENDEDLIST) |
| 52 | + INTEGER :: I |
| 53 | + I = 1 |
| 54 | +END FUNCTION FUNC_DEFAULT_EXTENDEDLIST |
| 55 | + |
| 56 | +!! ----- |
| 57 | + |
| 58 | +! Check specification valid forms of declare target with subroutines |
| 59 | +! utilising device_type and to clauses as well as the default |
| 60 | +! zero clause declare target |
| 61 | + |
| 62 | +! DEVICE-LABEL: func.func @_QPsubr_t_device() |
| 63 | +! DEVICE-SAME: {{.*}}attributes {omp.declare_target = #omp.declaretarget<device_type = (nohost), capture_clause = (to)>{{.*}} |
| 64 | +SUBROUTINE SUBR_T_DEVICE() |
| 65 | +!$omp declare target to(SUBR_T_DEVICE) device_type(nohost) |
| 66 | +END |
| 67 | + |
| 68 | +! HOST-LABEL: func.func @_QPsubr_t_host() |
| 69 | +! HOST-SAME: {{.*}}attributes {omp.declare_target = #omp.declaretarget<device_type = (host), capture_clause = (to)>{{.*}} |
| 70 | +SUBROUTINE SUBR_T_HOST() |
| 71 | +!$omp declare target to(SUBR_T_HOST) device_type(host) |
| 72 | +END |
| 73 | + |
| 74 | +! ALL-LABEL: func.func @_QPsubr_t_any() |
| 75 | +! ALL-SAME: {{.*}}attributes {omp.declare_target = #omp.declaretarget<device_type = (any), capture_clause = (to)>{{.*}} |
| 76 | +SUBROUTINE SUBR_T_ANY() |
| 77 | +!$omp declare target to(SUBR_T_ANY) device_type(any) |
| 78 | +END |
| 79 | + |
| 80 | +! ALL-LABEL: func.func @_QPsubr_default_t_any() |
| 81 | +! ALL-SAME: {{.*}}attributes {omp.declare_target = #omp.declaretarget<device_type = (any), capture_clause = (to)>{{.*}} |
| 82 | +SUBROUTINE SUBR_DEFAULT_T_ANY() |
| 83 | +!$omp declare target to(SUBR_DEFAULT_T_ANY) |
| 84 | +END |
| 85 | + |
| 86 | +! ALL-LABEL: func.func @_QPsubr_default_any() |
| 87 | +! ALL-SAME: {{.*}}attributes {omp.declare_target = #omp.declaretarget<device_type = (any), capture_clause = (to)>{{.*}} |
| 88 | +SUBROUTINE SUBR_DEFAULT_ANY() |
| 89 | +!$omp declare target |
| 90 | +END |
| 91 | + |
| 92 | +! ALL-LABEL: func.func @_QPsubr_default_extendedlist() |
| 93 | +! ALL-SAME: {{.*}}attributes {omp.declare_target = #omp.declaretarget<device_type = (any), capture_clause = (to)>{{.*}} |
| 94 | +SUBROUTINE SUBR_DEFAULT_EXTENDEDLIST() |
| 95 | +!$omp declare target(SUBR_DEFAULT_EXTENDEDLIST) |
| 96 | +END |
| 97 | + |
| 98 | +!! ----- |
| 99 | + |
| 100 | +! DEVICE-LABEL: func.func @_QPrecursive_declare_target |
| 101 | +! DEVICE-SAME: {{.*}}attributes {omp.declare_target = #omp.declaretarget<device_type = (nohost), capture_clause = (to)>{{.*}} |
| 102 | +RECURSIVE FUNCTION RECURSIVE_DECLARE_TARGET(INCREMENT) RESULT(K) |
| 103 | +!$omp declare target to(RECURSIVE_DECLARE_TARGET) device_type(nohost) |
| 104 | + INTEGER :: INCREMENT, K |
| 105 | + IF (INCREMENT == 10) THEN |
| 106 | + K = INCREMENT |
| 107 | + ELSE |
| 108 | + K = RECURSIVE_DECLARE_TARGET(INCREMENT + 1) |
| 109 | + END IF |
| 110 | +END FUNCTION RECURSIVE_DECLARE_TARGET |
0 commit comments