@@ -19,7 +19,7 @@ const DATATYPE_NULL = _Datatype(MPI_DATATYPE_NULL)
19
19
20
20
const MPI_Datatype_default = MPI_Datatype == Cint ? MPI_DATATYPE_NULL : C_NULL
21
21
Datatype () = Datatype (MPI_Datatype_default)
22
-
22
+
23
23
24
24
function free (dt:: Datatype )
25
25
if dt. val != DATATYPE_NULL. val && ! Finalized ()
80
80
81
81
# names
82
82
function get_name (datatype:: Datatype )
83
+ MPI. Initialized () || return " "
83
84
buffer = Array {UInt8} (undef, MPI_MAX_OBJECT_NAME)
84
85
lenref = Ref {Cint} ()
85
86
@mpichk ccall ((:MPI_Type_get_name , libmpi), Cint,
86
- (MPI_Datatype, Ptr{UInt8}, Ptr{Cint}),
87
+ (MPI_Datatype, Ptr{UInt8}, Ptr{Cint}),
87
88
datatype, buffer, lenref)
88
- String (resize! (buffer, lenref[]))
89
+ return String (resize! (buffer, lenref[]))
89
90
end
90
91
91
92
# datatype attribute to store Julia type
@@ -99,11 +100,13 @@ Return the Julia type corresponding to the MPI [`Datatype`](@ref) `datatype`, or
99
100
if it doesn't correspond directly.
100
101
"""
101
102
function to_type (datatype:: Datatype )
102
- ptr = get_attr (datatype, JULIA_TYPE_PTR_ATTR[])
103
- if isnothing (ptr)
104
- return ptr
103
+ if MPI. Initialized ()
104
+ ptr = get_attr (datatype, JULIA_TYPE_PTR_ATTR[])
105
+ if ! isnothing (ptr)
106
+ return unsafe_pointer_to_objref (ptr)
107
+ end
105
108
end
106
- return unsafe_pointer_to_objref (ptr)
109
+ return nothing
107
110
end
108
111
109
112
159
162
160
163
161
164
function Base. show (io:: IO , datatype:: Datatype )
162
- juliatype = to_type (datatype)
163
165
show (io, Datatype)
164
166
print (io, ' (' )
167
+ juliatype = to_type (datatype)
165
168
if isnothing (juliatype)
166
169
show (io, datatype. val)
167
170
else
@@ -174,7 +177,7 @@ function Base.show(io::IO, datatype::Datatype)
174
177
print (io, name)
175
178
end
176
179
end
177
-
180
+
178
181
179
182
180
183
module Types
231
234
MPI.Types.create_vector(count::Integer, blocklength::Integer, stride::Integer, oldtype::MPI.Datatype)
232
235
233
236
Create a derived [`Datatype`](@ref) that replicates `oldtype` into locations that
234
- consist of equally spaced blocks.
237
+ consist of equally spaced blocks.
235
238
236
239
Note that [`MPI.Types.commit!`](@ref) must be used before the datatype can be used for
237
240
communication.
274
277
"""
275
278
MPI.Types.create_subarray(sizes, subsizes, offset, oldtype::Datatype;
276
279
rowmajor=false)
277
-
280
+
278
281
Creates a derived [`Datatype`](@ref) describing an `N`-dimensional subarray of size
279
282
`subsizes` of an `N`-dimensional array of size `sizes` and element type `oldtype`, with
280
283
the first element offset by `offset` (i.e. the 0-based index of the first element).
@@ -298,7 +301,7 @@ function create_subarray!(newtype::Datatype, sizes, subsizes, offset, oldtype::D
298
301
sizes = sizes isa Vector{Cint} ? sizes : Cint[s for s in sizes]
299
302
subsizes = subsizes isa Vector{Cint} ? subsizes : Cint[s for s in subsizes]
300
303
offset = offset isa Vector{Cint} ? offset : Cint[s for s in offset]
301
-
304
+
302
305
@mpichk ccall ((:MPI_Type_create_subarray , libmpi), Cint,
303
306
(Cint, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Cint, MPI_Datatype, Ptr{MPI_Datatype}),
304
307
N, sizes, subsizes, offset,
0 commit comments