Conversation
examples/LAPACK/CMakeLists.txt
Outdated
find_package(cblas CONFIG REQUIRED) | ||
|
||
add_executable(foo foo.cpp) | ||
target_include_directories(foo PRIVATE ${CBLAS_INCLUDE_DIRS}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a property of imported target
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then I need to patch the sources. Could you make a fork of https://github.com/Reference-LAPACK/lapack so that we can add a hunter branch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
examples/LAPACK/CMakeLists.txt
Outdated
find_package(LAPACK CONFIG REQUIRED) | ||
|
||
|
||
find_package(cblas CONFIG REQUIRED) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a little bit confusing. Are we using LAPACK or cblas? According to the C++ code we depends only on cblas, meaning that find_package(LAPACK ...)
not needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think clbas is using lapack/blas and is just a C wrapper for the libraries. I included cblas only to get a C interface for the example. I wasn't able to directly use the lapack/blas libraries
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it possible to build cblas only for the example? Then there isn't a conflict and the user can add a buildflag for his/her project when cblas is really needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this pull request is about adding lapack
I expect at least one simple example with hunter_add_package(lapack)
+ find_package(lapack ...)
+ #include <lapack.h>
without any other instructions. If there are other important variants of using this package they should be added separately, e.g. examples/lapack-cblas
. In those examples we can use custom local config.cmake
with custom CMAKE_ARGS
for enabling/disabling components.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the install of lapack (without CBLAS) provides only libraries, no headers. So there is no lapack.h
to include.
To have an example with c-interface I added cblas. I'll move the current example to examples/LAPACK-CBLAS
but I don't know how to create an example just using liblapack.a
and libblas.a
edit: example path
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
provides only libraries, no headers
How they are expected to be used!? 😕 Probably that's because of it's written in Fortran (?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the libs are used directly and the users create the appropriate headers themselves. See https://github.com/jlblancoc/suitesparse-metis-for-windows/blob/master/SuiteSparse/CHOLMOD/Include/cholmod_blas.h for an example
I think that CBLAS and LAPACKE came later as an easier way to use the libraries
cmake/projects/LAPACK/hunter.cmake
Outdated
hunter_cmake_args( | ||
LAPACK | ||
CMAKE_ARGS | ||
BUILD_SHARED_LIBS=ON # build as shared libs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By default libraries should be static.
examples/LAPACK/foo.cpp
Outdated
@@ -0,0 +1,14 @@ | |||
#include <iostream> // std::cout | |||
#include <cblas.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we are conflicting with OpenBLAS package here:
Do you know how they are related? Is it two implementation of the same standard?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know. I think they are solving the same problem in slightly different ways. The creation of cblas can be turned off. I only added it to use it in the example. For suitesparse cblas is not used.
All the different blas, OpenBlas, ATLAS, LAPACK, LAPACKE are confusing me. I know suitesparse can use BLAS and LAPACK. About the others I don't know
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I compile OpenBLAS on Linux, it provides a Lapack as well if gfortran is detected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't cross compile the hunter OpenBlas with mingw-w64. Does it work natively on Windows?
[ 75%] Performing build step for 'OpenBLAS'
/bin/sh: 1: ./getarch: not found
make[3]: *** [config.h] Error 127
OpenBLAS: Detecting fortran compiler failed. Cannot compile LAPACK. Only compile BLAS.
gemv.c: In function 'sgemv_':
gemv.c:223:29: error: 'GEMM_MULTITHREAD_THRESHOLD' undeclared (first use in this function)
if ( 1L * m * n < 2304L * GEMM_MULTITHREAD_THRESHOLD )
^
gemv.c:223:29: note: each undeclared identifier is reported only once for each function it appears in
In file included from ../common.h:747:0,
from gemv.c:40:
../common_stackalloc.h:32:46: warning: unused variable 'stack_check' [-Wunused-variable]
#define STACK_ALLOC_PROTECT_SET volatile int stack_check = 0x7fc01234;
^
../common_stackalloc.h:56:3: note: in expansion of macro 'STACK_ALLOC_PROTECT_SET'
STACK_ALLOC_PROTECT_SET \
^
gemv.c:219:3: note: in expansion of macro 'STACK_ALLOC'
STACK_ALLOC(buffer_size, FLOAT, buffer);
^
Makefile:841: recipe for target 'sgemv.obj' failed
make[4]: *** [sgemv.obj] Error 1
Makefile:126: recipe for target 'libs' failed
make[3]: *** [libs] Error 1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it work natively on Windows?
There are no working toolchains on Windows in pkg.openblas
:
I have updated the configuration and added a local config file for the LAPACK example. But when building the example no
|
sent a patch upstream to add the include directories to the target also added the patch on top of v3.7.1 and tagged v3.7.1-p0 the example |
We could add a components schema to activate CBLAS or LAPACKE (c-interfaces for BLAS and LAPACK) If a user just wants the libraries he can use
if he wants the CBLAS interface
and for both optional c interfaces
This would be easier for the user than creating a local how much work would this be? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because the cmake arguments are not passed on to the LAPACK build (the local config.cmake is not working)
Build with HUNTER_STATUS_DEBUG=ON
. Are you sure local config.cmake
used?
We could add a components schema
how much work would this be?
Pretty much. CMake itself should be patched here. I'm not aware of "CMake components" feature supported for CMake projects. Components used in Hunter for Qt and Boost libraries. They are not using CMake as a build system.
examples/LAPACK-CBLAS/CMakeLists.txt
Outdated
cmake_minimum_required(VERSION 3.0) | ||
|
||
|
||
set(TESTING_CONFIG_OPT FILEPATH "${CMAKE_SOURCE_DIR}/config.cmake") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer CMAKE_CURRENT_LIST_DIR
:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, thx for the Info :)
yes I'm sure the |
examples/LAPACK-CBLAS/config.cmake
Outdated
@@ -0,0 +1,3 @@ | |||
include(hunter_cmake_args) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed
examples/LAPACK-CBLAS/config.cmake
Outdated
@@ -0,0 +1,3 @@ | |||
include(hunter_cmake_args) | |||
|
|||
hunter_cmake_args(LAPACK CMAKE_ARGS CBLAS=ON) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be hunter_config
, not hunter_cmake_args
:
that fixed it 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we still need examples/LAPACK
. Start with simple hunter_add_package(LAPACK)
without find_package
and any targets. We can add more info later.
cmake/projects/LAPACK/hunter.cmake
Outdated
hunter_cmake_args( | ||
LAPACK | ||
CMAKE_ARGS | ||
#BUILD_SHARED_LIBS=ON # build as shared libs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove unused commented options.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
the PR Reference-LAPACK/lapack#170 was merged, CBLAS should now work without any additional patchset. I'd like to recreate the tag v3.7.1-p0 on top of the current master and remove the custom branch hunter_v3.7.1. What are your thoughts on it? |
Merged now.
I think it make sense to keep the |
nice, that was fast :) ff-only was not possible, did a what is left to do before merge? I'd like to squash the commits before that please |
Please add
|
- add LAPACK example building targets blas and lapack - add LAPACK-CBLAS example using local cmake config file
added and squashed |
I've been trying to use this lapack package with ceres-solver, but when building the examples (or any other binary) I get missing fortran functions. The LAPACK config of static libraries does not properly propagate the dependency to gfortran and quadmath. When I build blas and lapack as dynamic libraries then the fortran libraries get resolved. With the statically built blas and lapack I can make it work if I add the following to the ceres-solver project
how do we add this dependency to the static blas and lapack libs? |
I don't have experience with Fortran so I'm not sure I understand all details.
Sounds like you need to update |
I think the runtime dependency should be propagated by the cmake-configure file of LAPACK, otherwise all projects using LAPACK need to be modified. But I don't know how |
I'm not sure that I understand enough all the details of the issue to give any advice here. |
I think for LAPACK and BLAS it is better to create a dynamic lib (so or dll). Then the consuming projects don't need to be updated. For Windows it should be possible to let a MSVC project consume the |
We can start with that as a workaround and use |
the hunter-examples for LAPACK and SuiteSparse build fine with static libs. They don't seem to use fortran provided functions (maybe because they are very basic examples) The projects LAPACK and SuiteSparse define -fPIC. So they could be linked into another dynamic library. I think that |
looks good 👍 |
sudo apt install gfortran
dependency for suitesparse as stated in Issue #855