Skip to content

Commit 6b4c8d3

Browse files
committed
Add wrappers for MPI_COMM_SPLIT and MPI_COMM_SPLIT_TYPE for defining new communicators, especially node-wise communicators and constants.
Add preliminary wrappers for MPI_Info type, which is required by MPI_COMM_SPLIT_TYPE. Add wrappers for Wtime and Wtick.
1 parent b7f8da7 commit 6b4c8d3

File tree

4 files changed

+37
-0
lines changed

4 files changed

+37
-0
lines changed

deps/gen_constants.f90

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ program gen_constants
2828
call output("MPI_COMM_SELF ", MPI_COMM_SELF)
2929
call output("MPI_COMM_WORLD ", MPI_COMM_WORLD)
3030

31+
call output("MPI_COMM_TYPE_SHARED", MPI_COMM_TYPE_SHARED)
32+
3133
call output("MPI_OP_NULL ", MPI_OP_NULL)
3234
call output("MPI_BAND ", MPI_BAND)
3335
call output("MPI_BOR ", MPI_BOR)
@@ -45,6 +47,8 @@ program gen_constants
4547

4648
call output("MPI_REQUEST_NULL", MPI_REQUEST_NULL)
4749

50+
call output("MPI_INFO_NULL ", MPI_INFO_NULL)
51+
4852
call output("MPI_STATUS_SIZE ", MPI_STATUS_SIZE)
4953
call output("MPI_ERROR ", MPI_ERROR)
5054
call output("MPI_SOURCE ", MPI_SOURCE)

deps/gen_functions.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ int main(int argc, char *argv[]) {
3232
printf(" :MPI_COMM_RANK => \"%s\",\n", STRING(MPI_COMM_RANK));
3333
printf(" :MPI_COMM_SIZE => \"%s\",\n", STRING(MPI_COMM_SIZE));
3434
printf(" :MPI_COMM_SPLIT => \"%s\",\n", STRING(MPI_COMM_SPLIT));
35+
printf(" :MPI_COMM_SPLIT_TYPE => \"%s\",\n", STRING(MPI_COMM_SPLIT_TYPE));
3536
printf(" :MPI_EXSCAN => \"%s\",\n", STRING(MPI_EXSCAN));
3637
printf(" :MPI_FINALIZE => \"%s\",\n", STRING(MPI_FINALIZE));
3738
printf(" :MPI_FINALIZED => \"%s\",\n", STRING(MPI_FINALIZED));
@@ -70,6 +71,7 @@ int main(int argc, char *argv[]) {
7071
printf(" :MPI_WAITALL => \"%s\",\n", STRING(MPI_WAITALL));
7172
printf(" :MPI_WAITANY => \"%s\",\n", STRING(MPI_WAITANY));
7273
printf(" :MPI_WAITSOME => \"%s\",\n", STRING(MPI_WAITSOME));
74+
printf(" :MPI_WTICK => \"%s\",\n", STRING(MPI_WTICK));
7375
printf(" :MPI_WTIME => \"%s\",\n", STRING(MPI_WTIME));
7476
printf(" :MPI_TYPE_CREATE_STRUCT => \"%s\",\n",
7577
STRING(MPI_TYPE_CREATE_STRUCT));

src/mpi-base.jl

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ mutable struct Request
9393
end
9494
const REQUEST_NULL = Request(MPI_REQUEST_NULL, nothing)
9595

96+
mutable struct Info
97+
val::Cint
98+
end
99+
const INFO_NULL = Info(MPI_INFO_NULL)
100+
96101
mutable struct Status
97102
val::Array{Cint,1}
98103
Status() = new(Array{Cint}(MPI_STATUS_SIZE))
@@ -169,6 +174,28 @@ function Comm_size(comm::Comm)
169174
Int(size[])
170175
end
171176

177+
function Comm_split(comm::Comm,color::Integer,key::Integer)
178+
newcomm = Ref{Cint}()
179+
ccall(MPI_COMM_SPLIT, Void, (Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}),
180+
&comm.val, &color, &key, newcomm, &0)
181+
MPI.Comm(newcomm[])
182+
end
183+
184+
function Comm_split_type(comm::Comm,split_type::Integer,key::Integer;info::Info=INFO_NULL)
185+
newcomm = Ref{Cint}()
186+
ccall(MPI_COMM_SPLIT_TYPE, Void, (Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}),
187+
&comm.val, &split_type, &key, &info.val, newcomm, &0)
188+
MPI.Comm(newcomm[])
189+
end
190+
191+
function Wtick()
192+
ccall(MPI_WTICK, Cdouble, () )
193+
end
194+
195+
function Wtime()
196+
ccall(MPI_WTIME, Cdouble, () )
197+
end
198+
172199
function type_create(T::DataType)
173200
if !isbits(T)
174201
throw(ArgumentError("Type must be isbits()"))

src/win_mpiconstants.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const MPI_INTEGER8 = Int32(0x4c000831)
2222
const MPI_COMM_NULL = Int32(67108864)
2323
const MPI_COMM_SELF = Int32(1140850689)
2424
const MPI_COMM_WORLD = Int32(1140850688)
25+
const MPI_COMM_TYPE_SHARED = Int32(1)
2526
const MPI_OP_NULL = Int32(402653184)
2627
const MPI_BAND = Int32(1476395014)
2728
const MPI_BOR = Int32(1476395016)
@@ -37,6 +38,7 @@ const MPI_PROD = Int32(1476395012)
3738
const MPI_REPLACE = Int32(1476395021)
3839
const MPI_SUM = Int32(1476395011)
3940
const MPI_REQUEST_NULL = Int32(738197504)
41+
const MPI_INFO_NULL = Int32(469762048)
4042
const MPI_STATUS_SIZE = Int32(5)
4143
const MPI_ERROR = Int32(5)
4244
const MPI_SOURCE = Int32(3)
@@ -51,6 +53,8 @@ const MPI_ABORT = (:MPI_ABORT, "msmpi.dll")
5153
const MPI_INIT = (:MPI_INIT, "msmpi.dll")
5254
const MPI_COMM_RANK = (:MPI_COMM_RANK, "msmpi.dll")
5355
const MPI_COMM_SIZE = (:MPI_COMM_SIZE, "msmpi.dll")
56+
const MPI_COMM_SPLIT = (:MPI_COMM_SPLIT, "msmpi.dll")
57+
const MPI_COMM_SPLIT_TYPE = (:MPI_COMM_SPLIT_TYPE, "msmpi.dll")
5458
const MPI_BARRIER = (:MPI_BARRIER, "msmpi.dll")
5559
const MPI_FINALIZE = (:MPI_FINALIZE, "msmpi.dll")
5660
const MPI_BCAST = (:MPI_BCAST, "msmpi.dll")

0 commit comments

Comments
 (0)