Dear NVIDIA developer,
I want to use the pinned memory in module. An example is as follows:
program test
use cudafor
use pintest
implicit none
integer::nx,ny,nz
nx=8; ny=8; nz=3
allocate(a(nx,ny,nz))
a=3
call addpin()
write(*,"(8(8i3,/))") a(:,:,1)
end program test
module pintest
integer,allocatable,pinned::a(:,:,:)
contains
subroutine addpin()
implicit none
integer::b
b=1
a=a+b
end subroutine addpin
end module pintest
Then I build it use:
nvfortran pintest.cuf test.cuf
then ./a.out
There is Segmentation fault (core dumped)
However, if I move the pinned in the module, it works well.
So could anyone let me know, how could I use pinned memory in module or in a subroutine?
Thanks a lot!
Hi chen_yang,
Unfortunately I’m not sure what’s wrong since your program works fine for me with 20.11 on a x86_64 and ARM system. Is there any other information you can provide such as the compiler version, OS, CUDA driver version, and system that you’re running on?
Thanks,
Mat
% cat pintest.cuf
module pintest
integer,allocatable,pinned::a(:,:,:)
contains
subroutine addpin()
implicit none
integer::b
b=1
a=a+b
end subroutine addpin
end module pintest
% cat test.cuf
program test
use cudafor
use pintest
implicit none
integer::nx,ny,nz
nx=8; ny=8; nz=3
allocate(a(nx,ny,nz))
a=3
call addpin()
write(*,"(8(8i3,/))") a(:,:,1)
end program test
% nvfortran pintest.cuf test.cuf -V20.11 ; a.out
pintest.cuf:
test.cuf:
4 4 4 4 4 4 4 4
4 4 4 4 4 4 4 4
4 4 4 4 4 4 4 4
4 4 4 4 4 4 4 4
4 4 4 4 4 4 4 4
4 4 4 4 4 4 4 4
4 4 4 4 4 4 4 4
4 4 4 4 4 4 4 4
Thanks much, Mat!
Yes, it’s my fault. My computer lose the connection with GPU. Now the code can run successfully!
Thanks again!
Chen