Folks, i recently had to solve a tricky issue that involves alignment of fortran types.
the attached program can be used and ran on two tasks in order to evidence the issue. if gfortran is used (to build both openmpi and the test case), then the test is successful if ifort (Intel compiler) is used (to build both openmpi and the test case), then the test fails. this was mentionned in the openmpi users list quite a while ago at http://www.open-mpi.org/community/lists/users/2010/07/13857.php the root cause is gfortran considers mpi_real8 must be aligned on 8 bytes whereas ifort considers mpi_real8 does not need to be aligned. consequently, the derived data type ddt is built with an extent of 16 (gfortran) or 12 (ifort) in order to determine the type aligment, configure builds a simple program with c and fortran that involves common. the default behaviour of ifort is to : - *not* align common - align records (aka the real8_int fortran type) hence the mismatch and the failure. the default behaviour of gfortran is to align both common and records, hence the success. /* i "extracted" from configure conftest.c and conftestf.f that can be used to build the conftest binary. conftest will store the alignment in the conftestval file */ i am wondering how this should be dealt by OpenMPI. here is a non exhaustive list of option : a) do nothing, this is not related to openmpi, and even if we do something, application built with -noalign will break. b) advise ifort users to configure with FCFLAGS="-align zcommons" since it is likely this is what they want c) advise ifort users to build their application with "-noalign" to be on the safe side (modulo a performance penalty) d) update OpenMPI so fortran type alignment is determined via a record instead of a common if fortran >= 90 is used (so far, i could not find any drawback in doing that) e) advise ifort users to create ddt with MPI_DOUBLE instead of mpi_real8 (because this works (!), i did not dig to find out why) f) other ... any thoughts ? Cheers, Gilles
bcast_types.f90
Description: Binary data
conftestf.f
Description: Binary data
#include <stdio.h> #include <stdlib.h> #ifdef __cplusplus extern "C" { #endif void align_(char *w, char *x, char *y, char *z) { unsigned long aw, ax, ay, az; FILE *f=fopen("conftestval", "w"); if (!f) exit(1); aw = (unsigned long) w; ax = (unsigned long) x; ay = (unsigned long) y; az = (unsigned long) z; if (! ((aw%16)||(ax%16)||(ay%16)||(az%16))) fprintf(f, "%d\n", 16); else if (! ((aw%12)||(ax%12)||(ay%12)||(az%12))) fprintf(f, "%d\n", 12); else if (! ((aw%8)||(ax%8)||(ay%8)||(az%8))) fprintf(f, "%d\n", 8); else if (! ((aw%4)||(ax%4)||(ay%4)||(az%4))) fprintf(f, "%d\n", 4); else if (! ((aw%2)||(ax%2)||(ay%2)||(az%2))) fprintf(f, "%d\n", 2); else fprintf(f, "%d\n", 1); fclose(f); } #ifdef __cplusplus } #endif