New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch to mpi_f08 #2486
Switch to mpi_f08 #2486
Conversation
I am not really sure why Intel or MPICH have these issues. There are not too many changes from CP2K side. |
I suspect a bug on either MPICH or compiler side. I will consult the developers. Furthermore, there is a bug in the Intel implementation which does not allow to pass non-contiguous arrays which is allowed to the MPI standard. I will also open a bug report there. |
Do we actually pass non-contiguous arrays to MPI? Generally, I think it would be good if we started using |
There is one spot. I forgot which one. This triggered the Intel compiler. What we could do is to add the contiguous keyword if we do not use the mpi_f08. |
Yes, I think the best solution would be to refactor that one spot an then simply declare all arrays in our wrapper as CONTIGUOUS. This should spare us a lot of hassle and produce more performance portable code. |
For the record, I've already spent some time to add CONTIGUOUS keyword in DBCSR... |
I added the contiguous keyword wherever possible except from the non-blocking routines where I used the is_contiguous function to prevent accidental programming mistakes (see commit message). |
Oh, good thinking! As an alternative we could use |
That does not work if the array has a constant size or the caller has to artificially use an allocatable instead. |
The issue with MPICH looks to me like a bug on the library or the compiler-side. If there are no complaints, I will just add a commit to enforce the use of the old MPI interface with MPICH in our install script and merge. |
Looks like this GCC bug which I found via Stackoverflow. |
I don't know. It feels like this could still trip up a lot of people. Maybe we make it opt-in for now via a |
For legacy/debugging
In case of non-blocking communication, we check contiguity with is_contiguous to prevent accidental copies from caller-site. If we were to call a non-blocking routine with a non-contiguous array and enforce contiguity in the interface, the compiler would make the array contiguous before calling the routine and copy it back afterwards such that MPI would not copy the result into the actual array and might even throw a segfault because the contiguous copy of the non-contiguous array might have already been cleaned up.
Just for reference: #1030 |
This PR replaces the old Fortran 90-style MPI module with its Fortran 2008 counterpart. This solves a bunch of issues with the old Fortran wrapper.
Because the mpi_f08 module is not always available or is buggy with certain combinations of compilers and libraries, the use of the new module has to be actively enabled by adding the preprocessor flag
-D__MPI_F08
.It will be used automatically via the toolchain if OpenMPI or IntelMPI is used. Probably, a few adjustments on the Dashboard will be necessary later.