pmix-standard icon indicating copy to clipboard operation
pmix-standard copied to clipboard

Fix asymmetry in data structure construct/destruct API

Open jjhursey opened this issue 3 years ago • 4 comments

Overview

Some PMIx data structures use a function for construction and a macro for destruction. See https://github.com/openpmix/openpmix/pull/2844 for a discussion of this issue.

Motivation

For consistency, the PMIx standard should be symmetric and consistent in the interface used for the data structure lifecycle. This discontinuity occurred while making the ABI for datatypes that were complex to construct but simple to destruct.

Discussion Items

Per PMIx Meeting on Dec. 8, 2022, the group decided to use functions for both types of operations. An implementation may provide a macro for backward compatibility that calls the appropriate function. The rationale was that by using functions instead of macros makes the interface stronger in an ABI sense, as well as more consistent.

jjhursey avatar Dec 08 '22 18:12 jjhursey

I'm kinda stuck on how to convert this macro to a function:

rhc54 avatar Dec 12 '22 23:12 rhc54

I'm kinda stuck on how to convert this macro to a function:

#define PMIX_VALUE_GET_NUMBER(s, m, n, t)               \
    do {                                                \
        (s) = PMIX_SUCCESS;                             \
        if (PMIX_SIZE == (m)->type) {                   \
            (n) = (t)((m)->data.size);                  \
        } else if (PMIX_INT == (m)->type) {             \
            (n) = (t)((m)->data.integer);               \
        } else if (PMIX_INT8 == (m)->type) {            \
            (n) = (t)((m)->data.int8);                  \
        } else if (PMIX_INT16 == (m)->type) {           \
            (n) = (t)((m)->data.int16);                 \
        } else if (PMIX_INT32 == (m)->type) {           \
            (n) = (t)((m)->data.int32);                 \
        } else if (PMIX_INT64 == (m)->type) {           \
            (n) = (t)((m)->data.int64);                 \
        } else if (PMIX_UINT == (m)->type) {            \
            (n) = (t)((m)->data.uint);                  \
        } else if (PMIX_UINT8 == (m)->type) {           \
            (n) = (t)((m)->data.uint8);                 \
        } else if (PMIX_UINT16 == (m)->type) {          \
            (n) = (t)((m)->data.uint16);                \
        } else if (PMIX_UINT32 == (m)->type) {          \
            (n) = (t)((m)->data.uint32);                \
        } else if (PMIX_UINT64 == (m)->type) {          \
            (n) = (t)((m)->data.uint64);                \
        } else if (PMIX_FLOAT == (m)->type) {           \
            (n) = (t)((m)->data.fval);                  \
        } else if (PMIX_DOUBLE == (m)->type) {          \
            (n) = (t)((m)->data.dval);                  \
        } else if (PMIX_PID == (m)->type) {             \
            (n) = (t)((m)->data.pid);                   \
        } else if (PMIX_PROC_RANK == (m)->type) {       \
            (n) = (t)((m)->data.rank);                  \
        } else {                                        \
            (s) = PMIX_ERR_BAD_PARAM;                   \
        }                                               \
    } while(0)

Any suggestions?

rhc54 avatar Dec 12 '22 23:12 rhc54

I have converted all the macros to functions, except for the one posted above. I think I have a solution there and will be playing with it next.

rhc54 avatar Dec 13 '22 23:12 rhc54

I think this issue has been resolved when we added the ABI in v5.0.

abouteiller avatar Feb 13 '25 20:02 abouteiller