Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork56.4k
Fix compile against lapack-3.10.0 - part 1#21114
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
dwardor commentedNov 24, 2021
Fixes#21116 |
alalek commentedNov 24, 2021
This change breaks Linux builds - LAPACK becomes disabled. |
msva commentedDec 2, 2021
actually, it fixes linux builds. On systems with modern versions of lapack. |
devurandom commentedDec 2, 2021
I assume for this to be accepted it has to work with both old and modern versions of LAPACK? Could this be done by checking for both #ifdefOPENCV_USE_OLD_LAPACK# defineLAPACK_sposv_ sposv_#endif ? |
devurandom commentedDec 2, 2021
msva commentedDec 2, 2021
@dwardor could you please add checks (to stay compatible with older lapack versions)? And also merge another PR (the part2) here, as, actually, it seems to be related to the same exact issue, so no need to split it to another PR, IMO. |
vpisarev commentedDec 3, 2021
@dwardor, thank you for the patch! I'm sure, it's useful, but I think we need to do it in a proper way:
then you should define or not OPENCV_USE_LAPACK_PREFIX, depending on the version. |
dwardor commentedDec 4, 2021
Just pushed a new version that should be more generic per vpisarev's recommendations
This still works on gentoo with lapack 3.10.0 by configuring OPENCV_USE_LAPACK_PREFIX=ON via ebuild Tried but failed to figure out how to test lapack version in OpenCVFindLAPACK.cmake (am a cmake noob). |
CMakeLists.txt Outdated
| OCV_OPTION(ENABLE_PYLINT"Add target with Pylint checks" (BUILD_DOCSOR BUILD_EXAMPLES) IF (NOTCMAKE_CROSSCOMPILINGANDNOT APPLE_FRAMEWORK) ) | ||
| OCV_OPTION(ENABLE_FLAKE8"Add target with Python flake8 checker" (BUILD_DOCSOR BUILD_EXAMPLES) IF (NOTCMAKE_CROSSCOMPILINGANDNOT APPLE_FRAMEWORK) ) | ||
| OCV_OPTION(OPENCV_USE_LAPACK_PREFIX"Use LAPACK_ prefix for function calls with lapack >= 3.9.1."OFF) |
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.
What do you think about setting it to "ON" based on detected lapack version (to ease downstream maintenance work)?
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.
Sounds great to me! Just haven't figured out how to do it
dwardor commentedDec 5, 2021
This autodetects LAPACK_VERSION, at least on my gentoo box, and activates OPENCV_USE_LAPACK_PREFIX automatically... I've only used LAPACK_FUNC to the function that strictly need it... My gut feeling is :
|
dwardor commentedDec 5, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Been looking through all lapack-release versions... and c/c++ interfaces appeared back in 3.4.0 : So just using LAPACK_xxxx in opencv source and letting the preprocessor macros do their job is the universal solution for anything above lapack-3.4.0. Am I right in saying no one is compiling opencv vs. anything <3.4.0 as it contains no c/c++ interface ? LAPACK_NAME(lcname,UCNAME) was replaced by LAPACK_GLOBAL(lcname,UCNAME) in lapack-3.4.1 |
alalek left a comment
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.
Thank you for update!
Please take a look on comments below.
cmake/OpenCVFindLAPACK.cmake Outdated
| set(BLA_STATIC 1) | ||
| endif() | ||
| find_package(LAPACK) | ||
| find_package(LAPACK CONFIG) |
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.
CONFIG
Why do we need to block CMake's LAPACK module?
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 just use CONFIG so as to have access to LAPACK_VERSION. If I don't add CONFIG LAPACK_VERSION is undefined.
cmake/OpenCVFindLAPACK.cmake Outdated
| #ifdef OPENCV_USE_LAPACK_PREFIX | ||
| #define LAPACK_FUNC(f) LAPACK_##f | ||
| #else | ||
| #define LAPACK_FUNC(f) f##_ |
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.
LAPACK_FUNC
Please useOPENCV_ /OCV_ prefix.
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.
OK
cmake/OpenCVFindLAPACK.cmake Outdated
| endif() | ||
| list(APPEND _lapack_content" | ||
| #ifdef OPENCV_USE_LAPACK_PREFIX | ||
| #define LAPACK_FUNC(f) LAPACK_##f |
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.
-DOPENCV_USE_LAPACK_PREFIX=LAPACK_
It makes sense to define prefix in CMake.
Moreover, we don't need global compiler definition at all.
It is a generated file. So generate this content through CMake conditions.
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.
Ok will remove the global alltogether and generate based in CMake conditions
dwardor commentedDec 20, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I'd prefer we use#21291 instead of this as per#21114 (comment) Update :#21291 is dead due to imcompatibility with Accelerate LAPACK implementation so this pullrequest seems the way to move forward |
dwardor commentedDec 21, 2021
Only issue seems to be Mac build (just a warning ?)...@alalek I don't know how to debug this as I don't have a Mac... |
Fix compilation against lapack >= 3.9.1 and 3.10.0 while not breaking older versionsOpenCVFindLAPACK.cmake & CMakeLists.txt: determine OPENCV_USE_LAPACK_PREFIX from LAPACK_VERSIONhal_internal.cpp : Only apply LAPACK_FUNC to functions whose number of inputs depends on LAPACK_FORTRAN_STR_LEN in lapack >= 3.9.1lapack_check.cpp : remove LAPACK_FUNC which is not OK as function are not used with input parameters (so lapack.h preprocessing of "LAPACK_xxxx(...)" is not applicable with lapack >= 3.9.1If not removed lapack_check fails so LAPACK is deactivated in build (not want we want)use OCV_ prefix and don't use Global, instead generate OCV_LAPACK_FUNC depending on CMake ConditionsRemove CONFIG from find_package(LAPACK) and use LAPACK_GLOBAL and LAPACK_NAME to figure out if using netlib's reference LAPACK implementation and how to #define OCV_LAPACK_FUNC(f)
alalek left a comment
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.
dwardor commentedDec 22, 2021
Thanks for the various pointers on the way. @alalek will this also make it into opencv:4.x ? |
alalek commentedDec 22, 2021
Changes to 4.x will be propagated automatically during the next "Merge-3.4" PR:https://github.com/opencv/opencv/wiki/Branches |
Uh oh!
There was an error while loading.Please reload this page.
TODO:
update builders configuration (to resolve Mac builder report) if it is not caused byremovedCONFIGusage in find_packageCONFIGPull Request Readiness Checklist
See details athttps://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.