Skip to content

Commit 1bc31df

Browse files
committed
Wrapper Ialltoall(v)
1 parent e922738 commit 1bc31df

File tree

6 files changed

+53
-0
lines changed

6 files changed

+53
-0
lines changed

deps/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ FortranCInterface_HEADER(jlmpi_f2c.h MACRO_NAMESPACE "JLMPI_" SYMBOLS
4949
MPI_GATHERV
5050
MPI_GET_COUNT
5151
MPI_GET_PROCESSOR_NAME
52+
MPI_IALLTOALL
53+
MPI_IALLTOALLV
5254
MPI_IBARRIER
5355
MPI_IBCAST
5456
MPI_INIT

deps/gen_functions.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ int main(int argc, char *argv[]) {
3737
printf(" :MPI_GET_COUNT => \"%s\",\n", STRING(MPI_GET_COUNT));
3838
printf(" :MPI_GET_PROCESSOR_NAME => \"%s\",\n",
3939
STRING(MPI_GET_PROCESSOR_NAME));
40+
printf(" :MPI_IALLTOALL => \"%s\",\n", STRING(MPI_IALLTOALL));
41+
printf(" :MPI_IALLTOALLV => \"%s\",\n", STRING(MPI_IALLTOALLV));
4042
printf(" :MPI_IBARRIER => \"%s\",\n", STRING(MPI_IBARRIER));
4143
printf(" :MPI_IBCAST => \"%s\",\n", STRING(MPI_IBCAST));
4244
printf(" :MPI_INIT => \"%s\",\n", STRING(MPI_INIT));

src/mpi-base.jl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,16 @@ function Alltoall{T}(sendbuf::MPIBuffertype{T}, count::Integer,
640640
recvbuf
641641
end
642642

643+
function Ialltoall{T}(sendbuf::MPIBuffertype{T}, count::Integer,
644+
comm::Comm)
645+
rval = Ref{Cint}()
646+
recvbuf = Array(T, Comm_size(comm)*count)
647+
ccall(MPI_IALLTOALL, Void,
648+
(Ptr{T}, Ptr{Cint}, Ptr{Cint}, Ptr{T}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}),
649+
sendbuf, &count, &mpitype(T), recvbuf, &count, &mpitype(T), &comm.val, rval, &0)
650+
Request(rval[], sendbuf), recvbuf
651+
end
652+
643653
function Alltoallv{T}(sendbuf::MPIBuffertype{T}, scounts::Vector{Cint},
644654
rcounts::Vector{Cint}, comm::Comm)
645655
recvbuf = Array(T, sum(rcounts))
@@ -651,6 +661,18 @@ function Alltoallv{T}(sendbuf::MPIBuffertype{T}, scounts::Vector{Cint},
651661
recvbuf
652662
end
653663

664+
function Ialltoallv{T}(sendbuf::MPIBuffertype{T}, scounts::Vector{Cint},
665+
rcounts::Vector{Cint}, comm::Comm)
666+
rval = Ref{Cint}()
667+
recvbuf = Array(T, sum(rcounts))
668+
sdispls = cumsum(scounts) - scounts
669+
rdispls = cumsum(rcounts) - rcounts
670+
ccall(MPI_IALLTOALLV, Void,
671+
(Ptr{T}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{T}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}),
672+
sendbuf, scounts, sdispls, &mpitype(T), recvbuf, rcounts, rdispls, &mpitype(T), &comm.val, rval, &0)
673+
Request(rval[], sendbuf), recvbuf
674+
end
675+
654676
function Scan{T}(sendbuf::MPIBuffertype{T}, count::Integer,
655677
op::Op, comm::Comm)
656678
recvbuf = Array(T, count)

src/win_mpiconstants.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ const MPI_ALLGATHER = (:MPI_ALLGATHER, "msmpi.dll")
6464
const MPI_ALLGATHERV = (:MPI_ALLGATHERV, "msmpi.dll")
6565
const MPI_ALLTOALL = (:MPI_ALLTOALL, "msmpi.dll")
6666
const MPI_ALLTOALLV = (:MPI_ALLTOALLV, "msmpi.dll")
67+
const MPI_IALLTOALL = (:MPI_IALLTOALL, "msmpi.dll")
68+
const MPI_IALLTOALLV = (:MPI_IALLTOALLV, "msmpi.dll")
6769
const MPI_INITIALIZED = (:MPI_INITIALIZED, "msmpi.dll")
6870
const MPI_FINALIZED = (:MPI_FINALIZED, "msmpi.dll")
6971
const MPI_SCATTER = (:MPI_SCATTER, "msmpi.dll")

test/test_alltoall.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,10 @@ rank = MPI.Comm_rank(comm)
99

1010
a = fill(rank,size)
1111
@test MPI.Alltoall(a, 1, comm) == collect(0:(size-1))
12+
13+
b = fill(rank,size)
14+
req,c = MPI.Ialltoall(b, 1, comm)
15+
MPI.Wait!(req)
16+
MPI.Barrier(MPI.COMM_WORLD)
17+
@test c == collect(0:(size-1))
1218
MPI.Finalize()

test/test_alltoallv.jl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ function alltoallv_array(A, scounts::Vector{Cint}, rcounts::Vector{Cint})
88
MPI.Alltoallv(A,scounts,rcounts,comm)
99
end
1010

11+
function ialltoallv_array(A, scounts::Vector{Cint}, rcounts::Vector{Cint})
12+
comm = MPI.COMM_WORLD
13+
req, B = MPI.Ialltoallv(A,scounts,rcounts,comm)
14+
MPI.Wait!(req)
15+
MPI.Barrier(comm)
16+
B
17+
end
18+
1119
comm = MPI.COMM_WORLD
1220
size = MPI.Comm_size(comm)
1321
rank = MPI.Comm_rank(comm)
@@ -23,6 +31,17 @@ for typ in MPI.MPIDatatype.types
2331
rcounts = fill(convert(Cint,rank + 1),size)
2432
C = alltoallv_array(A, scounts, rcounts)
2533
@test B == C
34+
35+
A = typ[]
36+
B = typ[]
37+
for i in 1:size
38+
A = vcat(A,convert(Vector{typ},collect(1:i)))
39+
B = vcat(B,convert(Vector{typ},collect(1:(rank+1))))
40+
end
41+
scounts = convert(Vector{Cint}, collect(1:size))
42+
rcounts = fill(convert(Cint,rank + 1),size)
43+
D = ialltoallv_array(A, scounts, rcounts)
44+
@test B == D
2645
end
2746

2847
MPI.Finalize()

0 commit comments

Comments
 (0)