added test_psb_caf e test_psb_ihalo
parent
5fd043e015
commit
5dab2a7bcc
@ -0,0 +1,270 @@
|
||||
module test_psb_caf
|
||||
use pfunit_mod
|
||||
use psb_base_mod
|
||||
use psb_caf_mod
|
||||
implicit none
|
||||
include 'mpif.h'
|
||||
|
||||
|
||||
contains
|
||||
|
||||
|
||||
@test(nimgs=[std])
|
||||
subroutine test_caf_allgather(this)
|
||||
implicit none
|
||||
Class(CafTestMethod), intent(inout) :: this
|
||||
integer:: ierr, status(MPI_STATUS_SIZE)
|
||||
integer, parameter :: size_=10
|
||||
integer :: snd(size_)
|
||||
integer, allocatable ::rcv(:,:),mpi_rcv(:,:)
|
||||
integer ::np, me, info
|
||||
|
||||
call MPI_COMM_RANK(MPI_COMM_WORLD, me, ierr)
|
||||
me = this_image()
|
||||
np=num_images()
|
||||
allocate(rcv(size_,0:np))
|
||||
allocate(mpi_rcv(size_,0:np))
|
||||
rcv=me
|
||||
mpi_rcv=me
|
||||
snd = me - 1
|
||||
if (me == 1) then
|
||||
snd(1:5)=(/1,32512,-1622251464,32512,62485/)
|
||||
endif
|
||||
if (me == 2) then
|
||||
snd(1:5)=(/0,2,62488,62489,62490/)
|
||||
endif
|
||||
if (me == 3) then
|
||||
snd(1:5)=(/2,3,0,0,0/)
|
||||
endif
|
||||
if (me == 4) then
|
||||
snd(1:5)=(/2,62497,62498,62499,62500/)
|
||||
endif
|
||||
call caf_allgather(snd, size_, rcv, info)
|
||||
call mpi_allgather(snd,size_,mpi_integer,&
|
||||
& mpi_rcv,size_,mpi_integer,MPI_COMM_WORLD,ierr)
|
||||
@assertEqual(mpi_rcv,rcv)
|
||||
deallocate(rcv, mpi_rcv)
|
||||
end subroutine test_caf_allgather
|
||||
|
||||
@test(nimgs=[std])
|
||||
subroutine test_allgatherv(this)
|
||||
implicit none
|
||||
Class(CafTestMethod), intent(inout) :: this
|
||||
INTEGER::myrank, ierr, status(MPI_STATUS_SIZE), i
|
||||
integer, allocatable ::snd(:), rcv(:),mpi_rcv(:), sdispls(:), rdispls(:), rcounts(:)
|
||||
integer :: me, np, scounts
|
||||
integer :: info
|
||||
!call MPI_INIT(ierr)
|
||||
call MPI_COMM_RANK(MPI_COMM_WORLD, myrank, ierr)
|
||||
me=this_image()
|
||||
np = num_images()
|
||||
allocate(snd(2),rcv(np*6), mpi_rcv(np*6))
|
||||
allocate(sdispls(np), rcounts(np), rdispls(np))
|
||||
snd=me
|
||||
rdispls(1)=0
|
||||
do i=1,np
|
||||
if (MOD(i,2) == 0) then
|
||||
rcounts(i)=2
|
||||
rdispls(i)=rdispls(i-1) + 2
|
||||
else
|
||||
rcounts(i)=1
|
||||
if (i>1) rdispls(i)=rdispls(i-1) + 4
|
||||
endif
|
||||
enddo
|
||||
if (MOD(me,2)==1) then
|
||||
scounts = 1
|
||||
else
|
||||
scounts = 2
|
||||
endif
|
||||
rcv=13
|
||||
mpi_rcv=13
|
||||
sync all
|
||||
call caf_allgatherv(snd, scounts, rcv, rcounts, rdispls, info)
|
||||
call mpi_allgatherv(snd, scounts, mpi_integer,&
|
||||
& mpi_rcv,rcounts,rdispls,mpi_integer,MPI_COMM_WORLD,ierr)
|
||||
|
||||
@assertEqual(mpi_rcv(1:size(rcv,1)),rcv)
|
||||
deallocate(snd,rcv, mpi_rcv)
|
||||
deallocate(sdispls, rcounts, rdispls)
|
||||
|
||||
end subroutine test_allgatherv
|
||||
|
||||
@test(nimgs=[std])
|
||||
subroutine test_allgatherv2(this)
|
||||
implicit none
|
||||
Class(CafTestMethod), intent(inout) :: this
|
||||
INTEGER::myrank, ierr, status(MPI_STATUS_SIZE), i
|
||||
integer, allocatable ::snd(:), rcv(:),mpi_rcv(:), sdispls(:), rdispls(:), rcounts(:)
|
||||
integer :: me, np, scounts
|
||||
integer :: info
|
||||
!call MPI_INIT(ierr)
|
||||
call MPI_COMM_RANK(MPI_COMM_WORLD, myrank, ierr)
|
||||
me=this_image()
|
||||
np = num_images()
|
||||
allocate(snd(2),rcv(np*3), mpi_rcv(np*3))
|
||||
allocate(sdispls(np), rcounts(np), rdispls(np))
|
||||
snd=me
|
||||
rdispls(1)=0
|
||||
do i=1,np
|
||||
if (MOD(i,2) == 0) then
|
||||
rcounts(i)=2
|
||||
rdispls(i)=rdispls(i-1) + 1
|
||||
else
|
||||
rcounts(i)=1
|
||||
if (i>1) rdispls(i)=rdispls(i-1) + 2
|
||||
endif
|
||||
enddo
|
||||
if (MOD(me,2)==1) then
|
||||
scounts = 1
|
||||
else
|
||||
scounts = 2
|
||||
endif
|
||||
rcv=13
|
||||
mpi_rcv=13
|
||||
sync all
|
||||
call caf_allgatherv(snd, scounts, rcv, rcounts, rdispls, info)
|
||||
call mpi_allgatherv(snd, scounts, mpi_integer,&
|
||||
& mpi_rcv,rcounts,rdispls,mpi_integer,MPI_COMM_WORLD,ierr)
|
||||
@assertEqual(mpi_rcv(1:size(rcv,1)),rcv)
|
||||
deallocate(snd,rcv, mpi_rcv)
|
||||
deallocate(sdispls, rcounts, rdispls)
|
||||
end subroutine test_allgatherv2
|
||||
|
||||
@test(nimgs=[std])
|
||||
subroutine test_alltoall(this)
|
||||
implicit none
|
||||
Class(CafTestMethod), intent(inout) :: this
|
||||
INTEGER::myrank, ierr, status(MPI_STATUS_SIZE)
|
||||
integer :: size_
|
||||
integer, allocatable :: snd(:)
|
||||
integer, allocatable ::rcv(:),mpi_rcv(:)
|
||||
integer :: me, np
|
||||
integer :: scount, info
|
||||
!call MPI_INIT(ierr)
|
||||
call MPI_COMM_RANK(MPI_COMM_WORLD, myrank, ierr)
|
||||
me=this_image()
|
||||
np = num_images()
|
||||
if (allocated(snd)) deallocate(snd)
|
||||
if (allocated(snd)) deallocate(rcv)
|
||||
if (allocated(snd)) deallocate(mpi_rcv)
|
||||
if (np >= 2) then
|
||||
allocate(snd(np*2),rcv(np*2),mpi_rcv(np*2), STAT=ierr)
|
||||
else
|
||||
allocate(snd(4),rcv(4),mpi_rcv(4), STAT=ierr)
|
||||
endif
|
||||
snd=me
|
||||
if (me==1) then
|
||||
snd(1:4)=(/0,10,0,0/)
|
||||
endif
|
||||
if (me==2) then
|
||||
snd(1:4)=(/10,0,10,0/)
|
||||
endif
|
||||
if (me==3) then
|
||||
snd(1:4)=(/0,10,0,10/)
|
||||
endif
|
||||
if (me==1) then
|
||||
snd(1:4)=(/0,0,10,0/)
|
||||
endif
|
||||
rcv=13
|
||||
mpi_rcv=13
|
||||
call caf_alltoall(snd, rcv, 1, info)
|
||||
call mpi_alltoall(snd,1,mpi_integer,&
|
||||
& mpi_rcv,1,mpi_integer,MPI_COMM_WORLD,ierr)
|
||||
@assertEqual(mpi_rcv,rcv)
|
||||
|
||||
if (allocated(snd)) deallocate(snd)
|
||||
if (allocated(snd)) deallocate(rcv)
|
||||
if (allocated(snd)) deallocate(mpi_rcv)
|
||||
end subroutine test_alltoall
|
||||
|
||||
@test(nimgs=[std])
|
||||
subroutine test_alltoallv(this)
|
||||
implicit none
|
||||
Class(CafTestMethod), intent(inout) :: this
|
||||
INTEGER::myrank, ierr, status(MPI_STATUS_SIZE), i
|
||||
integer, allocatable ::snd(:), rcv(:),mpi_rcv(:), sdispls(:), scounts(:), rdispls(:), rcounts(:)
|
||||
integer :: me, np
|
||||
integer :: info
|
||||
!call MPI_INIT(ierr)
|
||||
call MPI_COMM_RANK(MPI_COMM_WORLD, myrank, ierr)
|
||||
me=this_image()
|
||||
np = num_images()
|
||||
allocate(snd(np*2),rcv(np*2),mpi_rcv(np*2))
|
||||
allocate(scounts(np), sdispls(np), rcounts(np), rdispls(np))
|
||||
snd=me
|
||||
if (MOD(me,2)==0) then
|
||||
do i=1,np
|
||||
rcounts(i)=1
|
||||
rdispls(i)=i-1
|
||||
enddo
|
||||
else
|
||||
do i=1,np
|
||||
rcounts(i)=2
|
||||
rdispls(i)=(i-1)*2
|
||||
enddo
|
||||
endif
|
||||
sdispls(1)=0
|
||||
do i=1,np
|
||||
if (MOD(i,2)==0) then
|
||||
scounts(i) = 1
|
||||
sdispls(i)=sdispls(i-1) + 2
|
||||
else
|
||||
scounts(i)=2
|
||||
if (i>1) sdispls(i)=sdispls(i-1) + 1
|
||||
endif
|
||||
enddo
|
||||
rcv=13
|
||||
mpi_rcv=13
|
||||
call caf_alltoallv(snd, scounts, sdispls, rcv, rcounts, rdispls, info)
|
||||
call mpi_alltoallv(snd,scounts,sdispls, mpi_integer,&
|
||||
& mpi_rcv,rcounts,rdispls,mpi_integer,MPI_COMM_WORLD,ierr)
|
||||
@assertEqual(mpi_rcv,rcv)
|
||||
|
||||
end subroutine test_alltoallv
|
||||
|
||||
@test(nimgs=[std])
|
||||
subroutine test_dalltoallv(this)
|
||||
implicit none
|
||||
Class(CafTestMethod), intent(inout) :: this
|
||||
INTEGER::myrank, ierr, status(MPI_STATUS_SIZE), i
|
||||
double precision, allocatable :: snd(:), rcv(:), mpi_rcv(:)
|
||||
integer, allocatable :: sdispls(:), scounts(:), rdispls(:), rcounts(:)
|
||||
integer :: me, np
|
||||
integer :: info
|
||||
!call MPI_INIT(ierr)
|
||||
call MPI_COMM_RANK(MPI_COMM_WORLD, myrank, ierr)
|
||||
me=this_image()
|
||||
np = num_images()
|
||||
allocate(snd(np*2),rcv(np*2),mpi_rcv(np*2))
|
||||
allocate(scounts(np), sdispls(np), rcounts(np), rdispls(np))
|
||||
snd=dble(me)
|
||||
if (MOD(me,2)==0) then
|
||||
do i=1,np
|
||||
rcounts(i)=1
|
||||
rdispls(i)=i-1
|
||||
enddo
|
||||
else
|
||||
do i=1,np
|
||||
rcounts(i)=2
|
||||
rdispls(i)=(i-1)*2
|
||||
enddo
|
||||
endif
|
||||
sdispls(1)=0
|
||||
do i=1,np
|
||||
if (MOD(i,2)==0) then
|
||||
scounts(i) = 1
|
||||
sdispls(i)=sdispls(i-1) + 2
|
||||
else
|
||||
scounts(i)=2
|
||||
if (i>1) sdispls(i)=sdispls(i-1) + 1
|
||||
endif
|
||||
enddo
|
||||
rcv=dble(13)
|
||||
mpi_rcv=dble(13)
|
||||
call caf_dalltoallv(snd, scounts, sdispls, rcv, rcounts, rdispls, info)
|
||||
call mpi_alltoallv(snd,scounts,sdispls, mpi_double,&
|
||||
& mpi_rcv,rcounts,rdispls,mpi_double,MPI_COMM_WORLD,ierr)
|
||||
@assertEqual(mpi_rcv,rcv)
|
||||
|
||||
end subroutine test_dalltoallv
|
||||
end module test_psb_caf
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue