[Solved] what is the c++ equivalent type if MPI_FLOAT_INT


The only authoritative source, the MPI standard, defines MPI_FLOAT_INT as (Section 5.9.4 MINLOC and MAXLOC):

The datatype MPI_FLOAT_INT is as if defined by the following sequence of instructions.

type[0] = MPI_FLOAT
type[1] = MPI_INT
disp[0] = 0
disp[1] = sizeof(float)
block[0] = 1
block[1] = 1
MPI_TYPE_CREATE_STRUCT(2, block, disp, type, MPI_FLOAT_INT)

Similar statements apply for MPI_LONG_INT and MPI_DOUBLE_INT.

It means that the type corresponds to struct { float a; int b; }, but only if there is guarantee that no padding space is inserted between a and b. This might not be the case on systems where int is 64-bit and has to be aligned on 8 bytes. One might need to instruct the compiler to generate packed structures, e.g. with GCC:

#pragma pack(push, 1)
struct float_int
{
   float a;
   int b;
}
#pragma pack(pop)

Note that MPI_FLOAT_INT is intended to be used in MINLOC and MAXLOC reductions in order to find out both the min/max float value and the lowest numbered rank that is holding it.

solved what is the c++ equivalent type if MPI_FLOAT_INT