Skip to content

Commit 95cc4ca

Browse files
committed
Wrapped ireduce, iscan, iexscan
1 parent 5e01ef5 commit 95cc4ca

File tree

7 files changed

+78
-0
lines changed

7 files changed

+78
-0
lines changed

deps/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,15 @@ FortranCInterface_HEADER(jlmpi_f2c.h MACRO_NAMESPACE "JLMPI_" SYMBOLS
5555
MPI_IALLTOALLV
5656
MPI_IBARRIER
5757
MPI_IBCAST
58+
MPI_IEXSCAN
5859
MPI_IGATHER
5960
MPI_IGATHERV
6061
MPI_INIT
6162
MPI_INITIALIZED
6263
MPI_IPROBE
6364
MPI_IRECV
65+
MPI_IREDUCE
66+
MPI_ISCAN
6467
MPI_ISCATTER
6568
MPI_ISCATTERV
6669
MPI_ISEND

deps/gen_functions.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,15 @@ int main(int argc, char *argv[]) {
4343
printf(" :MPI_IALLTOALLV => \"%s\",\n", STRING(MPI_IALLTOALLV));
4444
printf(" :MPI_IBARRIER => \"%s\",\n", STRING(MPI_IBARRIER));
4545
printf(" :MPI_IBCAST => \"%s\",\n", STRING(MPI_IBCAST));
46+
printf(" :MPI_IEXSCAN => \"%s\",\n", STRING(MPI_IEXSCAN));
4647
printf(" :MPI_IGATHER => \"%s\",\n", STRING(MPI_IGATHER));
4748
printf(" :MPI_IGATHERV => \"%s\",\n", STRING(MPI_IGATHERV));
4849
printf(" :MPI_INIT => \"%s\",\n", STRING(MPI_INIT));
4950
printf(" :MPI_INITIALIZED => \"%s\",\n", STRING(MPI_INITIALIZED));
5051
printf(" :MPI_IPROBE => \"%s\",\n", STRING(MPI_IPROBE));
5152
printf(" :MPI_IRECV => \"%s\",\n", STRING(MPI_IRECV));
53+
printf(" :MPI_IREDUCE => \"%s\",\n", STRING(MPI_IREDUCE));
54+
printf(" :MPI_ISCAN => \"%s\",\n", STRING(MPI_ISCAN));
5255
printf(" :MPI_ISCATTER => \"%s\",\n", STRING(MPI_ISCATTER));
5356
printf(" :MPI_ISCATTERV => \"%s\",\n", STRING(MPI_ISCATTERV));
5457
printf(" :MPI_ISEND => \"%s\",\n", STRING(MPI_ISEND));

src/mpi-base.jl

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,30 @@ function Reduce{T}(object::T, op::Op, root::Integer, comm::Comm)
547547
isroot ? recvbuf[1] : nothing
548548
end
549549

550+
function Ireduce{T}(sendbuf::MPIBuffertype{T}, count::Integer,
551+
op::Op, root::Integer, comm::Comm)
552+
rval = Ref{Cint}()
553+
isroot = Comm_rank(comm) == root
554+
recvbuf = Array(T, isroot ? count : 0)
555+
ccall(MPI_IREDUCE, Void,
556+
(Ptr{T}, Ptr{T}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint},
557+
Ptr{Cint}, Ptr{Cint}, Ptr{Cint}),
558+
sendbuf, recvbuf, &count, &mpitype(T), &op.val, &root, &comm.val,
559+
rval, &0)
560+
Request(rval[], sendbuf), isroot ? recvbuf : nothing
561+
end
562+
563+
function Ireduce{T}(sendbuf::Array{T}, op::Op, root::Integer, comm::Comm)
564+
Ireduce(sendbuf, length(sendbuf), op, root, comm)
565+
end
566+
567+
function Ireduce{T}(object::T, op::Op, root::Integer, comm::Comm)
568+
isroot = Comm_rank(comm) == root
569+
sendbuf = T[object]
570+
req, recvbuf = Ireduce(sendbuf, op, root, comm)
571+
req, isroot ? recvbuf[1] : nothing
572+
end
573+
550574
function Scatter{T}(sendbuf::MPIBuffertype{T},
551575
count::Integer, root::Integer, comm::Comm)
552576
recvbuf = Array(T, count)
@@ -775,6 +799,21 @@ function Scan{T}(object::T, op::Op, comm::Comm)
775799
Scan(sendbuf,1,op,comm)
776800
end
777801

802+
function Iscan{T}(sendbuf::MPIBuffertype{T}, count::Integer,
803+
op::Op, comm::Comm)
804+
recvbuf = Array(T, count)
805+
rval = Ref{Cint}()
806+
ccall(MPI_ISCAN, Void,
807+
(Ptr{T}, Ptr{T}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}),
808+
sendbuf, recvbuf, &count, &mpitype(T), &op.val, &comm.val, rval, &0)
809+
Request(rval[], sendbuf), recvbuf
810+
end
811+
812+
function Iscan{T}(object::T, op::Op, comm::Comm)
813+
sendbuf = T[object]
814+
Iscan(sendbuf,1,op,comm)
815+
end
816+
778817
function ExScan{T}(sendbuf::MPIBuffertype{T}, count::Integer,
779818
op::Op, comm::Comm)
780819
recvbuf = Array(T, count)
@@ -789,6 +828,21 @@ function ExScan{T}(object::T, op::Op, comm::Comm)
789828
ExScan(sendbuf,1,op,comm)
790829
end
791830

831+
function IExScan{T}(sendbuf::MPIBuffertype{T}, count::Integer,
832+
op::Op, comm::Comm)
833+
recvbuf = Array(T, count)
834+
rval = Ref{Cint}()
835+
ccall(MPI_IEXSCAN, Void,
836+
(Ptr{T}, Ptr{T}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}),
837+
sendbuf, recvbuf, &count, &mpitype(T), &op.val, &comm.val, rval, &0)
838+
Request(rval[], sendbuf), recvbuf
839+
end
840+
841+
function IExScan{T}(object::T, op::Op, comm::Comm)
842+
sendbuf = T[object]
843+
IExScan(sendbuf,1,op,comm)
844+
end
845+
792846
# Conversion between C and Fortran Comm handles:
793847
if HAVE_MPI_COMM_C2F
794848
# use MPI_Comm_f2c and MPI_Comm_c2f

src/win_mpiconstants.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ const MPI_FINALIZE = (:MPI_FINALIZE, "msmpi.dll")
5656
const MPI_BCAST = (:MPI_BCAST, "msmpi.dll")
5757
const MPI_IBCAST = (:MPI_IBCAST, "msmpi.dll")
5858
const MPI_REDUCE = (:MPI_REDUCE, "msmpi.dll")
59+
const MPI_IREDUCE = (:MPI_IREDUCE, "msmpi.dll")
5960
const MPI_IRECV = (:MPI_IRECV, "msmpi.dll")
6061
const MPI_RECV = (:MPI_RECV, "msmpi.dll")
6162
const MPI_ISEND = (:MPI_ISEND, "msmpi.dll")
@@ -74,7 +75,9 @@ const MPI_SCATTER = (:MPI_SCATTER, "msmpi.dll")
7475
const MPI_SCATTERV = (:MPI_SCATTERV, "msmpi.dll")
7576
const MPI_SEND = (:MPI_SEND, "msmpi.dll")
7677
const MPI_SCAN = (:MPI_SCAN, "msmpi.dll")
78+
const MPI_ISCAN = (:MPI_ISCAN, "msmpi.dll")
7779
const MPI_EXSCAN = (:MPI_EXSCAN, "msmpi.dll")
80+
const MPI_IEXSCAN = (:MPI_IEXSCAN, "msmpi.dll")
7881
const MPI_GATHER = (:MPI_GATHER, "msmpi.dll")
7982
const MPI_GATHERV = (:MPI_GATHERV, "msmpi.dll")
8083
const MPI_IGATHER = (:MPI_GATHER, "msmpi.dll")

test/test_exscan.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ for typ in typs
1616
if rank > 0
1717
@test_approx_eq B[1] factorial(rank)
1818
end
19+
req, C = MPI.IExScan(val, MPI.PROD, comm)
20+
MPI.Wait!(req)
21+
if rank > 0
22+
@test_approx_eq C[1] factorial(rank)
23+
end
1924
end
2025

2126
MPI.Finalize()

test/test_reduce.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,10 @@ sum_mesg = MPI.Reduce(mesg, MPI.SUM, root, comm)
2323
sum_mesg = rank == root ? sum_mesg : size*mesg
2424
@test isapprox(norm(sum_mesg-size*mesg), 0.0)
2525

26+
mesg = collect(1.0:5.0)
27+
req, sum_mesg = MPI.Ireduce(mesg, MPI.SUM, root, comm)
28+
MPI.Wait!(req)
29+
sum_mesg = rank == root ? sum_mesg : size*mesg
30+
@test isapprox(norm(sum_mesg-size*mesg), 0.0)
31+
2632
MPI.Finalize()

test/test_scan.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ for typ in typs
1414
val = convert(typ,rank + 1)
1515
B = MPI.Scan(val, MPI.PROD, comm)
1616
@test_approx_eq B[1] factorial(val)
17+
val = convert(typ,rank + 1)
18+
req, B = MPI.Iscan(val, MPI.PROD, comm)
19+
MPI.Wait!(req)
20+
@test_approx_eq B[1] factorial(val)
1721
end
1822

1923
MPI.Finalize()

0 commit comments

Comments
 (0)