user2069668
user2069668

Reputation: 91

How to implement MPI_Datatype starting from scratch? (In a new OS)

I am trying to implement the MPI protocol in EPOS Operation System. In this moment, I am studying the MPI_Datatypes. Well, I wrote a document with some mpi types, in this way:

typedef unsigned int MPI_Datatype;

#define MPI_CHAR ((MPI_Datatype)1)

#define MPI_UNSIGNED_CHAR ((MPI_Datatype)2)

#define MPI_BYTE ((MPI_Datatype)3)

#define MPI_SHORT ((MPI_Datatype)4)

#define MPI_UNSIGNED_SHORT ((MPI_Datatype)5)

.....

But, I think it's not good! How could I explicit write that the MPI_CHAR is equivalent to 1 byte character (a char type in C language). Or, for example, MPI_INT is equivalent to 32-bit integer. Are that possible? I would like some tips! Thanks a lot! (Sorry if the title of this topic is not so understandable!).

Upvotes: 1

Views: 325

Answers (1)

nullptr
nullptr

Reputation: 11058

In fact, MPI_CHAR is not equivalent to a char type: you cannot declare a variable of MPI_CHAR type. MPI_CHAR is just an integer constant that tells MPI to process the data as a sequence of chars.

So what you have done is quite correct.

You should then map each supported MPI_Datatype to a real type at the place(s) where the MPI implementation processes the MPI_Datatype values. E.g. in MPI_Send when determining amount of data to be sent.

Upvotes: 2

Related Questions