Hi,
I downloaded today the NVIDIA HPC Software Development Kit ( Bundled with the newest CUDA version (11.4)) and I am running it on Ubuntu 21.04 LTS. I cannot compile this program attached:
addition.f90 (345 Bytes)
I tried:
pgfortran -acc addition.f90 -o fast_addition.exe
however I can compile with:
gfortran addition.f90 -fopenacc -o fast.exe
How can I make it work with pgfortran?
Thank you for the help
nvfortran (aka pgfortran) can compile this, it just takes awhile. The problem being this line:
real, dimension(15000,20000) :: Mat = 0.
Static initialization of a fixed size array means that the compiler needs to set-up the BSS section to contain the initialization on load of the program which can take time as this is done per element. Better to change this to runtime initialization:
% cat addition.f90
program addition
integer :: i, j
real, dimension(15000,20000) :: Mat
Mat=0.
i = 0
j = 0
!$acc parallel loop
do i = 1,15000
do j = 1,20000
Mat(i,j) = i+j
enddo
enddo
!$acc end parallel loop
print *,Mat(10000,20000)
end program addition
% time nvfortran addition.f90 -acc
0.880u 0.147s 0:01.14 89.4% 0+0k 0+632io 0pf+0w
% a.out
30000.00
Thanks a lot for the explanation