Skip to content

Commit 6a81554

Browse files
authored
Add bool datatype handling (#522)
Fixes #506.
1 parent df887b4 commit 6a81554

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/datatypes.jl

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,18 @@ for (mpiname, T) in [
134134
:FLOAT => Float32
135135
:DOUBLE => Float64
136136
:C_FLOAT_COMPLEX => ComplexF32
137-
:C_DOUBLE_COMPLEX => ComplexF64]
137+
:C_DOUBLE_COMPLEX => ComplexF64
138+
:C_BOOL => Bool
139+
]
138140

139141
@eval if @isdefined($(Symbol(:MPI_,mpiname)))
140142
const $mpiname = _Datatype($(Symbol(:MPI_,mpiname)))
141143
if !hasmethod(Datatype, Tuple{Type{$T}})
142144
Datatype(::Type{$T}) = $mpiname
143-
push!(mpi_init_hooks, () -> set_attr!($mpiname, JULIA_TYPE_PTR_ATTR[], pointer_from_objref($T)))
145+
push!(mpi_init_hooks, () -> begin
146+
@assert Types.size($mpiname) == sizeof($T)
147+
set_attr!($mpiname, JULIA_TYPE_PTR_ATTR[], pointer_from_objref($T))
148+
end)
144149
end
145150
end
146151
end
@@ -187,6 +192,16 @@ import MPI: @mpichk, libmpi, _doc_external,
187192
Datatype, MPI_Datatype, MPI_Aint,
188193
free
189194

195+
# ??
196+
function size(dt::Datatype)
197+
dtsize = Ref{Cint}()
198+
@mpichk ccall((:MPI_Type_size, libmpi), Cint,
199+
(MPI_Datatype, Ptr{Cint}),
200+
dt, dtsize)
201+
return dtsize[]
202+
end
203+
204+
190205
"""
191206
lb, extent = MPI.Types.extent(dt::MPI.Datatype)
192207

0 commit comments

Comments
 (0)