@@ -120,6 +120,48 @@ function Comm_size(comm::Comm)
120120 Int (size[])
121121end
122122
123+ function Type_create_struct {T <: DataType} (:: Type{T} )
124+
125+ @assert isbits (T)
126+ fieldtypes = T. types
127+ offsets = fieldoffsets (T)
128+ nfields = Cint (length (fieldtypes))
129+
130+ blocklengths = ones (Cint, nfields)
131+ displacements = zeros (Cint, nfields)
132+ types = zeros (Cint, nfields)
133+ for i= 1 : nfields
134+ displacements[i] = offsets[i]
135+ types[i] = mpitype (fieldtypes[i])
136+ end
137+
138+ newtype_ref = Ref {Cint} ()
139+ flag = Ref {Cint} ()
140+ ccall (MPI_TYPE_CREATE_STRUCT, Void, (Ptr{Cint}, Ptr{Cint}, Ptr{Cint},
141+ Ptr{Cint}, Ptr{Cint}), & nfields, blocklengths, displacements, types,
142+ newtype_ref, flag)
143+
144+ if flag[] != 0
145+ println (STDERR, " Warning: MPI_TYPE_CREATE_STRUCT returned non-zero exit stats" )
146+ end
147+
148+ flag2 = Ref {Cint} ()
149+
150+ ccall (MPI_TYPE_COMMIT, Void, (Ptr{Cint}, Ptr{Cint}), newtype_ref, flag2)
151+
152+ if flag2[] != 0
153+ println (STDERR, " Warning: MPI_TYPE_COMMIT returned non-zero exit status" )
154+ end
155+
156+ mpitype_dict[T] = newtype_ref[]
157+
158+ return nothing
159+ end
160+
161+
162+
163+
164+
123165# Point-to-point communication
124166
125167function Probe (src:: Integer , tag:: Integer , comm:: Comm )
0 commit comments