I have compiled the following code, inspired by the first example in https://docs.computecanada.ca/wiki/OpenACC_Tutorial_-_Adding_directives
program example_acc
implicit none
integer :: i, N
real(8), dimension(1:200000000) :: x
real(8), dimension(1:200000000) :: y
real(8) :: a
a = 3.14159265d0
N = 200000000
!$acc kernels
do i = 1, N
x(i) = 1.0d0
y(i) = 2.0d0
end do
y(:) = a*x(:) + y(:)
!$acc end kernels
end program example_acc
I am using gfortran 9.3.0 under Ubuntu 20.04:
$ gfortran example_acc.f90 && time ./a.out
real 0m2,237s
user 0m1,477s
sys 0m0,760s
When trying to compile with -fopenacc, I had the following error:
lto-wrapper: fatal error: could not find accel/nvptx-none/mkoffload in /usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/ (consider using ‘-B’)
compilation terminated.
/usr/bin/ld : erreur : lto-wrapper failed
collect2: error: ld returned 1 exit status
I have installed the gcc-offload-nvptx packages: “This package contains libgomp plugin for offloading to NVidia PTX. The plugin needs libcuda.so.1 shared library that has to be installed separately.”
$ gfortran -fopenacc example_acc.f90 && time ./a.out
real 0m2,557s
user 0m1,667s
sys 0m0,891s
So, it seems you need a NVidia accelerator, but I have an ATI Radeon on my HP ZBook…