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

Fix: standalone FindBLAS.cmake, mislink to global-visible lib #3623

Merged
merged 10 commits into from
Mar 5, 2024

Conversation

yizeyi18
Copy link

@yizeyi18 yizeyi18 commented Feb 21, 2024

Reminder

  • Have you linked an issue with this pull request?
  • Have you noticed possible changes of behavior below or in the linked issue?
  • Have you explained the changes of codes in core modules of ESolver, HSolver, ElecState, Hamilt, Operator or Psi? (ignore if not applicable)

Linked Issue

Fix #3589, #3497 (comment)

What's changed?

  • Added a check for include dir in FindELPA.cmake, to avoid using unspecified global visible header
  • Changed LibXC finding strategy to pkg-config first, to avoid linking to unspecified global visible lib
  • Made a standalone FindBLAS.cmake, removed incompatible blas in FindLAPACK.cmake

Any changes of core modules? (ignore if not applicable)

  • No.

@dyzheng dyzheng requested a review from caic99 February 22, 2024 07:11
@caic99
Copy link
Member

caic99 commented Feb 22, 2024

Hi @yizeyi18 ,
I wonder whether the name FindBLAS conflicts with the standard interface by CMake? And, is it possible to use that interface? Thanks!

@yizeyi18
Copy link
Author

Hi @yizeyi18 , I wonder whether the name FindBLAS conflicts with the standard interface by CMake? And, is it possible to use that interface? Thanks!

There is certainly conflict between cmake and abacus-builtin FindBLAS as well as FindLAPACK, and the builtin one would be executed. I 'm happy to try the cmake one, although I had not used it——a bunch of open source quantum chem package, e. g. CP2K, ScalES, Dalton, use their own FindBLAS/LAPACK/ScaLAPACK/math, I had no idea why.

@caic99
Copy link
Member

caic99 commented Feb 23, 2024

There is certainly conflict between cmake and abacus-builtin FindBLAS as well as FindLAPACK, and the builtin one would be executed. I 'm happy to try the cmake one, although I had not used it

Hi @yizeyi18 ,
I think it's OK to use our own config with a different name.

a bunch of open source quantum chem package, e. g. CP2K, ScalES, Dalton, use their own FindBLAS/LAPACK/ScaLAPACK/math, I had no idea why.

It provides certainty and also rooms to tweak, since the user does not always use the latest CMake module files.

@yizeyi18
Copy link
Author

@caic99 I made a demo using cmake's FindBLAS/FindLAPACK in https://github.com/yizeyi18/abacus-develop/tree/cmake-FindBLAS, may you take a look?
This demo simply deleted the builtin ones and added some variable wrapper, runs on my pc.

Using cmake FindBLAS/FindLAPACK
@yizeyi18
Copy link
Author

@caic99 The demo above got merged.
The intel check failed to init check container, could you help to restart it?

@yizeyi18 yizeyi18 mentioned this pull request Mar 2, 2024
14 tasks
@dyzheng dyzheng merged commit bfe2925 into deepmodeling:develop Mar 5, 2024
11 checks passed
@scott-5
Copy link

scott-5 commented Mar 15, 2024

hi, when I was compiling ABACUS v3.5.4 with option -DLibxc_DIR=~/libxc, it occurs an error message:

-- Checking for one of the modules 'libxc'
CMake Error at /home/user/miniconda3/share/cmake-3.26/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find Libxc (missing: Libxc_LINK_LIBRARIES Libxc_INCLUDE_DIRS)
Call Stack (most recent call first):
  /home/user/miniconda3/share/cmake-3.26/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
  cmake/FindLibxc.cmake:14 (find_package_handle_standard_args)
  CMakeLists.txt:549 (find_package)
-- Configuring incomplete, errors occurred! 

I try to provide -DLibxc_LINK_LIBRARIES=~/libxc/lib and Libxc_INCLUDE_DIRS=~/libxc/include, other error is that:

-- Checking for one of the modules 'libxc'
-- Found Libxc: ~/libxc/lib  
-- Found Libxc: version 
CMake Error at CMakeLists.txt:551 (if):
  if given arguments:
    "VERSION_LESS" "5.1.7"
  Unknown arguments specified

Now I don't know how to solve this problem.

@yizeyi18
Copy link
Author

@scott-5 Hi, may you show the content of ~/libxc/lib/pkgconfig/libxc.pc? From your provided output, CMake found a pkg-config and failed to get information from pkgconf file.

@scott-5
Copy link

scott-5 commented Mar 15, 2024

Of course.

prefix=/home/user/libxc                                                                                                                
exec_prefix=/home/user/libxc
libdir=${exec_prefix}/lib64
includedir=${prefix}/include

Name: libxc
Description: Library of exchange and correlation functionals to be used in DFT codes
Requires:
Version: 6.2.0
Libs: -L${libdir} -lxc
Cflags: -I${includedir}

(I made a mistake. In fact, only ~/libxc/lib64 exists and not ~/libxc/lib. So I change -DLibxc_LINK_LIBRARIES to ~/libxc/lib64. But they get the same error.

-- Found Libxc: ~/libxc/lib64  
-- Found Libxc: version 
CMake Error at CMakeLists.txt:551 (if):
  if given arguments:
    "VERSION_LESS" "5.1.7"
  Unknown arguments specified
```)

@yizeyi18
Copy link
Author

@scott-5 May you try changing ~/libxc in command line to ${HOME}/libxc or /home/user/libxc? I guess pkg-config may have problem facing non-absolute path.

@scott-5
Copy link

scott-5 commented Mar 15, 2024

It works. Thank you. Aha, but it is weird that using ~ for other options(like -DELPA_DIR=~/elpa) can be passed.

@yizeyi18
Copy link
Author

@scott-5 Ehh, that's a bit software-dependent.
elpa would not have something like ELPA_config.cmake in any of its redistribution, that makes it's possible to use some cmake's builtin function as its default routine, and judge if we fall into a wrong global visible dir. CMake function supports ~/ as $HOME/.
But Libxc may have Libxc._config.cmake; even worse, apt-installed libxc have it. While using cmake's builtin function, a apt-installed libxc would seize in some cases, e. g. using one libxc built with gnu toolchain. In regard of that, pkg-config method was choosed to be default, although it also have some problems.

@scott-5
Copy link

scott-5 commented Mar 15, 2024

Got it. Thanks again.

yizeyi18 added a commit to yizeyi18/abacus-develop that referenced this pull request Mar 21, 2024
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.

Misfinding ELPA Headers from Globle Visible Directory
4 participants