Skip to content

Update Fortran MPI interface: "use mpi" instead of "include mpif.h"#46

Merged
danielhollas merged 2 commits intomasterfrom
use-mpi
Nov 9, 2020
Merged

Update Fortran MPI interface: "use mpi" instead of "include mpif.h"#46
danielhollas merged 2 commits intomasterfrom
use-mpi

Conversation

@danielhollas
Copy link
Copy Markdown
Contributor

@danielhollas danielhollas commented Nov 6, 2020

Closes #33. This change uncovered a couple of bugs we had in various MPI calls, fortunately nothing critical.

As an unfortunate side-effect, we now need to build our own MPICH and OpenMPI in Github Actions, for each GFortran version,
since use mpi does not allow using different GFortran versions for MPI compiler and ABIN. That is unfortunate, but probably a good thing to do anyway. The MPICH and OpenMPI builds take a long time, but we cache them so it's not so bad (GA cache should last at least a week).

As part of this, I also did a bit more cleanup of Makefile and TEST/test.sh.

@danielhollas danielhollas self-assigned this Nov 6, 2020
@danielhollas danielhollas changed the title Use mpi "use mpi" instead of "include mpif.h" Nov 6, 2020
@codecov
Copy link
Copy Markdown

codecov Bot commented Nov 6, 2020

Codecov Report

Merging #46 (63f522e) into master (b16aa08) will not change coverage.
The diff coverage is 87.17%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #46   +/-   ##
=======================================
  Coverage   54.67%   54.67%           
=======================================
  Files          36       36           
  Lines        5536     5536           
=======================================
  Hits         3027     3027           
  Misses       2509     2509           
Impacted Files Coverage Δ
abin.F90 72.59% <ø> (ø)
force_cp2k.F90 0.00% <ø> (ø)
force_tera.F90 0.00% <0.00%> (ø)
force_terash.F90 0.00% <ø> (ø)
init.F90 59.23% <57.14%> (ø)
remd.F90 83.63% <100.00%> (ø)

@danielhollas danielhollas force-pushed the use-mpi branch 12 times, most recently from 033c723 to 404b2cd Compare November 6, 2020 23:34
Comment thread WATERMODELS/Makefile
@@ -1,5 +1,5 @@
CXX = g++
CXXFLAGS = -g -O2 -Wall
CXXFLAGS = -O2 -Wall -std=c++11
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was overlooked in the last PR. :-(

Comment thread force_tera.F90
end if

timer = MPI_WTIME(ierr)
timer = MPI_WTIME()
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MPI_WTIME() does not return any errors. This kind of error can be caught by using use mpi instead of include mpif.h.

Comment thread remd.F90
call MPI_recv(fyc_new ,size1*size2, MPI_DOUBLE_PRECISION, dest, tag_fy, MPI_COMM_WORLD, status, ierr )
call MPI_recv(fzc_new, size1*size2, MPI_DOUBLE_PRECISION, dest, tag_fz, MPI_COMM_WORLD, status, ierr )
call MPI_recv(irank, 1, MPI_INTEGER, dest, tag_fz, MPI_COMM_WORLD, status, ierr )
call MPI_Send(x, size1*size2, MPI_DOUBLE_PRECISION, dest, tag_x, MPI_COMM_WORLD, ierr)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here again, the status parameter should not be there in MPI_Send(). Hopefully, this did not introduce any practical problem in the REMD code, since we're not checking the ierr variable anyway (but we really should).

Comment thread TESTS/test.sh

# TODO: This is extremely brittle, we should at least
# verify that the number of parameters is correct!
if [[ $# -ne 7 ]]; then
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes in test.sh and Makefile do not actually pertain to MPI, but they were a nice cleanup.

Comment thread Makefile
.cpp.o:
$(CXX) $(CXXLAGS) $(DFLAGS) -c $<
%.o: %.cpp
$(CXX) $(CXXFLAGS) $(DFLAGS) -c $<
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, previous PR had a typo, CXXLAGS -> CXXFLAGS

Comment thread Makefile

.cpp.o:
$(CXX) $(CXXLAGS) $(DFLAGS) -c $<
%.o: %.cpp
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread Makefile
testclean :
/bin/bash TESTS/test.sh ${BIN} clean ${MPI} ${FFTW} $(PLUMED) ${CP2K}
testclean:
/bin/bash TESTS/test.sh ${BIN} $(TEST) ${MPI} ${FFTW} $(PLUMED) ${CP2K} clean
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now more consistent.

@danielhollas danielhollas requested a review from suchanj November 7, 2020 00:26
@danielhollas danielhollas marked this pull request as ready for review November 7, 2020 00:26
@danielhollas danielhollas changed the title "use mpi" instead of "include mpif.h" Update Fortran MPI interface: "use mpi" instead of "include mpif.h" Nov 7, 2020
Closes #33.
We might be able to use 'use mpi_f08', which is recommended,
but need to test whether it's supported by all compiler versions
in our CI suite. It might also require some code changes.

See https://www.mpi-forum.org/docs/mpi-3.1/mpi31-report/node408.htm

As an unfortunate side-effect, we now need to build our own
MPICH and OpenMPI in Github Actions, for each GFortran version,
since use mpi does not allow using different GFortran versions for
MPI compiler and ABIN. Probably a good thing to do anyway.
The MPICH and OpenMPI builds take a long time,
but we cache them so it's not so bad
(GA cache should last at least a week).
@danielhollas danielhollas merged commit 12ff538 into master Nov 9, 2020
@danielhollas danielhollas deleted the use-mpi branch November 9, 2020 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use 'use mpi' instead of 'include mpif.h'

2 participants