Skip to content

Commit 21e9d97

Browse files
authored
Fix typo in create_resized (#495)
1 parent 027b051 commit 21e9d97

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

src/datatypes.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ communication.
361361
$(_doc_external("MPI_Type_create_resized"))
362362
"""
363363
function create_resized(oldtype::Datatype, lb::Integer, extent::Integer)
364-
finalizer(free, create_resized(Datatype(), oldtype, lb, extent))
364+
finalizer(free, create_resized!(Datatype(), oldtype, lb, extent))
365365
end
366366
function create_resized!(newtype::Datatype, oldtype::Datatype, lb::Integer, extent::Integer)
367367
# int MPI_Type_create_resized(MPI_Datatype oldtype, MPI_Aint lb,

test/test_datatype.jl

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,37 @@ end
150150
@test arr_recv == [nothing for i = 1:100]
151151
end
152152

153+
struct Particle
154+
x::Float32
155+
y::Float32
156+
z::Float32
157+
velocity::Float32
158+
name::Char
159+
mass::Float64
160+
end
161+
@testset "create_X" begin
162+
# create_vector
163+
RowType = MPI.Types.create_vector(8, 1, 8, MPI.DOUBLE)
164+
@test typeof(RowType) == MPI.Datatype
165+
166+
# create_subarray
167+
SubMatrixType = MPI.Types.create_subarray((8, 8), (4, 4), (0, 0), MPI.INT64_T)
168+
@test typeof(SubMatrixType) == MPI.Datatype
169+
170+
# create_struct + _resized
171+
oldtypes = MPI.Datatype.([Float32, Char, Float64])
172+
len = [4, 1, 1]
173+
disp = Vector{Int}(undef, 3)
174+
disp[1] = 0
175+
disp[2] = disp[1] + 4 * sizeof(Float32)
176+
disp[3] = disp[2] + sizeof(Char)
177+
178+
tmp = MPI.Types.create_struct(len, disp, oldtypes)
179+
@test typeof(tmp) == MPI.Datatype
180+
ParticleMPI = MPI.Types.create_resized(tmp, 0, sizeof(Particle))
181+
@test typeof(ParticleMPI) == MPI.Datatype
182+
end
183+
153184

154185
MPI.Barrier(MPI.COMM_WORLD)
155186
MPI.Finalize()

0 commit comments

Comments
 (0)