Skip to content

Commit 8c8b228

Browse files
committed
Add some MPI-2 and MPI-3 one sided calls (and spawn)
1 parent 3821ddd commit 8c8b228

File tree

11 files changed

+347
-6
lines changed

11 files changed

+347
-6
lines changed

README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,12 +196,16 @@ Julia Function (assuming `import MPI`) | Fortran Function
196196
`MPI.Abort` | [`MPI_Abort`](https://www.open-mpi.org/doc/v1.10/man3/MPI_Abort.3.php)
197197
`MPI.Comm_dup` | [`MPI_Comm_dup`](https://www.open-mpi.org/doc/v1.10/man3/MPI_Comm_dup.3.php)
198198
`MPI.Comm_free` | [`MPI_Comm_free`](https://www.open-mpi.org/doc/v1.10/man3/MPI_Comm_free.3.php)
199+
`MPI.Comm_get_parent` | [`MPI_Comm_get_parent`](https://www.open-mpi.org/doc/v3.0/man3/MPI_Comm_get_parent.3.php)
199200
`MPI.Comm_rank` | [`MPI_Comm_rank`](https://www.open-mpi.org/doc/v1.10/man3/MPI_Comm_rank.3.php)
200201
`MPI.Comm_size` | [`MPI_Comm_size`](https://www.open-mpi.org/doc/v1.10/man3/MPI_Comm_size.3.php)
202+
`MPI.Comm_spawn` | [`MPI_Comm_spawn`](https://www.open-mpi.org/doc/v3.0/man3/MPI_Comm_spawn.3.php)
201203
`MPI.Finalize` | [`MPI_Finalize`](https://www.open-mpi.org/doc/v1.10/man3/MPI_Finalize.3.php)
202204
`MPI.Finalized` | [`MPI_Finalized`](https://www.open-mpi.org/doc/v1.10/man3/MPI_Finalized.3.php)
205+
`MPI.Get_address` | [`MPI_Get_address`](https://www.open-mpi.org/doc/v3.0/man3/MPI_Get_address.3.php)
203206
`MPI.Init` | [`MPI_Init`](https://www.open-mpi.org/doc/v1.10/man3/MPI_Init.3.php)
204207
`MPI.Initialized` | [`MPI_Initialized`](https://www.open-mpi.org/doc/v1.10/man3/MPI_Initialized.3.php)
208+
`MPI.Intercomm_merge` | [`MPI_Intercomm_merge`](https://www.open-mpi.org/doc/v3.0/man3/MPI_Intercomm_merge.3.php)
205209
`MPI.mpitype` | [`MPI_Type_create_struct`](https://www.open-mpi.org/doc/v1.10/man3/MPI_Type_create_struct.3.php) and [`MPI_Type_commit`](https://www.open-mpi.org/doc/v1.10/man3/MPI_Type_commit.3.php) (see: [mpitype note](#mpitypenote))
206210

207211
<a name="mpitypenote">mpitype note</a>: This is not strictly a wrapper for
@@ -246,7 +250,22 @@ Julia Function (assuming `import MPI`) | Fortran Function
246250
`MPI.Scatter` | [`MPI_Scatter`](https://www.open-mpi.org/doc/v1.10/man3/MPI_Scatter.3.php)
247251
`MPI.Scatterv` | [`MPI_Scatterv`](https://www.open-mpi.org/doc/v1.10/man3/MPI_Scatterv.3.php)
248252

249-
253+
#### One-sided communication
254+
Julia Function (assuming `import MPI`) | Fortran Function
255+
---------------------------------------|--------------------------------------------------------
256+
`MPI.Win_create` | [`MPI_Win_create`](https://www.open-mpi.org/doc/v3.0/man3/MPI_Win_create.3.php)
257+
`MPI.Win_create_dynamic` | [`MPI_Win_create_dynamic`](https://www.open-mpi.org/doc/v3.0/man3/MPI_Win_create_dynamic.3.php)
258+
`MPI.Win_attach` | [`MPI_Win_attach`](https://www.open-mpi.org/doc/v3.0/man3/MPI_Win_attach.3.php)
259+
`MPI.Win_detach` | [`MPI_Win_detach`](https://www.open-mpi.org/doc/v3.0/man3/MPI_Win_detach.3.php)
260+
`MPI.Win_fence` | [`MPI_Win_fence`](https://www.open-mpi.org/doc/v3.0/man3/MPI_Win_fence.3.php)
261+
`MPI.Win_flush` | [`MPI_Win_flush`](https://www.open-mpi.org/doc/v3.0/man3/MPI_Win_flush.3.php)
262+
`MPI.Win_free` | [`MPI_Win_free`](https://www.open-mpi.org/doc/v3.0/man3/MPI_Win_free.3.php)
263+
`MPI.Win_sync` | [`MPI_Win_sync`](https://www.open-mpi.org/doc/v3.0/man3/MPI_Win_sync.3.php)
264+
`MPI.Win_lock` | [`MPI_Win_lock`](https://www.open-mpi.org/doc/v3.0/man3/MPI_Win_lock.3.php)
265+
`MPI.Win_unlock` | [`MPI_Win_unlock`](https://www.open-mpi.org/doc/v3.0/man3/MPI_Win_unlock.3.php)
266+
`MPI.Get` | [`MPI_Get`](https://www.open-mpi.org/doc/v3.0/man3/MPI_Get.3.php)
267+
`MPI.Put` | [`MPI_Put`](https://www.open-mpi.org/doc/v3.0/man3/MPI_Put.3.php)
268+
`MPI.Fetch_and_op` | [`MPI_Fetch_and_op`](https://www.open-mpi.org/doc/v3.0/man3/MPI_Fetch_and_op.3.php)
250269

251270
[Julia]: http://julialang.org/
252271
[MPI]: http://www.mpi-forum.org/

REQUIRE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
julia 0.6
22
BinDeps
3-
Compat 0.9.5
3+
Compat 0.42

deps/CMakeLists.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,20 @@ FortranCInterface_HEADER(jlmpi_f2c.h MACRO_NAMESPACE "JLMPI_" SYMBOLS
3838
MPI_CANCEL
3939
MPI_COMM_DUP
4040
MPI_COMM_FREE
41+
MPI_COMM_GET_PARENT
4142
MPI_COMM_RANK
4243
MPI_COMM_SIZE
4344
MPI_COMM_SPLIT
4445
MPI_COMM_SPLIT_TYPE
4546
MPI_EXSCAN
47+
MPI_FETCH_AND_OP
4648
MPI_FINALIZE
4749
MPI_FINALIZED
4850
MPI_GATHER
4951
MPI_GATHER
5052
MPI_GATHERV
53+
MPI_GET
54+
MPI_GET_ADDRESS
5155
MPI_GET_COUNT
5256
MPI_GET_PROCESSOR_NAME
5357
MPI_INFO_CREATE
@@ -58,6 +62,7 @@ FortranCInterface_HEADER(jlmpi_f2c.h MACRO_NAMESPACE "JLMPI_" SYMBOLS
5862
MPI_INFO_SET
5963
MPI_INIT
6064
MPI_INITIALIZED
65+
MPI_INTERCOMM_MERGE
6166
MPI_IPROBE
6267
MPI_IRECV
6368
MPI_ISEND
@@ -66,6 +71,7 @@ FortranCInterface_HEADER(jlmpi_f2c.h MACRO_NAMESPACE "JLMPI_" SYMBOLS
6671
MPI_PACK
6772
MPI_PACK_SIZE
6873
MPI_PROBE
74+
MPI_PUT
6975
MPI_RECV
7076
MPI_RECV_INIT
7177
MPI_REDUCE
@@ -88,6 +94,16 @@ FortranCInterface_HEADER(jlmpi_f2c.h MACRO_NAMESPACE "JLMPI_" SYMBOLS
8894
MPI_WAITALL
8995
MPI_WAITANY
9096
MPI_WAITSOME
97+
MPI_WIN_ATTACH
98+
MPI_WIN_CREATE
99+
MPI_WIN_CREATE_DYNAMIC
100+
MPI_WIN_DETACH
101+
MPI_WIN_FENCE
102+
MPI_WIN_FLUSH
103+
MPI_WIN_FREE
104+
MPI_WIN_LOCK
105+
MPI_WIN_SYNC
106+
MPI_WIN_UNLOCK
91107
MPI_WTICK
92108
MPI_WTIME
93109
)

deps/gen_constants.f90

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ program gen_constants
4040
call output("MPI_MAX ", MPI_MAX)
4141
call output("MPI_MAXLOC ", MPI_MAXLOC)
4242
call output("MPI_MIN ", MPI_MIN)
43+
call output("MPI_NO_OP ", MPI_NO_OP)
4344
call output("MPI_MINLOC ", MPI_MINLOC)
4445
call output("MPI_PROD ", MPI_PROD)
4546
call output("MPI_REPLACE ", MPI_REPLACE)
@@ -59,6 +60,9 @@ program gen_constants
5960
call output("MPI_TAG_UB ", MPI_TAG_UB)
6061
call output("MPI_UNDEFINED ", MPI_UNDEFINED)
6162

63+
call output("MPI_INFO_NULL ", MPI_INFO_NULL)
64+
call output("MPI_LOCK_EXCLUSIVE", MPI_LOCK_EXCLUSIVE)
65+
call output("MPI_LOCK_SHARED ", MPI_LOCK_SHARED)
6266
contains
6367

6468
subroutine output(name, value)

deps/gen_functions.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,19 @@ int main(int argc, char *argv[]) {
2929
printf(" :MPI_CANCEL => \"%s\",\n", STRING(MPI_CANCEL));
3030
printf(" :MPI_COMM_DUP => \"%s\",\n", STRING(MPI_COMM_DUP));
3131
printf(" :MPI_COMM_FREE => \"%s\",\n", STRING(MPI_COMM_FREE));
32+
printf(" :MPI_COMM_GET_PARENT => \"%s\",\n", STRING(MPI_COMM_GET_PARENT));
3233
printf(" :MPI_COMM_RANK => \"%s\",\n", STRING(MPI_COMM_RANK));
3334
printf(" :MPI_COMM_SIZE => \"%s\",\n", STRING(MPI_COMM_SIZE));
3435
printf(" :MPI_COMM_SPLIT => \"%s\",\n", STRING(MPI_COMM_SPLIT));
3536
printf(" :MPI_COMM_SPLIT_TYPE => \"%s\",\n", STRING(MPI_COMM_SPLIT_TYPE));
3637
printf(" :MPI_EXSCAN => \"%s\",\n", STRING(MPI_EXSCAN));
38+
printf(" :MPI_FETCH_AND_OP => \"%s\",\n", STRING(MPI_FETCH_AND_OP));
3739
printf(" :MPI_FINALIZE => \"%s\",\n", STRING(MPI_FINALIZE));
3840
printf(" :MPI_FINALIZED => \"%s\",\n", STRING(MPI_FINALIZED));
3941
printf(" :MPI_GATHER => \"%s\",\n", STRING(MPI_GATHER));
4042
printf(" :MPI_GATHERV => \"%s\",\n", STRING(MPI_GATHERV));
43+
printf(" :MPI_GET => \"%s\",\n", STRING(MPI_GET));
44+
printf(" :MPI_GET_ADDRESS => \"%s\",\n", STRING(MPI_GET_ADDRESS));
4145
printf(" :MPI_GET_COUNT => \"%s\",\n", STRING(MPI_GET_COUNT));
4246
printf(" :MPI_GET_PROCESSOR_NAME => \"%s\",\n",
4347
STRING(MPI_GET_PROCESSOR_NAME));
@@ -49,6 +53,7 @@ int main(int argc, char *argv[]) {
4953
printf(" :MPI_INFO_SET => \"%s\",\n", STRING(MPI_INFO_SET));
5054
printf(" :MPI_INIT => \"%s\",\n", STRING(MPI_INIT));
5155
printf(" :MPI_INITIALIZED => \"%s\",\n", STRING(MPI_INITIALIZED));
56+
printf(" :MPI_INTERCOMM_MERGE => \"%s\",\n", STRING(MPI_INTERCOMM_MERGE));
5257
printf(" :MPI_IPROBE => \"%s\",\n", STRING(MPI_IPROBE));
5358
printf(" :MPI_IRECV => \"%s\",\n", STRING(MPI_IRECV));
5459
printf(" :MPI_ISEND => \"%s\",\n", STRING(MPI_ISEND));
@@ -57,6 +62,7 @@ int main(int argc, char *argv[]) {
5762
printf(" :MPI_PACK => \"%s\",\n", STRING(MPI_PACK));
5863
printf(" :MPI_PACK_SIZE => \"%s\",\n", STRING(MPI_PACK_SIZE));
5964
printf(" :MPI_PROBE => \"%s\",\n", STRING(MPI_PROBE));
65+
printf(" :MPI_PUT => \"%s\",\n", STRING(MPI_PUT));
6066
printf(" :MPI_RECV => \"%s\",\n", STRING(MPI_RECV));
6167
printf(" :MPI_RECV_INIT => \"%s\",\n", STRING(MPI_RECV_INIT));
6268
printf(" :MPI_REDUCE => \"%s\",\n", STRING(MPI_REDUCE));
@@ -77,6 +83,16 @@ int main(int argc, char *argv[]) {
7783
printf(" :MPI_WAITALL => \"%s\",\n", STRING(MPI_WAITALL));
7884
printf(" :MPI_WAITANY => \"%s\",\n", STRING(MPI_WAITANY));
7985
printf(" :MPI_WAITSOME => \"%s\",\n", STRING(MPI_WAITSOME));
86+
printf(" :MPI_WIN_ATTACH => \"%s\",\n", STRING(MPI_WIN_ATTACH));
87+
printf(" :MPI_WIN_CREATE => \"%s\",\n", STRING(MPI_WIN_CREATE));
88+
printf(" :MPI_WIN_CREATE_DYNAMIC => \"%s\",\n", STRING(MPI_WIN_CREATE_DYNAMIC));
89+
printf(" :MPI_WIN_DETACH => \"%s\",\n", STRING(MPI_WIN_DETACH));
90+
printf(" :MPI_WIN_FENCE => \"%s\",\n", STRING(MPI_WIN_FENCE));
91+
printf(" :MPI_WIN_FLUSH => \"%s\",\n", STRING(MPI_WIN_FLUSH));
92+
printf(" :MPI_WIN_FREE => \"%s\",\n", STRING(MPI_WIN_FREE));
93+
printf(" :MPI_WIN_LOCK => \"%s\",\n", STRING(MPI_WIN_LOCK));
94+
printf(" :MPI_WIN_SYNC => \"%s\",\n", STRING(MPI_WIN_SYNC));
95+
printf(" :MPI_WIN_UNLOCK => \"%s\",\n", STRING(MPI_WIN_UNLOCK));
8096
printf(" :MPI_WTICK => \"%s\",\n", STRING(MPI_WTICK));
8197
printf(" :MPI_WTIME => \"%s\",\n", STRING(MPI_WTIME));
8298
printf(" :MPI_TYPE_CREATE_STRUCT => \"%s\",\n",
@@ -86,6 +102,8 @@ int main(int argc, char *argv[]) {
86102
printf(")\n");
87103
printf("\n");
88104
printf("primitive type CComm %d end\n", (int)(sizeof(MPI_Comm) * 8));
105+
printf("primitive type CInfo %d end\n", (int)(sizeof(MPI_Info) * 8));
106+
printf("primitive type CWin %d end\n", (int)(sizeof(MPI_Win) * 8));
89107

90108
return 0;
91109
}

src/mpi-base.jl

Lines changed: 157 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ const LOR = Op(MPI_LOR)
8484
const LXOR = Op(MPI_LXOR)
8585
const MAX = Op(MPI_MAX)
8686
const MIN = Op(MPI_MIN)
87+
const NO_OP = Op(MPI_NO_OP)
8788
const PROD = Op(MPI_PROD)
89+
const REPLACE = Op(MPI_REPLACE)
8890
const SUM = Op(MPI_SUM)
8991

9092
mutable struct Request
@@ -95,7 +97,6 @@ const REQUEST_NULL = Request(MPI_REQUEST_NULL, nothing)
9597

9698
mutable struct Info
9799
val::Cint
98-
#val::Cint
99100
function Info()
100101
newinfo = Ref{Cint}()
101102
ccall(MPI_INFO_CREATE, Void, (Ptr{Cint}, Ptr{Cint}), newinfo, &0 )
@@ -105,8 +106,15 @@ mutable struct Info
105106
info.val = MPI_INFO_NULL ) )
106107
info
107108
end
109+
110+
function Info(val::Cint)
111+
if val != MPI_INFO_NULL
112+
error("Info can only be created using Info()")
113+
end
114+
return new(MPI_INFO_NULL)
115+
end
108116
end
109-
const INFO_NULL = MPI_INFO_NULL
117+
const INFO_NULL = Info(MPI_INFO_NULL)
110118

111119
# the info functions assume that Fortran hidden arguments are placed at the end of the argument list
112120
function Info_set(info::Info,key::AbstractString,value::AbstractString)
@@ -149,6 +157,17 @@ Get_error(stat::Status) = Int(stat.val[MPI_ERROR])
149157
Get_source(stat::Status) = Int(stat.val[MPI_SOURCE])
150158
Get_tag(stat::Status) = Int(stat.val[MPI_TAG])
151159

160+
mutable struct Win
161+
val::Cint
162+
Win() = new(0)
163+
end
164+
165+
struct LockType
166+
val::Cint
167+
end
168+
const LOCK_EXCLUSIVE = LockType(MPI_LOCK_EXCLUSIVE)
169+
const LOCK_SHARED = LockType(MPI_LOCK_SHARED)
170+
152171
const ANY_SOURCE = Int(MPI_ANY_SOURCE)
153172
const ANY_TAG = Int(MPI_ANY_TAG)
154173
const TAG_UB = Int(MPI_TAG_UB)
@@ -814,18 +833,154 @@ function Exscan(object::T, op::Op, comm::Comm) where T
814833
Exscan(sendbuf,1,op,comm)
815834
end
816835

836+
function Win_create(base::Array{T}, info::Info, comm::Comm, win::Win) where T
837+
out_win = Ref(win.val)
838+
ccall(MPI_WIN_CREATE, Void,
839+
(Ptr{T}, Ref{Cptrdiff_t}, Ref{Cint}, Ref{Cint}, Ref{Cint}, Ref{Cint}, Ref{Cint}),
840+
base, Cptrdiff_t(length(base)), sizeof(T), info.val, comm.val, out_win, 0)
841+
win.val = out_win[]
842+
end
843+
844+
function Win_create_dynamic(info::Info, comm::Comm, win::Win)
845+
out_win = Ref(win.val)
846+
ccall(MPI_WIN_CREATE_DYNAMIC, Void,
847+
(Ref{Cint}, Ref{Cint}, Ref{Cint}, Ref{Cint}),
848+
info.val, comm.val, out_win, 0)
849+
win.val = out_win[]
850+
end
851+
852+
function Win_attach(win::Win, base::Array{T}) where T
853+
ccall(MPI_WIN_ATTACH, Void,
854+
(Ref{Cint}, Ptr{T}, Ref{Cptrdiff_t}, Ref{Cint}),
855+
win.val, base, Cptrdiff_t(sizeof(base)), 0)
856+
end
857+
858+
function Win_detach(win::Win, base::Array{T}) where T
859+
ccall(MPI_WIN_DETACH, Void,
860+
(Ref{Cint}, Ptr{T}, Ref{Cint}),
861+
win.val, base, 0)
862+
end
863+
864+
function Win_fence(assert::Integer, win::Win)
865+
ccall(MPI_WIN_FENCE, Void, (Ref{Cint}, Ref{Cint}, Ref{Cint}), assert, win.val, 0)
866+
end
867+
868+
function Win_flush(rank::Integer, win::Win)
869+
ccall(MPI_WIN_FLUSH, Void, (Ref{Cint}, Ref{Cint}, Ref{Cint}), rank, win.val, 0)
870+
end
871+
872+
function Win_free(win::Win)
873+
ccall(MPI_WIN_FREE, Void, (Ref{Cint}, Ref{Cint}), win.val, 0)
874+
end
875+
876+
function Win_sync(win::Win)
877+
ccall(MPI_WIN_SYNC, Void, (Ref{Cint}, Ref{Cint}), win.val, 0)
878+
end
879+
880+
function Win_sync(win::CWin)
881+
ccall(:MPI_Win_sync, Void, (CWin,), win)
882+
end
883+
884+
function Win_lock(lock_type::LockType, rank::Integer, assert::Integer, win::Win)
885+
ccall(MPI_WIN_LOCK, Void,
886+
(Ref{Cint}, Ref{Cint}, Ref{Cint}, Ref{Cint}, Ref{Cint}),
887+
lock_type.val, rank, assert, win.val, 0)
888+
end
889+
890+
function Win_unlock(rank::Integer, win::Win)
891+
ccall(MPI_WIN_UNLOCK, Void, (Ref{Cint}, Ref{Cint}, Ref{Cint}), rank, win.val, 0)
892+
end
893+
894+
function Get(origin_buffer::MPIBuffertype{T}, count::Integer, target_rank::Integer, target_disp::Integer, win::Win) where T
895+
ccall(MPI_GET, Void,
896+
(Ptr{T}, Ref{Cint}, Ref{Cint}, Ref{Cint}, Ref{Cptrdiff_t}, Ref{Cint}, Ref{Cint}, Ref{Cint}, Ref{Cint}),
897+
origin_buffer, count, mpitype(T), target_rank, Cptrdiff_t(target_disp), count, mpitype(T), win.val, 0)
898+
end
899+
function Get(origin_buffer::Array{T}, target_rank::Integer, win::Win) where T
900+
count = length(origin_buffer)
901+
Get(origin_buffer, count, target_rank, 0, win)
902+
end
903+
function Get(origin_value::Ref{T}, target_rank::Integer, win::Win) where T
904+
Get(origin_value, 1, target_rank, 0, win)
905+
end
906+
907+
function Put(origin_buffer::MPIBuffertype{T}, count::Integer, target_rank::Integer, target_disp::Integer, win::Win) where T
908+
ccall(MPI_PUT, Void,
909+
(Ptr{T}, Ref{Cint}, Ref{Cint}, Ref{Cint}, Ref{Cptrdiff_t}, Ref{Cint}, Ref{Cint}, Ref{Cint}, Ref{Cint}),
910+
origin_buffer, count, mpitype(T), target_rank, Cptrdiff_t(target_disp), count, mpitype(T), win.val, 0)
911+
end
912+
function Put(origin_buffer::Array{T}, target_rank::Integer, win::Win) where T
913+
count = length(origin_buffer)
914+
Put(origin_buffer, count, target_rank, 0, win)
915+
end
916+
function Put(origin_value::Ref{T}, target_rank::Integer, win::Win) where T
917+
Put(origin_value, 1, target_rank, 0, win)
918+
end
919+
920+
function Fetch_and_op(sourceval::MPIBuffertype{T}, returnval::MPIBuffertype{T}, target_rank::Integer, target_disp::Integer, op::Op, win::Win) where T
921+
ccall(MPI_FETCH_AND_OP, Void,
922+
(Ptr{T}, Ptr{T}, Ref{Cint}, Ref{Cint}, Ref{Cptrdiff_t}, Ref{Cint}, Ref{Cint}, Ref{Cint}),
923+
sourceval, returnval, mpitype(T), target_rank, Cptrdiff_t(target_disp), op.val, win.val, 0)
924+
end
925+
926+
function Fetch_and_op(sourceval::MPIBuffertype{T}, returnval::MPIBuffertype{T}, target_rank::Integer, target_disp::Integer, op::Op, win::CWin) where T
927+
ccall(:MPI_Fetch_and_op, Void,
928+
(Ptr{T}, Ptr{T}, Cint, Cint, Cptrdiff_t, Cint, CWin),
929+
sourceval, returnval, mpitype(T), target_rank, target_disp, op.val, win)
930+
end
931+
932+
function Get_address(location::MPIBuffertype{T}) where T
933+
addr = Ref{Cptrdiff_t}(0)
934+
ccall(MPI_GET_ADDRESS, Void, (Ptr{T}, Ref{Cptrdiff_t}, Ref{Cint}), location, addr, 0)
935+
#ccall(:MPI_Get_address, Int, (Ptr{Void}, Ref{Cptrdiff_t}), location, addr)
936+
return addr[]
937+
end
938+
939+
function Comm_get_parent()
940+
comm_id = Ref{Cint}()
941+
ccall(MPI_COMM_GET_PARENT, Void, (Ref{Cint}, Ref{Cint}), comm_id, 0)
942+
return Comm(comm_id[])
943+
end
944+
945+
function Comm_spawn(command::String, argv::Vector{String}, nprocs::Integer, comm::Comm, errors = Vector{Cint}(nprocs))
946+
c_intercomm = Ref{CComm}()
947+
ccall(:MPI_Comm_spawn, Void,
948+
(Cstring, Ptr{Ptr{Cchar}}, Cint, CInfo, Cint, CComm, Ref{CComm}, Ptr{Cint}),
949+
command, argv, nprocs, CInfo(INFO_NULL), 0, CComm(comm), c_intercomm, errors)
950+
return Comm(c_intercomm[])
951+
end
952+
953+
function Intercomm_merge(intercomm::Comm, flag::Bool)
954+
comm_id = Ref{Cint}()
955+
ccall(MPI_INTERCOMM_MERGE, Void, (Ref{Cint}, Ref{Cint}, Ref{Cint}, Ref{Cint}), intercomm.val, Cint(flag), comm_id, 0)
956+
return Comm(comm_id[])
957+
end
958+
817959
# Conversion between C and Fortran Comm handles:
818960
if HAVE_MPI_COMM_C2F
819961
# use MPI_Comm_f2c and MPI_Comm_c2f
820962
Base.convert(::Type{CComm}, comm::Comm) =
821963
ccall(:MPI_Comm_f2c, CComm, (Cint,), comm.val)
822964
Base.convert(::Type{Comm}, ccomm::CComm) =
823965
Comm(ccall(:MPI_Comm_c2f, Cint, (CComm,), ccomm))
966+
# Assume info is treated the same way
967+
Base.convert(::Type{CInfo}, info::Info) =
968+
ccall(:MPI_Info_f2c, CInfo, (Cint,), info.val)
969+
Base.convert(::Type{Info}, cinfo::CInfo) =
970+
Info(ccall(:MPI_Info_c2f, Cint, (CInfo,), cinfo))
971+
Base.convert(::Type{CWin}, win::Win) =
972+
ccall(:MPI_Win_f2c, CWin, (Cint,), win.val)
973+
Base.convert(::Type{Win}, cwin::CWin) =
974+
Win(ccall(:MPI_Win_c2f, Cint, (CWin,), cwin))
824975
elseif sizeof(CComm) == sizeof(Cint)
825976
# in MPICH, both C and Fortran use identical Cint comm handles
826977
# and MPI_Comm_c2f is not provided.
827978
Base.convert(::Type{CComm}, comm::Comm) = reinterpret(CComm, comm.val)
828979
Base.convert(::Type{Comm}, ccomm::CComm) = Comm(reinterpret(Cint, ccomm))
980+
Base.convert(::Type{CInfo}, info::Info) = reinterpret(CInfo, info.val)
981+
Base.convert(::Type{Info}, cinfo::CInfo) = Info(reinterpret(Cint, cinfo))
982+
Base.convert(::Type{CWin}, win::Win) = reinterpret(CWin, win.val)
983+
Base.convert(::Type{Win}, cwin::CWin) = Win(reinterpret(Cint, cwin))
829984
else
830985
warn("No MPI_Comm_c2f found - conversion to/from MPI.CComm will not work")
831986
end

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const coverage_opts =
1818
# Files to run without mpiexec
1919
juliafiles = ["test_cman_julia.jl"]
2020
# Files to run with mpiexec -n 1
21-
singlefiles = []
21+
singlefiles = ["test_spawn.jl"]
2222

2323
function runtests()
2424
nprocs = clamp(Sys.CPU_CORES, 2, 4)

0 commit comments

Comments
 (0)