Skip to content

standardize opaque handle types #3

Closed
@jeffhammond

Description

@jeffhammond

Problem

The type of the opaque handles -- Comm, Datatype, File, Group, Info, Message, Op, Request, Window -- must be standardized to have an ABI.

MPICH currently uses int. Open-MPI uses pointers. There are advantages to both.

Unfortunately, because we are required to support equality comparison in C, which lacks operator overloading, we cannot do something elegant like struct or union (which would allow compilers to do type-checking).

Proposal

Option 1

Standardizing intptr_t is compatible with both existing designs, although it is an ABI change for MPICH (on 64-bit platforms, at least).

intptr_t would allow Open-MPI to continue to use pointers internally since, by definition, intptr_t can be cast to/from valid pointers. Since it is also an integer, MPICH can continue to use the tricks it has for encoding special values, and just ignore the additional zeroes.

Option 2

Handles that are incomplete struct pointers (ISPs) allow for type checking. Encoding compile-time constants for predefined handles relies on implementation-defined behavior (IB) but should be viable.

The translation from ISP to MPICH handles not as simple as with Option 1. If one implements a compatibility layer, it could maintain a vector of integers and the pointers could pointer to these, assuming casting an ISP to int* is always legal. Encoding the int handles directly in the ISP as a value relies on IB.

Changes to the Text

Impact on Implementations

Implementations will have to change, particularly macros that manipulate handles.

The biggest impact is that this breaks the MPICH ABI, but that is a necessary evil in this process.

Impact on Users

Breaking existing MPICH ABI but have standard ABI.

References and Pull Requests

https://github.com/jeffhammond/blog/blob/main/MPI_Needs_ABI_Part_4.md (although this proposes the invalid union/struct design)

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