Fix BLAS++ and LAPACK++ build#903
Fix BLAS++ and LAPACK++ build#903weslleyspereira wants to merge 10 commits intoReference-LAPACK:masterfrom
Conversation
|
I have two other concerns related to my last message:
|
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #903 +/- ##
========================================
Coverage 0.00% 0.00%
========================================
Files 1918 1918
Lines 188653 188757 +104
========================================
- Misses 188653 188757 +104
☔ View full report in Codecov by Sentry. |
2020.10.02. You had me worried for a minute. I think that was just what was available at the time. Perhaps we could use a We can update the release version, I'm just not excited about updating LAPACK every time that BLAS++ and LAPACK++ are updated. |
|
Sorry for the "2010", @mgates3. Not intentional. I fixed my message above. So, I have an idea on how we could make it easy to
Ok. Thanks. We could at least try to update these dependencies whenever we release LAPACK, or whenever BLAS++ and LAPACK++ have a major update regarding the wrappers. I am also not too excited to update LAPACK every time that BLAS++ and LAPACK++ are updated. I was just surprised it was using a release from almost 3 years ago. |
|
Now, about my second bullet: |
95bd970 to
35c78b7
Compare
66905e9 to
680cfd8
Compare
|
I updated this PR so that it solves #905. It should be ready for review. Note that the changes do not add tests for the flag |
mgates3
left a comment
There was a problem hiding this comment.
I coded up some changes in this commit. These work on my Mac with this configuration:
cmake -D BLAS++=true -D LAPACK++=true \
-D USE_OPTIMIZED_BLAS=true -D BLA_VENDOR=Apple \
-D CMAKE_INSTALL_PREFIX=${HOME}/install-lapack -B build
cd build
make
make install
Haven't tried other configurations or elsewhere yet.
| lapackpp | ||
| GIT_REPOSITORY https://github.com/icl-utk-edu/lapackpp | ||
| GIT_TAG 62680a16a9aba2a426e3d089dd13e18bfd140c74 # v2023.08.25 | ||
| ) |
There was a problem hiding this comment.
May want blaspp 91dd418fa910498cc03dee397826099914cc3185
and lapackpp 88088c33cd9467475e8f139f42d158620f11e64d
which have the fixes for Fortran strlen.
We will likely do a SLATE / BLAS++ / LAPACK++ bug fix release this month, but perhaps for that just update LAPACK right before the SC23 release.
| # TODO: This is incomplete. Fill in the other cases. | ||
| set(BLAS_Fortran_LIB "") | ||
| endif() | ||
| endif() |
There was a problem hiding this comment.
Is this when using Reference BLAS, is that why it checks NOT BLAS_FOUND?
When I tried to compile, linking with liblapack.a also needed -lgfortran, but since I used optimized BLAS, BLAS_FOUND was true and BLAS_Fortran_LIB was empty.
BTW, setting it to empty in the else case is redundant with set above if.
CMakeLists.txt
Outdated
| -D CMAKE_INSTALL_PREFIX="${blaspp_BINARY_DIR}" | ||
| -D CMAKE_INSTALL_LIBDIR="${PROJECT_BINARY_DIR}/lib" | ||
| -D blas_libraries_cached="" | ||
| -D lapack_libraries_cached="" |
There was a problem hiding this comment.
Why was it needed to set blas_libraries_cached and lapack_libraries_cached? These are internal variables to the BLAS++ and LAPACK++ CMake scripts and subject to change.
Is this from having 2 COMMAND cmake above in the add_custom_command? Better to have only 1 COMMAND cmake so it searches correctly the first time.
(The additional COMMAND cmake --build below seems fine.)
There was a problem hiding this comment.
I don't think I need to set blas_libraries_cached and lapack_libraries_cached even if we configure cmake 2x. I needed it at some point of writing the PR, but I can't reproduce it anymore.
CMakeLists.txt
Outdated
| COMMAND ${CMAKE_COMMAND} | ||
| -B "${lapackpp_BINARY_DIR}" | ||
| -D LAPACK_LIBRARIES="${LAPACK_LIBRARIES}" ) | ||
| endif() |
There was a problem hiding this comment.
As above, this can be simplified.
CMakeLists.txt
Outdated
| -B "${lapackpp_BINARY_DIR}" | ||
| -D CMAKE_INSTALL_PREFIX="${lapackpp_BINARY_DIR}" | ||
| -D CMAKE_INSTALL_LIBDIR="${PROJECT_BINARY_DIR}/lib" | ||
| -D lapack_libraries_cached="" |
There was a problem hiding this comment.
As above, shouldn't set internal variables.
CMakeLists.txt
Outdated
| # Setup remaining configuration options and installation | ||
| add_custom_command( OUTPUT lapackpp-cmd APPEND | ||
| COMMAND ${CMAKE_COMMAND} | ||
| -B "${lapackpp_BINARY_DIR}" |
There was a problem hiding this comment.
For me, LAPACK++ couldn't find BLAS++. I found it easier to install them in the same directory. Maybe setting CMAKE_PREFIX_PATH would also work.
CMakeLists.txt
Outdated
| FILES_MATCHING REGEX "liblapackpp.(a|so)$" | ||
| DIRECTORY "${LAPACK_BINARY_DIR}/lib/" | ||
| DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
| FILES_MATCHING REGEX "liblapackpp.(a|so)$" |
There was a problem hiding this comment.
There could be other lapackpp files. Matching on just lapackpp would capture everything. For instance:
-- Installing: /.../lapack/build4/lib/cmake/lapackpp/lapackppTargets.cmake
-- Installing: /.../lapack/build4/lib/cmake/lapackpp/lapackppTargets-noconfig.cmake
-- Installing: /.../lapack/build4/lib/cmake/lapackpp/lapackppConfig.cmake
-- Installing: /.../lapack/build4/lib/cmake/lapackpp/lapackppConfigVersion.cmake
CMakeLists.txt
Outdated
| "${CMAKE_CURRENT_BINARY_DIR}/lib/lapackpp/lapackppConfigVersion.cmake" | ||
| FILES "${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/lapackpp/lapackppConfig.cmake" | ||
| "${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/lapackpp/lapackppConfigVersion.cmake" | ||
| DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/" |
There was a problem hiding this comment.
There are a couple other files; see above for easier fix.
CMakeLists.txt
Outdated
| -D BLAS_LIBRARIES="${BLAS_LIBRARIES}" | ||
| -D LAPACK_LIBRARIES="${LAPACK_LIBRARIES}" ) | ||
| endif() | ||
| endif() |
There was a problem hiding this comment.
These 4 add_custom_command blocks are quite redundant. May I suggest setting some variables to have one 1 instance? See my top-level review comment for suggestion.
There was a problem hiding this comment.
The redundancy is because we cannot use CMake generator expressions (e.g., $<TARGET_FILE:${LAPACKLIB}>) to set CMake variables at configuration time. See https://stackoverflow.com/questions/51353110/how-do-i-output-the-result-of-a-generator-expression-in-cmake. There is certainly a better way to do this, but I couldn't figure it out.
CMakeLists.txt
Outdated
| ) | ||
|
|
||
| endif() | ||
| if (BLAS++) |
There was a problem hiding this comment.
LAPACK++ requires BLAS++, so as above, I think this should be if (BLAS++ OR LAPACK++).
There was a problem hiding this comment.
With cmake -D LAPACK++=on .., this will build BLAS++ and LAPACK++, but doesn't install libblaspp.a. Changing to if (BLAS++ or LAPACK++) fixes the issue. Can be merged with if block below (line 650).
|
Even with the changes from this commit. I am still having trouble to use the flag LAPACK++. See icl-utk-edu/lapackpp#50 |
00f51ca to
fc569f4
Compare
|
The AppVeyor script needs some change. I will open an issue for that. This PR is ready to be merged. |
|
@mgates3, could you review the current stage of this PR. I think this is ready to merge. Thanks! |
9ded2af to
b50109c
Compare
mgates3
left a comment
There was a problem hiding this comment.
Here's the patch that worked for me:
sh leconte lapack> git diff
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 17609c05d..89db6a866 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -633,21 +633,19 @@ install(FILES
if (LAPACK++)
install(
- DIRECTORY "${LAPACK_BINARY_DIR}/lib/"
+ DIRECTORY "${LAPACK_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}/"
DESTINATION ${CMAKE_INSTALL_LIBDIR}
FILES_MATCHING REGEX "lapackpp"
)
endif()
-if (BLAS++)
+if (BLAS++ OR LAPACK++)
install(
- DIRECTORY "${LAPACK_BINARY_DIR}/lib/"
+ DIRECTORY "${LAPACK_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}/"
DESTINATION ${CMAKE_INSTALL_LIBDIR}
FILES_MATCHING REGEX "blaspp"
)
-endif()
-if (BLAS++ OR LAPACK++)
install(
DIRECTORY "${LAPACK_BINARY_DIR}/include/"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
Otherwise, looks good. I tested on macOS with GNU compilers and OpenBLAS, and on Linux (Redhat) with GNU compilers, Intel MKL, and CUDA.
One minor issue, on Linux it said
-- Build files have been written to: /home/mgates/repos/lapack/build2/_deps/lapackpp-build
gmake[3]: warning: jobserver unavailable: using -j1. Add '+' to parent make rule.
and then run make in serial instead of parallel, so it was rather slow. Not a big deal.
CMakeLists.txt
Outdated
| DIRECTORY "${LAPACK_BINARY_DIR}/lib/" | ||
| DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
| FILES_MATCHING REGEX "libblaspp.(a|so)$" | ||
| DIRECTORY "${LAPACK_BINARY_DIR}/lib/" |
There was a problem hiding this comment.
On Linux, it put them in ${LAPACK_BINARY_DIR}/lib64, so it find libblaspp.a and liblapackpp.a to install:
sh leconte build2> pwd
/home/mgates/repos/lapack/build2
sh leconte build2> ls lib lib64
lib:
liblapack.a
lib64:
cmake libblaspp.a liblapackpp.a
sh leconte build2> ls ~/install-test/lib64/
cmake liblapack.a pkgconfig
On macOS, it put them in ${LAPACK_BINARY_DIR}/lib, and everything worked (with previously mentioned fix about if (BLAS++ or LAPACK++)):
pangolin lapack/build3> pwd
/Users/mgates/Documents/lapack/build3
pangolin lapack/build3> ls lib
cmake/ libblaspp.a liblapack.a liblapackpp.a
pangolin lapack/build3> ls ~/install-test/lib/
cmake/ libblaspp.a liblapack.a liblapackpp.a pkgconfig/
CMakeLists.txt
Outdated
| FILES "${CMAKE_CURRENT_BINARY_DIR}/lib/lapackpp/lapackppConfig.cmake" | ||
| "${CMAKE_CURRENT_BINARY_DIR}/lib/lapackpp/lapackppConfigVersion.cmake" | ||
| DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/" | ||
| DIRECTORY "${LAPACK_BINARY_DIR}/lib/" |
There was a problem hiding this comment.
Same issue as below; use ${CMAKE_INSTALL_LIBDIR}.
|
@weslleyspereira Any plans to fix this branch up and merge? |
I can do that. Should I wait for icl-utk-edu/blaspp#91 and icl-utk-edu/lapackpp#71? |
7f2c622 to
80be947
Compare
85b55f9 to
a5c5d4d
Compare
|
Couldn't make BLAS++ and LAPACK++ link with the correct LAPACK library when using shared libs. See:
Interestingly, static libraries are correctly linked. See: https://github.com/Reference-LAPACK/lapack/actions/runs/14112347619/job/39534062287 (end of build phase) |
In the current LAPACK master, building with
BLAS++flagONcauses the following error in CMake:There is some issue in BLAS++ (https://bitbucket.org/icl/lapackpp/downloads/lapackpp-2020.10.02.tar.gz) so that it can't find
testsweeper.hh. I can give more details about my system configuration.The point is: we actually don't need to build the BLAS++ tests to obtain
libblaspp. Thus, this PR solves the issue by adding-Dbuild_tests=OFFto the configuration step of BLAS++ and LAPACK++ in LAPACK.Closes #905.