I am implementing a message passing interface and one of the qualifications of its standards are custom MPI datatypes that map to say C datatypes. E.g MPI_INT maps to the C int.

So simple enough I would like to do:

typedef int MPI_INT;
typedef short int MPI_SHORT;

But I want all these custom datatypes to be under a more general datatype called MPI_Datatype such that I could make a function prototype such as

MPI_Send(void*, MPI_Datatype)

where MPI_Datatype is one of MPI_INT, MPI_SHORT, etc

I'm not really sure how one would do this in C so if anyone has an idea that would be superb.

1 Answers

Ali On

You may assign a unique ID number to each data type, and have both sides of the message passing line agree on it. Apparently you cannot compare data types, i.e. if (data_type == MPI_INT), but you can compare IDs.