Skip to content

Pack/unpack external broken for long double real and complex datatypes #8770

@dalcinl

Description

@dalcinl

Looks like the pack/unpack external operations do not roundtrip for long double (real and complex) datatypes with current ompi@master.

This is my trivial Python reproducer

from mpi4py import MPI
import numpy as np

datatype = MPI.LONG_DOUBLE
typecode = MPI._typecode(datatype)
iarray = np.array([1,2,3], dtype=typecode)
oarray = np.zeros(3, dtype=typecode)

n = datatype.Pack_external_size("external32", len(iarray))
work = bytearray(n)
datatype.Pack_external("external32", iarray, work, 0)
datatype.Unpack_external("external32", work, 0, oarray)

print(iarray)
print(oarray)

Running on my Linux-64 workstation I get the following output (both lines are expected to be the same):

[1. 2. 3.]
[8.40525786e-4933 8.40525786e-4933 1.26078868e-4932]

@jsquyres I understand that supporting external32 for long double [complex] is a bit tricky. You probably have to rely on a compiler quad-precision type like GCC __float128 for a proper implementation, see MPI 3.1 Table 13.2 pp. 580 RFC 1832, Sec. 3.8, but if it cannot be supported, then perhaps you should error rather that let things success silently and end up with broken data? Or maybe this is just a trivial bug?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions