Cytnx icon indicating copy to clipboard operation
Cytnx copied to clipboard

Refactor cmake

Open pcchen opened this issue 1 year ago • 5 comments

I create this issue to document information needed to refactor cmake related material.

Minimum requirements to build cytnx. Here is the incomplete list.

For C++

  • boost
  • blas/lapack. Effectively, we only support MKL and OpenBLAS. Maybe we only officially support these two.

For python wrapper

  • python
  • pybind11

For GPU support

  • CUDA
  • cuTENSOR
  • cuQuantum

For OpenMP

Some references

  • https://cliutils.gitlab.io/modern-cmake/README.html

pcchen avatar Sep 15 '24 15:09 pcchen

CMP0167 https://cmake.org/cmake/help/latest/policy/CMP0167.html

The FindBoost module is removed in cmake 3.30.

find_package(Boost CONFIG) finds the upstream package directly, without the find module.

Examples

  • https://cliutils.gitlab.io/modern-cmake/chapters/packages/Boost.html

pcchen avatar Sep 15 '24 15:09 pcchen

CMP0146 https://cmake.org/cmake/help/latest/policy/CMP0146.html

The FindCUDA module is removed in cmake 3.27.

Examples

  • https://cliutils.gitlab.io/modern-cmake/chapters/packages/CUDA.html

pcchen avatar Sep 15 '24 15:09 pcchen

OpenMP examples

  • https://cliutils.gitlab.io/modern-cmake/chapters/packages/OpenMP.html

pcchen avatar Sep 15 '24 15:09 pcchen

CUDA Quantum and CMake

pcchen avatar Sep 15 '24 15:09 pcchen

OpenBLAS

If libopenblas is installed in /opt/OpenBLAS/

On Linux, after setting

export C_INCLUDE_PATH=/opt/OpenBLAS/include
export CPLUS_INCLUDE_PATH=/opt/OpenBLAS/include
export LD_LIBRARY_PATH=/opt/OpenBLAS/lib

cmake can find OpenBLAS and one can compile cytnx.

On MacOS (Apple silicon), still cmake cannot find OpenBLAS.

On Linux and MacOS, one can use CMAKE_PREFIX_PATH.

CMAKE_PREFIX_PATH=/opt/OpenBLAS cmake ..

then cmake can find OpenBLAS. But it will fail to compile because it cannot find lapacke.h. One still have to set the include_path as above. Then it will compile OK.

==> Next thing is to try to use submodules to handle OpenBLAS.

pcchen avatar Sep 15 '24 15:09 pcchen