Compilation issue with MPICH and GCC
Currently a number of MPI_Waitall
make use of MPI_STATUSES_IGNORE
rather than passing an array of MPI_Status
. This works for OpenMPI (see https://www.open-mpi.org/doc/v4.1/man3/MPI_Waitall.3.php) but may encounter issues with MPICH as the definition of MPI_STATUSES_IGNORE
differs:
- OpenMPI:
#define MPI_STATUSES_IGNORE ((MPI_Status *) 0)
- MPICH:
#define MPI_STATUSES_IGNORE (MPI_Status *) 1
With at least the GNU compiler this will trigger the -Werror=stringop-overflow=
error:
proxy.c: In function 'proxy_tags_exchange':
proxy.c:174:7: error: 'MPI_Waitall' accessing 20 bytes in a region of size 0 [-Werror=stringop-overflow=]
174 | if (MPI_Waitall(num_reqs_out, reqs_out, MPI_STATUSES_IGNORE) != MPI_SUCCESS)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
proxy.c:174:7: note: referencing argument 3 of type 'MPI_Status[0]'
In file included from proxy.c:34:
/opt/cray/pe/mpich/8.1.19/ofi/gnu/9.1/include/mpi.h:966:5: note: in a call to function 'MPI_Waitall'
966 | int MPI_Waitall(int count, MPI_Request array_of_requests[], MPI_Status array_of_statuses[]) MPICH_API_PUBLIC;
| ^~~~~~~~~~~
This impacts src/engine_strays.c
, src/proxy.c
and src/exchange_structs.c
. A simple solution would be to actually pass a MPI_Status status_array[5 * engine_maxproxies]
to the Waitall. It does allocate some small amount of resources but would ensure the code compiles everywhere no matter the definition of MPI_STATUSES_IGNORE
.