| 1 |
! OpenACC parallelism dimensions clauses: num_gangs, num_workers, |
| 2 |
! vector_length. |
| 3 |
|
| 4 |
! { dg-additional-sources parallel-dims-aux.c } |
| 5 |
! { dg-additional-options -Wno-complain-wrong-lang } |
| 6 |
! { dg-do run } |
| 7 |
|
| 8 |
! { dg-additional-options "-DEXPENSIVE" { target run_expensive_tests } } |
| 9 |
! { dg-additional-options "-cpp" } |
| 10 |
|
| 11 |
! { dg-additional-options "-fopt-info-note-omp" } |
| 12 |
! { dg-additional-options "--param=openacc-privatization=noisy" } |
| 13 |
! { dg-additional-options "-foffload=-fopt-info-note-omp" } |
| 14 |
! { dg-additional-options "-foffload=--param=openacc-privatization=noisy" } |
| 15 |
! for testing/documenting aspects of that functionality. |
| 16 |
|
| 17 |
! { dg-additional-options "-Wopenacc-parallelism" } for testing/documenting |
| 18 |
! aspects of that functionality. |
| 19 |
|
| 20 |
! See also '../libgomp.oacc-c-c++-common/parallel-dims.c'. |
| 21 |
|
| 22 |
module acc_routines |
| 23 |
implicit none (type, external) |
| 24 |
|
| 25 |
interface |
| 26 |
integer function acc_gang() bind(C) |
| 27 |
!$acc routine seq |
| 28 |
end function acc_gang |
| 29 |
|
| 30 |
integer function acc_worker() bind(C) |
| 31 |
!$acc routine seq |
| 32 |
end function acc_worker |
| 33 |
|
| 34 |
integer function acc_vector() bind(C) |
| 35 |
!$acc routine seq |
| 36 |
end function acc_vector |
| 37 |
end interface |
| 38 |
end module acc_routines |
| 39 |
|
| 40 |
program main |
| 41 |
use iso_c_binding |
| 42 |
use openacc |
| 43 |
use acc_routines |
| 44 |
implicit none (type, external) |
| 45 |
|
| 46 |
integer :: gangs_min, gangs_max, workers_min, workers_max, vectors_min, vectors_max |
| 47 |
integer :: vectors_actual |
| 48 |
integer :: i, j, k |
| 49 |
|
| 50 |
|
| 51 |
#ifdef EXPENSIVE |
| 52 |
integer, parameter :: N = 100 |
| 53 |
#else |
| 54 |
integer, parameter :: N = 50 |
| 55 |
#endif |
| 56 |
|
| 57 |
call acc_init (acc_device_default) |
| 58 |
|
| 59 |
! OpenACC parallel construct. |
| 60 |
|
| 61 |
!TODO |
| 62 |
|
| 63 |
|
| 64 |
! OpenACC kernels construct. |
| 65 |
|
| 66 |
!TODO |
| 67 |
|
| 68 |
|
| 69 |
! OpenACC serial construct. |
| 70 |
|
| 71 |
! GR, WS, VS. |
| 72 |
|
| 73 |
gangs_min = huge(gangs_min) ! INT_MAX |
| 74 |
workers_min = huge(workers_min) ! INT_MAX |
| 75 |
vectors_min = huge(vectors_min) ! INT_MAX |
| 76 |
gangs_max = -huge(gangs_max) - 1 ! INT_MIN |
| 77 |
workers_max = -huge(gangs_max) - 1 ! INT_MIN |
| 78 |
vectors_max = -huge(gangs_max) - 1 ! INT_MIN |
| 79 |
!$acc serial & |
| 80 |
!$acc reduction (min: gangs_min, workers_min, vectors_min) reduction (max: gangs_max, workers_max, vectors_max) ! { dg-warning "using .vector_length \\(32\\)., ignoring 1" "" { target openacc_nvidia_accel_selected } } |
| 81 |
! { dg-note {variable 'D\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-1 } |
| 82 |
do i = N, -(N-1), -1 |
| 83 |
gangs_min = acc_gang (); |
| 84 |
gangs_max = acc_gang (); |
| 85 |
workers_min = acc_worker (); |
| 86 |
workers_max = acc_worker (); |
| 87 |
vectors_min = acc_vector (); |
| 88 |
vectors_max = acc_vector (); |
| 89 |
end do |
| 90 |
!$acc end serial |
| 91 |
if (gangs_min /= 0 .or. gangs_max /= 1 - 1 & |
| 92 |
.or. workers_min /= 0 .or. workers_max /= 1 - 1 & |
| 93 |
.or. vectors_min /= 0 .or. vectors_max /= 1 - 1) & |
| 94 |
stop 1 |
| 95 |
|
| 96 |
! Composition of GP, WP, VP. |
| 97 |
|
| 98 |
vectors_actual = 1 ! Implicit 'vector_length (1)' clause. |
| 99 |
gangs_min = huge(gangs_min) ! INT_MAX |
| 100 |
workers_min = huge(workers_min) ! INT_MAX |
| 101 |
vectors_min = huge(vectors_min) ! INT_MAX |
| 102 |
gangs_max = -huge(gangs_max) - 1 ! INT_MIN |
| 103 |
workers_max = -huge(gangs_max) - 1 ! INT_MIN |
| 104 |
vectors_max = -huge(gangs_max) - 1 ! INT_MIN |
| 105 |
!$acc serial copy (vectors_actual) & |
| 106 |
!$acc copy (gangs_min, gangs_max, workers_min, workers_max, vectors_min, vectors_max) ! { dg-warning "using .vector_length \\(32\\)., ignoring 1" "" { target openacc_nvidia_accel_selected } } |
| 107 |
! { dg-bogus "\[Ww\]arning: region contains gang partitioned code but is not gang partitioned" "TODO 'serial'" { xfail *-*-* } .-1 } |
| 108 |
! { dg-bogus "\[Ww\]arning: region contains worker partitioned code but is not worker partitioned" "TODO 'serial'" { xfail *-*-* } .-2 } |
| 109 |
! { dg-bogus "\[Ww\]arning: region contains vector partitioned code but is not vector partitioned" "TODO 'serial'" { xfail *-*-* } .-3 } |
| 110 |
! { dg-note {variable 'C.[0-9]+' declared in block potentially has improper OpenACC privatization level: 'const_decl'} "TODO" { target *-*-* } .-4 } |
| 111 |
!TODO Unhandled 'CONST_DECL' instance for constant argument in 'acc_on_device' call. |
| 112 |
if (acc_on_device (acc_device_nvidia)) then |
| 113 |
! The GCC nvptx back end enforces vector_length (32). |
| 114 |
! It's unclear if that's actually permissible here; |
| 115 |
! <https://github.com/OpenACC/openacc-spec/issues/238> "OpenACC 'serial' |
| 116 |
! construct might not actually be serial". |
| 117 |
vectors_actual = 32 |
| 118 |
end if |
| 119 |
!$acc loop gang reduction (min: gangs_min, workers_min, vectors_min) reduction (max: gangs_max, workers_max, vectors_max) |
| 120 |
! { dg-note {variable 'i' in 'private' clause isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-1 } |
| 121 |
do i = N, -(N-1), -1 |
| 122 |
!$acc loop worker reduction (min: gangs_min, workers_min, vectors_min) reduction (max: gangs_max, workers_max, vectors_max) |
| 123 |
! { dg-note {variable 'j' in 'private' clause isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-1 } |
| 124 |
! { dg-note {variable 'D\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-2 } |
| 125 |
do j = N, -(N-1), -1 |
| 126 |
!$acc loop vector reduction (min: gangs_min, workers_min, vectors_min) reduction (max: gangs_max, workers_max, vectors_max) |
| 127 |
! { dg-note {variable 'k' in 'private' clause isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-1 } |
| 128 |
do k = N * vectors_actual, -(N-1) * vectors_actual, -1 |
| 129 |
gangs_min = acc_gang (); |
| 130 |
gangs_max = acc_gang (); |
| 131 |
workers_min = acc_worker (); |
| 132 |
workers_max = acc_worker (); |
| 133 |
vectors_min = acc_vector (); |
| 134 |
vectors_max = acc_vector (); |
| 135 |
end do |
| 136 |
end do |
| 137 |
end do |
| 138 |
!$acc end serial |
| 139 |
if (acc_get_device_type () .eq. acc_device_nvidia) then |
| 140 |
if (vectors_actual /= 32) stop 2 |
| 141 |
else |
| 142 |
if (vectors_actual /= 1) stop 3 |
| 143 |
end if |
| 144 |
if (gangs_min /= 0 .or. gangs_max /= 1 - 1 & |
| 145 |
.or. workers_min /= 0 .or. workers_max /= 1 - 1 & |
| 146 |
.or. vectors_min /= 0 .or. vectors_max /= vectors_actual - 1) & |
| 147 |
stop 4 |
| 148 |
|
| 149 |
end program main |