@@ -120,31 +120,36 @@ function Comm_size(comm::Comm)
120120 Int (size[])
121121end
122122
123- function Type_create_struct {T <: DataType} (:: Type{T} )
123+ function Type_create_struct {T <: Any} (:: Type{T} ) # <: Any effectively
124+ # limits T to being a Type
124125
125126 @assert isbits (T)
127+ # get the data from the type
126128 fieldtypes = T. types
127129 offsets = fieldoffsets (T)
128130 nfields = Cint (length (fieldtypes))
129131
132+ # put data in MPI format
130133 blocklengths = ones (Cint, nfields)
131- displacements = zeros (Cint , nfields)
134+ displacements = zeros (Csize_t , nfields) # size_t == MPI_Aint ?
132135 types = zeros (Cint, nfields)
133136 for i= 1 : nfields
134137 displacements[i] = offsets[i]
135138 types[i] = mpitype (fieldtypes[i])
136139 end
137140
141+ # create the datatype
138142 newtype_ref = Ref {Cint} ()
139143 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,
144+ ccall (MPI_TYPE_CREATE_STRUCT, Void, (Ptr{Cint}, Ptr{Cint}, Ptr{Csize_t },
145+ Ptr{Cint}, Ptr{Cint}, Ptr{Cint} ), & nfields, blocklengths, displacements, types,
142146 newtype_ref, flag)
143147
144148 if flag[] != 0
145149 println (STDERR, " Warning: MPI_TYPE_CREATE_STRUCT returned non-zero exit stats" )
146150 end
147151
152+ # commit the datatatype
148153 flag2 = Ref {Cint} ()
149154
150155 ccall (MPI_TYPE_COMMIT, Void, (Ptr{Cint}, Ptr{Cint}), newtype_ref, flag2)
@@ -153,6 +158,7 @@ function Type_create_struct{T <: DataType}(::Type{T})
153158 println (STDERR, " Warning: MPI_TYPE_COMMIT returned non-zero exit status" )
154159 end
155160
161+ # add it to the dictonary of known types
156162 mpitype_dict[T] = newtype_ref[]
157163
158164 return nothing
0 commit comments