[MPI3 Fortran] Serious problem with alignment of MPI_DOUBLE_PRECISION

William Gropp wgropp at illinois.edu
Wed Sep 28 02:44:08 CDT 2011


This entire problem comes from the natural but mistaken idea that the  
MPI library should assign some default padding when creating a  
datatype.  This is a bad idea because the alignment rules can depend  
on compiler switches or other compiler-specific choices; for example,  
some compilers allow the user to select between always 8 byte  
alignment, leading to structures that might have gaps but permit the  
uniform use of faster load operations or 4 byte alignment, but at a  
potential performance cost.  In other words, even for a single  
compiler, there need not be a unique choice of extent, and hence this  
problem is insoluble.  Further, it is not necessary - the user can  
either create the datatype with the appropriate extent (by using  
MPI_UB) or resize it appropriately (with MPI_TYPE_CREATE_RESIZED since  
MPI 2.0).  Rather than continue to get this wrong, I recommend simply  
telling the user not to assume that the MPI library can always divine  
how the compiler is going to chose to pad a derived type or struct.   
We can add an advice to users here that explains the problem and  
recommends using the existing MPI features to handle this problem.   
This is better coding and will affect few users.

Bill

William Gropp
Director, Parallel Computing Institute
Deputy Director for Research
Institute for Advanced Computing Applications and Technologies
Paul and Cynthia Saylor Professor of Computer Science
University of Illinois Urbana-Champaign






More information about the mpiwg-fortran mailing list