Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Size of MPI_Aint?

Tags:

c

mpi

I have a simple question about MPI_Aint, but I didn't find any answer anywhere. For some reason, MPI_Type_size(MPI_Aint) doesn't work (it does not look like classical datatypes, e.g. MPI_Double or MPI_Int), at least with OpenMPI 1.8.4 and 1.10.1 but I don't think it's an OpenMPI problem.

I have to create a type with MPI_Type_create_hindexed() and to allocate the array_of_displacements array dynamically. After computing a size N, I wrote

MPI_Aint* disps = (MPI_Aint*) malloc(N*sizeof(MPI_Aint)) ;

instead of

int mpiAintSize ;
MPI_Type_size(MPI_Aint, &mpiAintSize) ;
MPI_Aint* disps = (MPI_Aint*) malloc(N*mpiAintSize) ;

because of this problem. sizeof() will do the job as long as I'm lucky and I don't need portability (this array will be used to write/read big files with MPI-I/O).

But I would like to know: what is the clean and portable way to allocate my disps array ? What did I miss about MPI_Aint ?

like image 890
Robin Huart Avatar asked Oct 19 '22 12:10

Robin Huart


1 Answers

MPI_Aint isn't a MPI_Type such as MPI_INT, MPI_DOUBLE or what you create with MPI_Type_create_hindexed(), MPI_Aint is a type in the C language, like int, double or a struct. In fact I suspect that most of the time MPI_Aint will simply be define as a typedef large enough to store what it needs to. Most probably, it will be define as either typedef long MPI_Aint; or typedef long long MPI_Aint;.

Therefore, your approach for allocating your array is correct in using sizeof() instead of MPI_Type_size().

like image 122
Gilles Avatar answered Oct 21 '22 04:10

Gilles