i want make a test that data from different gpu on different process with cuda fotran ,but it always print Signal: Segmentation fault (11)
the code if follow and i run tow process and tow gpu:
program main
use mpi
use cudafor
implicit none
real,device,allocatable::d_0(:),d_1(:)
real,allocatable::h_0(:),h_1(:)
integer :: STATUS(MPI_STATUS_SIZE),numprocs
call mpi_init(ierr)
call mpi_comm_size(mpi_comm_world, numprocs,ierr)
call mpi_comm_rank(mpi_comm_world,myrank,ierr)
do i =0,numprocs-1
istat=cudaSetDevice(i)
istat = cudaGetDevice(i)
end do
allocate(d_0(1:100))
allocate(d_1(1:100))
allocate(h_0(1:100))
allocate(h_1(1:100))
if(myrank .eq. 0) then
d_0 = 0.0
call MPI_SENDRECV(d_0,100,mpi_real,1,sendtag,d_1,100,mpi_real,0,recvtag,mpi_comm_world,status,ierror)
h_0=d_0
write(0,) ‘0 myrank h_0 is’ ,h_0
end if
if(myrank .eq. 1) then
d_1 =1.0
call MPI_SENDRECV(d_0,100,mpi_real,0,sendtag,d_1,100,mpi_real,1,recvtag,mpi_comm_world,status,ierror)
h_1=d_1
write(0,) ‘1 myrank h_1 is’ ,h_1
end if
!call cpy1()
deallocate(d)
call mpi_finalize(rc)
end program main