ohpc icon indicating copy to clipboard operation
ohpc copied to clipboard

caf wrapper in opencoarrays broken

Open LaHaine opened this issue 7 years ago • 4 comments

The script caf from opencoarrays-gnu8-openmpi3-ohpc-2.2.0-11.2.ohpc.1.3.6.x86_64 is broken, it tries to link to libcaf_mpi.a while only libcaf_mpi.so is available:

% module add gnu8 openmpi3 opencoarrays
% caf hw-coarray.f90
gfortran: error: /opt/ohpc/pub/libs/gnu8/openmpi3/opencoarrays/2.2.0/lib64/libcaf_mpi.a: No such file or directory
Error: comand:
   `/opt/ohpc/pub/compiler/gcc/8.2.0/bin/gfortran -I/opt/ohpc/pub/libs/gnu8/openmpi3/opencoarrays/2.2.0/include/OpenCoarrays-2.2.0_GNU-8.2.0 -fcoarray=lib -pthread -Wl,-rpath -Wl,/opt/ohpc/pub/mpi/openmpi3-gnu8/3.1.2/lib -Wl,--enable-new-dtags -pthread hw-coarray.f90 /opt/ohpc/pub/libs/gnu8/openmpi3/opencoarrays/2.2.0/lib64/libcaf_mpi.a /opt/ohpc/pub/mpi/openmpi3-gnu8/3.1.2/lib/libmpi_usempif08.so /opt/ohpc/pub/mpi/openmpi3-gnu8/3.1.2/lib/libmpi_usempi_ignore_tkr.so /opt/ohpc/pub/mpi/openmpi3-gnu8/3.1.2/lib/libmpi_mpifh.so /opt/ohpc/pub/mpi/openmpi3-gnu8/3.1.2/lib/libmpi.so`
failed to compile.
% ls /opt/ohpc/pub/libs/gnu8/openmpi3/opencoarrays/2.2.0/lib64
cmake  libcaf_mpi.so  libcaf_mpi.so.3

This is caused by the rm command in the spec file that deletes the static library ``rm *.a

LaHaine avatar Jan 07 '19 08:01 LaHaine

In general, I think shipping static libraries is frowned upon. The fedora build guidelines and the RHEL developer guide strongly discourage the use of static libraries. Looking at the Fedora opencoarrays package they don't ship the static library either. I was curious how they get around the issue, but from what I can tell caf has the same issue when using the Fedora RPMs. I was able to get something working[1], but I don't believe it's something that should be patched by the OpenHPC opencoarrays RPM.

It looks like the 2.4.0 release of opencoarrays has a version of caf that can use the static or dynamic library.

[1] Using the following diff

--- /opt/ohpc/pub/libs/gnu8/openmpi3/opencoarrays/2.2.0/bin/caf.orig    2019-01-07 11:35:01.921760140 -0800
+++ /opt/ohpc/pub/libs/gnu8/openmpi3/opencoarrays/2.2.0/bin/caf.updated 2019-01-07 11:40:19.727133432 -0800
@@ -86,7 +86,7 @@
 # __*AND*__ `pkg-config
 # --libs-only-L`
 mpi_compile_flags=(-pthread)
-caf_libs=(lib64/libcaf_mpi.a) # e.g. "libcaf_mpi" "libcaf_extensions",
+caf_libs=(lib64/libcaf_mpi.so) # e.g. "libcaf_mpi" "libcaf_extensions",
 # preferably full paths, but could be
 # combination of -L... and -lcaf_mpi...
 mpi_libs=( "/opt/ohpc/pub/mpi/openmpi3-gnu8/3.1.2/lib/libmpi_usempif08.so" "/opt/ohpc/pub/mpi/openmpi3-gnu8/3.1.2/lib/libmpi_usempi_ignore_tkr.so" "/opt/ohpc/pub/mpi/openmpi3-gnu8/3.1.2/lib/libmpi_mpifh.so" "/opt/ohpc/pub/mpi/openmpi3-gnu8/3.1.2/lib/libmpi.so") # e.g. `pkg-config --libs-only-l` or full paths

I was able to run the opencoarrays example

$ caf tally.f90 -o tally
$ cafrun -np 4 ./tally
 Test passed

amblakem avatar Jan 07 '19 19:01 amblakem

This is still broken in the 1.3.8 version of OpenHPC where opencoarrays was updated to 2.6.3. This is because the caf script is stupid and is using the wrong substitution attempt:

+ caf_added_libs+=("$(substitute_lib "${prefix%/}/${lib}")")
++ substitute_lib /opt/ohpc/pub/libs/gnu8/openmpi3/opencoarrays/2.6.3/lib64/libcaf_mpi.a
++ [[ -f /opt/ohpc/pub/libs/gnu8/openmpi3/opencoarrays/2.6.3/lib64/libcaf_mpi.a ]]
++ case "${1##*.}" in
++ for suff in so dylib dll
++ [[ -f /opt/ohpc/pub/libs/gnu8/openmpi3/opencoarrays/2.so ]]
++ for suff in so dylib dll
++ [[ -f /opt/ohpc/pub/libs/gnu8/openmpi3/opencoarrays/2.dylib ]]
++ for suff in so dylib dll
++ [[ -f /opt/ohpc/pub/libs/gnu8/openmpi3/opencoarrays/2.dll ]]
++ echo 'Failed to find static library /opt/ohpc/pub/libs/gnu8/openmpi3/opencoarrays/2.6.3/lib64/libcaf_mpi.a or shared library alternatives.'
Failed to find static library /opt/ohpc/pub/libs/gnu8/openmpi3/opencoarrays/2.6.3/lib64/libcaf_mpi.a or shared library alternatives.

See also https://github.com/sourceryinstitute/OpenCoarrays/issues/672

LaHaine avatar Jun 12 '19 12:06 LaHaine

In OpenHPC 1.3.9 the opencoarrays version is getting bumped to 2.8.0 (EG. #1067). I went ahead and installed the current OBS build and it seems like caf should be working once 1.3.9 goes live.

$ rpm -q opencoarrays-gnu8-openmpi3-ohpc
opencoarrays-gnu8-openmpi3-ohpc-2.8.0-4.2.ohpc.1.3.9.x86_64
$ which caf
/opt/ohpc/pub/libs/gnu8/openmpi3/opencoarrays/2.8.0/bin/caf
$ caf --version

OpenCoarrays Coarray Fortran Compiler Wrapper (caf version 2.8.0)
Copyright (C) 2015-2018 Sourcery Institute
Copyright (C) 2015-2018 Sourcery, Inc.

OpenCoarrays comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of OpenCoarrays under the terms of the
BSD 3-Clause License.  For more information about these matters, see
the file named LICENSE that is distributed with OpenCoarrays.

$ caf tally.f90 -o tally
$ cafrun -np 4 ./tally
 Test passed

amblakem avatar Oct 21 '19 15:10 amblakem