问题描述:

I am using cray-mpich/7.4.0. When I do

 printf("Size:%d",sizeof(MPI_UINT64_T));

It print 4 instead of 8. Why is that? The cluster machine is 64 bit for sure.

I have tried this with openmpi/1.10.2 on another cluster and that prints 8.

网友答案:

Previous answer is right. But you really should use MPI_Type_size.

MPI_Type_size(MPI_UINT64_T,&tsize);
fprintf(stderr,"Size:%d, MPI_Type_size:%d\n",sizeof(MPI_UINT64_T),tsize);

which shows the difference between the size of the MPI_Datatype and what you really want to know, the size of the UINT64 type.

Size:4, MPI_Type_size:8
网友答案:

MPI_UINT64_T is of type MPI_Datatype. The exact implementation of MPI_Datatype is not specified. For MPICH based MPI implementations (such as Cray's), that's s is usually an int, whereas in OpenMPI it's a pointer to a struct.

In any case, your printf prints the sizeof(MPI_Datatype), which has no relation to the actual bytesize of the type it stands for.

If you want to check whether the pointer (address) size in your system is 32 or 64 bit, you could print sizeof(void*) or any other pointer type.

相关阅读:
Top