Skip to content

Commit e922738

Browse files
committed
Wrapped Ibcast
1 parent 75fee7d commit e922738

File tree

5 files changed

+36
-0
lines changed

5 files changed

+36
-0
lines changed

deps/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ FortranCInterface_HEADER(jlmpi_f2c.h MACRO_NAMESPACE "JLMPI_" SYMBOLS
5050
MPI_GET_COUNT
5151
MPI_GET_PROCESSOR_NAME
5252
MPI_IBARRIER
53+
MPI_IBCAST
5354
MPI_INIT
5455
MPI_INITIALIZED
5556
MPI_IPROBE

deps/gen_functions.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ int main(int argc, char *argv[]) {
3838
printf(" :MPI_GET_PROCESSOR_NAME => \"%s\",\n",
3939
STRING(MPI_GET_PROCESSOR_NAME));
4040
printf(" :MPI_IBARRIER => \"%s\",\n", STRING(MPI_IBARRIER));
41+
printf(" :MPI_IBCAST => \"%s\",\n", STRING(MPI_IBCAST));
4142
printf(" :MPI_INIT => \"%s\",\n", STRING(MPI_INIT));
4243
printf(" :MPI_INITIALIZED => \"%s\",\n", STRING(MPI_INITIALIZED));
4344
printf(" :MPI_IPROBE => \"%s\",\n", STRING(MPI_IPROBE));

src/mpi-base.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,19 @@ function Bcast!{T}(buffer::Array{T}, root::Integer, comm::Comm)
485485
Bcast!(buffer, length(buffer), root, comm)
486486
end
487487

488+
function Ibcast!{T}(buffer::MPIBuffertype{T}, count::Integer,
489+
root::Integer, comm::Comm)
490+
rval = Ref{Cint}()
491+
ccall(MPI_IBCAST, Void,
492+
(Ptr{T}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}),
493+
buffer, &count, &mpitype(T), &root, &comm.val, rval, &0)
494+
Request(rval[], buffer), buffer
495+
end
496+
497+
function Ibcast!{T}(buffer::Array{T}, root::Integer, comm::Comm)
498+
Ibcast!(buffer, length(buffer), root, comm)
499+
end
500+
488501
#=
489502
function Bcast{T}(obj::T, root::Integer, comm::Comm)
490503
buf = [T]

src/win_mpiconstants.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ const MPI_BARRIER = (:MPI_BARRIER, "msmpi.dll")
5454
const MPI_IBARRIER = (:MPI_IBARRIER, "msmpi.dll")
5555
const MPI_FINALIZE = (:MPI_FINALIZE, "msmpi.dll")
5656
const MPI_BCAST = (:MPI_BCAST, "msmpi.dll")
57+
const MPI_IBCAST = (:MPI_IBCAST, "msmpi.dll")
5758
const MPI_REDUCE = (:MPI_REDUCE, "msmpi.dll")
5859
const MPI_IRECV = (:MPI_IRECV, "msmpi.dll")
5960
const MPI_RECV = (:MPI_RECV, "msmpi.dll")

test/test_bcast.jl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,19 @@ function bcast_array(A, root)
1616
B
1717
end
1818

19+
function ibcast_array(A, root)
20+
comm = MPI.COMM_WORLD
21+
22+
if MPI.Comm_rank(comm) == root
23+
B = copy(A)
24+
else
25+
B = similar(A)
26+
end
27+
28+
req, B = MPI.Ibcast!(B, root, comm)
29+
req, B
30+
end
31+
1932
root = 0
2033

2134
srand(17)
@@ -53,4 +66,11 @@ end
5366
B = MPI.bcast(B, root, comm)
5467
@test B["foo"] == "bar"
5568

69+
#ibcast
70+
A = ['s', 't', 'a', 'r', ' ', 'w', 'a', 'r', 's']
71+
req, B = ibcast_array(A, root)
72+
MPI.Wait!(req)
73+
MPI.Barrier(MPI.COMM_WORLD)
74+
@test B == A
75+
5676
MPI.Finalize()

0 commit comments

Comments
 (0)