Skip to content
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

WIP: Experimental fpm build #753

Draft
wants to merge 31 commits into
base: main
Choose a base branch
from
Draft

WIP: Experimental fpm build #753

wants to merge 31 commits into from

Conversation

rouson
Copy link
Member

@rouson rouson commented Apr 23, 2022

coverage on master
Codecov branch

Summary of changes

  1. Greatly restructure/simplify the directory structure and remove unsupported legacy files, e.g., GASNet-1 layer.
  2. Add fpm manifist: fpm.toml.
  3. Add run-fpm.sh script for building with fpm.

To Do

  • Reconcile the file system restructuring with the windows-support branch.
  • Replace the install.sh with an installer based the [Caffeine] installer and the new run-fpm.sh script.

Rationale for changes

  1. The Fortran Package Manager has grown greatly in popularity and an fpm manifest so simple to maintain that it's reasonable to support two build systems.
  2. Homebrew has become sufficiently stable on macOS and Linux that it will be much easier to maintain a homebred-based installer than the current homegrown-package-management installer.

Additional info and certifications

This pull request (PR) is a:

  • Bug fix
  • Feature addition
  • Other, Please describe:

I certify that

  • I certify that:
    • I have reviewed and followed the contributing guidelines
    • I will wait at least 24 hours before self-approving the PR to give another
      OpenCoarrays developer a chance to review my proposed code
    • I have not introduced errant white space (no trailing white space or white space errors may
      be introduced)
    • I have added an explanation of what these changes do and why they should be included
    • I have checked to ensure there aren't other open Pull Requests for the same change
    • I have you written new tests for these changes
    • I have successfully tested these changes locally
    • I have commented any non-trivial, non-obvious code changes
    • The commits are logically atomic, self consistent and coherent
    • The commit messages follow best practices
    • Test coverage is maintained or increased after this is merged

Code coverage data

coverage on master

This commit eliminates the hardwired, separate build and run steps
in run-fpm.sh and instead passes an command-line arguments along
to fpm.  The following now works even with no prior build directory
present:

./run-fpm.sh --example hello
Copy link
Collaborator

@everythingfunctional everythingfunctional left a comment

Choose a reason for hiding this comment

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

I'm not sure I understand the CMake changes, but I made some comments on the install script.

Comment on lines +17 to +18
echo "For a non-interactive build with the 'yes' utility installed, execute"
echo "yes | ./install.sh"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think I'd include this. There are too many scenarios where this won't work. For example, if homebrew asks for sudo access.

Copy link
Member Author

Choose a reason for hiding this comment

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

@everythingfunctional I was going to remove this, but decided to keep it because it relates to a user request. I think I can borrow code from the original installer to cover the case in which sudo is required.

--c-flag "-DPREFIX_NAME=_gfortran_caf_ -DGCC_GE_7 -DGCC_GE_8" \
--flag "-fcoarray=lib"

CAF_VERSION=$(sed -n '/[0-9]\{1,\}\(\.[0-9]\{1,\}\)\{1,\}/{s/^\([^.]*\)\([0-9]\{1,\}\(\.[0-9]\{1,\}\)\{1,\}\)\(.*\)/\2/p;q;}' .VERSION)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This regular expression deserves an explanatory comment I think.

install.sh Outdated Show resolved Hide resolved
install.sh Outdated
if [ -z ${MPIFC+x} ] || [ -z ${MPICC+x} ]; then
ask_permission_to_install_homebrew_package "'mpifort' and 'mpicc'" "open-mpi"
exit_if_user_declines "mpifort and mpicc"
"$BREW" install gcc@$GCC_VERSION
Copy link
Collaborator

Choose a reason for hiding this comment

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

I get the following error from mpicc installed with homebrew on Linux

--------------------------------------------------------------------------
The Open MPI wrapper compiler was unable to find the specified compiler
gcc-5 in your PATH.

Note that this compiler was either specified at configure time or in
one of several possible environment variables.
--------------------------------------------------------------------------
<ERROR> Compilation failed for object " example_hello.f90.o "
<ERROR>stopping due to failed compilation

install.sh Outdated Show resolved Hide resolved
install.sh Outdated
Comment on lines 266 to 270
$FPM install \
--compiler $FPM_FC \
--c-compiler $FPM_CC \
--c-flag "-DPREFIX_NAME=_gfortran_caf_ -DGCC_GE_7 -DGCC_GE_8" \
--flag "-fcoarray=lib"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I get the following error from this on Linux.

 + /usr/bin/mpicc -c ./src/mpi-runtime/mpi_caf.c  -DPREFIX_NAME=_gfortran_caf_ -DGCC_GE_7 -DGCC_GE_8 -o build/mpifort_EA4E6F5B6A428512/opencoarrays/src_mpi-runtime_mpi_caf.c.o
./src/mpi-runtime/mpi_caf.c:46:10: fatal error: mpi.h: No such file or directory
   46 | #include <mpi.h>
      |          ^~~~~~~
compilation terminated.

install.sh Outdated
Comment on lines 278 to 279
sed -i '' -e "s/@Fortran_COMPILER@/$Fortran_COMPILER/g" "$PREFIX"/bin/caf
sed -i '' -e "s/@CAF_LIBS@/lib\/libopencoarrays.a/g" "$PREFIX"/bin/caf
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm pretty sure these sed commands have to have -i'' (without the space) or just -i on Linux.

run-fpm.sh Outdated
Comment on lines 7 to 12
fpm $@ \
--compiler `which mpifort` \
--c-compiler `which mpicc` \
--c-flag "-DPREFIX_NAME=_gfortran_caf_ -DGCC_GE_7 -DGCC_GE_8" \
--flag "-fcoarray=lib" \
--runner "mpirun -n 4"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is the idea that this is the fpm command to be used if one wants to make use of OpenCoarrays? If so, shouldn't there be a flag that points to the installed opencoarrays library?, or is the idea that it would be listed in the project's fpm.toml file and thus downloaded and compiled by fpm with those flags?

Comment on lines +26 to +28
image_numbers = [(merge(0, me, me/=i), i = 1, ni)]
call co_sum(image_numbers)
result_ = assert_that(all(image_numbers == [(i, i = 1, ni)]) .and. size(image_numbers)>0, "correct image set")
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a "clever trick", and as such deserves better explanation. There might be a way to make the code more clear, but I'd settle for an explanatory comment.

Base automatically changed from windows-support to main May 7, 2022 02:25
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.

None yet

2 participants