Skip to content

Commit 6c47fba

Browse files
authored
Merge pull request #206 from barche/accumulate
Add onesided accumulate functions
2 parents 8ac9a3d + 03f0703 commit 6c47fba

File tree

6 files changed

+64
-0
lines changed

6 files changed

+64
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,8 @@ Julia Function (assuming `import MPI`) | Fortran Function
266266
`MPI.Get` | [`MPI_Get`](https://www.open-mpi.org/doc/v3.0/man3/MPI_Get.3.php)
267267
`MPI.Put` | [`MPI_Put`](https://www.open-mpi.org/doc/v3.0/man3/MPI_Put.3.php)
268268
`MPI.Fetch_and_op` | [`MPI_Fetch_and_op`](https://www.open-mpi.org/doc/v3.0/man3/MPI_Fetch_and_op.3.php)
269+
`MPI.Accumulate` | [`MPI_Accumulate`](https://www.open-mpi.org/doc/v3.0/man3/MPI_Accumulate.3.php)
270+
`MPI.Get_accumulate` | [`MPI_Get_accumulate`](https://www.open-mpi.org/doc/v3.0/man3/MPI_Get_accumulate.3.php)
269271

270272
[Julia]: http://julialang.org/
271273
[MPI]: http://www.mpi-forum.org/

deps/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ include(FortranCInterface)
2727
# Keep these function names sorted alphabetically
2828
FortranCInterface_HEADER(jlmpi_f2c.h MACRO_NAMESPACE "JLMPI_" SYMBOLS
2929
MPI_ABORT
30+
MPI_ACCUMULATE
3031
MPI_ALLGATHER
3132
MPI_ALLGATHERV
3233
MPI_ALLREDUCE
@@ -51,6 +52,7 @@ FortranCInterface_HEADER(jlmpi_f2c.h MACRO_NAMESPACE "JLMPI_" SYMBOLS
5152
MPI_GATHER
5253
MPI_GATHERV
5354
MPI_GET
55+
MPI_GET_ACCUMULATE
5456
MPI_GET_ADDRESS
5557
MPI_GET_COUNT
5658
MPI_GET_PROCESSOR_NAME

deps/gen_functions.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ int main(int argc, char *argv[]) {
1818
printf("\n");
1919
printf("const _mpi_functions = Dict{Symbol, String}(\n");
2020
printf(" :MPI_ABORT => \"%s\",\n", STRING(MPI_ABORT));
21+
printf(" :MPI_ACCUMULATE => \"%s\",\n", STRING(MPI_ACCUMULATE));
2122
printf(" :MPI_ALLGATHER => \"%s\",\n", STRING(MPI_ALLGATHER));
2223
printf(" :MPI_ALLGATHERV => \"%s\",\n", STRING(MPI_ALLGATHERV));
2324
printf(" :MPI_ALLREDUCE => \"%s\",\n", STRING(MPI_ALLREDUCE));
@@ -41,6 +42,7 @@ int main(int argc, char *argv[]) {
4142
printf(" :MPI_GATHER => \"%s\",\n", STRING(MPI_GATHER));
4243
printf(" :MPI_GATHERV => \"%s\",\n", STRING(MPI_GATHERV));
4344
printf(" :MPI_GET => \"%s\",\n", STRING(MPI_GET));
45+
printf(" :MPI_GET_ACCUMULATE => \"%s\",\n", STRING(MPI_GET_ACCUMULATE));
4446
printf(" :MPI_GET_ADDRESS => \"%s\",\n", STRING(MPI_GET_ADDRESS));
4547
printf(" :MPI_GET_COUNT => \"%s\",\n", STRING(MPI_GET_COUNT));
4648
printf(" :MPI_GET_PROCESSOR_NAME => \"%s\",\n",

src/mpi-base.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,18 @@ function Fetch_and_op(sourceval::MPIBuffertype{T}, returnval::MPIBuffertype{T},
929929
sourceval, returnval, mpitype(T), target_rank, target_disp, op.val, win)
930930
end
931931

932+
function Accumulate(origin_buffer::MPIBuffertype{T}, count::Integer, target_rank::Integer, target_disp::Integer, op::Op, win::Win) where T
933+
ccall(MPI_ACCUMULATE, Void,
934+
(Ptr{T}, Ref{Cint}, Ref{Cint}, Ref{Cint}, Ref{Cptrdiff_t}, Ref{Cint}, Ref{Cint}, Ref{Cint}, Ref{Cint}, Ref{Cint}),
935+
origin_buffer, count, mpitype(T), target_rank, Cptrdiff_t(target_disp), count, mpitype(T), op.val, win.val, 0)
936+
end
937+
938+
function Get_accumulate(origin_buffer::MPIBuffertype{T}, result_buffer::MPIBuffertype{T}, count::Integer, target_rank::Integer, target_disp::Integer, op::Op, win::Win) where T
939+
ccall(MPI_GET_ACCUMULATE, Void,
940+
(Ptr{T}, Ref{Cint}, Ref{Cint}, Ptr{T}, Ref{Cint}, Ref{Cint}, Ref{Cint}, Ref{Cptrdiff_t}, Ref{Cint}, Ref{Cint}, Ref{Cint}, Ref{Cint}, Ref{Cint}),
941+
origin_buffer, count, mpitype(T), result_buffer, count, mpitype(T), target_rank, Cptrdiff_t(target_disp), count, mpitype(T), op.val, win.val, 0)
942+
end
943+
932944
function Get_address(location::MPIBuffertype{T}) where T
933945
addr = Ref{Cptrdiff_t}(0)
934946
ccall(MPI_GET_ADDRESS, Void, (Ptr{T}, Ref{Cptrdiff_t}, Ref{Cint}), location, addr, 0)

src/win_mpiconstants.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ const HAVE_MPI_COMM_C2F = false
5555
const libmpi = "msmpi.dll"
5656

5757
const MPI_ABORT = (:MPI_ABORT, libmpi)
58+
const MPI_ACCUMULATE = (:MPI_ACCUMULATE, libmpi)
5859
const MPI_ALLREDUCE = (:MPI_ALLREDUCE, libmpi)
5960
const MPI_INIT = (:MPI_INIT, libmpi)
6061
const MPI_CANCEL = (:MPI_CANCEL, libmpi)
@@ -93,6 +94,7 @@ const MPI_SEND = (:MPI_SEND, libmpi)
9394
const MPI_SCAN = (:MPI_SCAN, libmpi)
9495
const MPI_EXSCAN = (:MPI_EXSCAN, libmpi)
9596
const MPI_GET = (:MPI_GET, libmpi)
97+
const MPI_GET_ACCUMULATE = (:MPI_GET_ACCUMULATE, libmpi)
9698
const MPI_GET_ADDRESS = (:MPI_GET_ADDRESS, libmpi)
9799
const MPI_GET_COUNT = (:MPI_GET_COUNT, libmpi)
98100
const MPI_GATHER = (:MPI_GATHER, libmpi)

test/test_onesided.jl

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,50 @@ if rank == 0
3636
@test buf == collect(0:N-1)
3737
end
3838

39+
MPI.Barrier(comm)
40+
41+
if rank == 1
42+
MPI.Win_lock(MPI.LOCK_EXCLUSIVE, 1, 0, win)
43+
fill!(buf,3)
44+
MPI.Win_unlock(1,win)
45+
end
46+
47+
MPI.Barrier(comm)
48+
49+
if rank == 0
50+
MPI.Win_lock(MPI.LOCK_EXCLUSIVE, 0, 0, win)
51+
fill!(buf, 2)
52+
MPI.Win_unlock(0,win)
53+
MPI.Win_lock(MPI.LOCK_EXCLUSIVE, 1, 0, win)
54+
result = similar(buf)
55+
MPI.Get_accumulate(buf, result, length(buf), 1, 0, MPI.SUM, win)
56+
MPI.Win_unlock(1,win)
57+
@test all(result .== 3)
58+
end
59+
60+
MPI.Barrier(comm)
61+
62+
if rank == 1
63+
MPI.Win_lock(MPI.LOCK_EXCLUSIVE, 1, 0, win)
64+
@test all(buf .== 5)
65+
fill!(buf,-2)
66+
MPI.Win_unlock(1,win)
67+
MPI.Win_lock(MPI.LOCK_EXCLUSIVE, 0, 0, win)
68+
MPI.Accumulate(buf, length(buf), 0, 0, MPI.SUM, win)
69+
MPI.Win_unlock(0,win)
70+
MPI.Win_lock(MPI.LOCK_EXCLUSIVE, 1, 0, win)
71+
fill!(buf,1)
72+
MPI.Win_unlock(1,win)
73+
end
74+
75+
MPI.Barrier(comm)
76+
77+
if rank == 0
78+
MPI.Win_lock(MPI.LOCK_EXCLUSIVE, 0, 0, win)
79+
@test all(buf .== 0)
80+
MPI.Win_unlock(0,win)
81+
end
82+
3983
MPI.Barrier(comm)
4084
MPI.Win_free(win)
4185
MPI.Barrier(comm)

0 commit comments

Comments
 (0)