Cmake Lapack

The CMake option -DKokkosENABLELIBRT=on or the makefile setting KOKKOSUSETPLS=librt enables the use of a more accurate timer mechanism on many Unix-like platforms for internal profiling. The CMake option -DKokkosENABLEDEBUG=on or the makefile setting KOKKOSDEBUG=yes enables printing of run-time debugging information that can be useful. Export CMAKE PREFIX PATH=/path/to/lapack Now the installation of the custom GROMACS-LS package Installing LAPACK with CMake $ tar -zxvf gromacs-4.5.5-ls-5.0.tar.gz $ cd gromacs-4.5.5-ls-5.0 $ mkdir build $ cd build $ ccmake./ Once the ccmakedialog comes up, press c to begin the initial con guration, and then modify the CMAKE INSTALL PREFIX. The recipe is valid with CMake version 3.5 (and higher) and has been tested on GNU/Linux, macOS, and Windows. Many numerical codes rely heavily on matrix and vector operations. Think for example of matrix-vector and matrix-matrix products, the solution of linear system of equations, the calculation of eigenvalues and eigenvectors or singular. (1) Use the right BLAS and LAPACK libraries. Determine where your BLAS and LAPACK libraries are. If the default 'make' does not find them, use 'make BLAS=-lmyblaslibraryhere LAPACK=-lmylapackgoeshere' (2) Install Intel's Threading Building Blocks (TBB). This is optionally used by SuiteSparseQR. The CMake option -DKokkosENABLELIBRT=on or the makefile setting KOKKOSUSETPLS=librt enables the use of a more accurate timer mechanism on many Unix-like platforms for internal profiling. The CMake option -DKokkosENABLEDEBUG=on or the makefile setting KOKKOSDEBUG=yes enables printing of run-time debugging information that can be useful.

I tried to convert the following litte problem to Cmake, but whatever I tried I could not solve the problem.

I downloaded and instaleed Lapack using Mingw-64 which created the following directories/filess using Cmake

C:/lapack/build/include … and c:lapackbuildlib

The file main.c can be downloaded from https://gist.github.com/xianyi/6930656

I I run

[C:temp]gcc -o main.exe main.o -Lc:/lapack/build/lib -llapack -llapacke -lcblas -lblas -ltmglib -lgfortran -lquadmath

[C:temp]main

11.000000 -9.000000 5.000000 -9.000000 21.000000 -1.000000 5.000000 -1.000000 3.00000

Everythin works fine

The last two libraries are Mingw-64 libraries

I tried to convert the gcc statement to cmake but whatever I tried I get different error messages.

May be you can help me

Thank you for your efforts

Chris Nabold

It is possible to configure and build HANDE using CMake. At least version 3.6of CMake is required. You can get CMake either via your package manager or bydownloading an executable tarball from hereUnpacking and adding to your PATH will do the trick:

Cmake

where we have assumed the tarball was downloaded in the $HOME/Softwaredirectory.

Once dependencies are installed, you can configure HANDE either by running thecmake executable directly:

or by using the frontend Python script cmakeconfig.py:

The result of using the two methods is exactly the same: a subdirectorybuild will be created containing the build system.Using the frontend script however results in more compact configure lines.

Configuration options¶

Building of HANDE can be tweaked in various ways passing options to thefrontend script (or CMake directly).The help menu for the cmakeconfig.py script shows the available options:

These options are translated to CMake native options. For more detailed information onHANDE-specific compile-time settings, see Compile-time settings. The following listis a translation guide between the frontend script and “bare” CMake:

  • --fc=FC/-DCMAKE_Fortran_COMPILER=FC. To set the Fortran compiler. Defaultis gfortran.

  • --extra-fc-flags='list-of-flags'/-DEXTRA_FCFLAGS='list-of-flags'. To set additional flagsfor the Fortran compiler.

  • --cc=CC/-DCMAKE_C_COMPILER=CC. To set the C compiler. Default is gcc.

  • --extra-cc-flags='list-of-flags'/-DEXTRA_CFLAGS='list-of-flags'. To set additional flagsfor the C compiler.

  • --python=INTERP/-DPYTHON_INTERPRETER=INTERP. To set the Python interpreter. Thedefault is empty, so that CMake will attempt to find a suitable version.

  • --lua=LUA/-DLUA_ROOT=LUA. To set the Lua installation to use. Minimumrequired version of Lua is 5.3. The default is empty, so that CMake will attempt tofind a suitable version.See below for Lua detection issues.

    Warning

    CMake will not pick up Lua from a nonstandard location, even though it is onpath (any or all of CPATH, LIBRARY_PATH, LD_LIBRARY_PATH,PATH)

  • --mpi/-DENABLE_MPI=ON. Enables MPI parallelization. CMake willattempt to find a suitable implementation of MPI and set the compilersaccordingly.

    Warning

    To use a specific MPI implementation, pass the appropriate MPI compilerwrappers as arguments to --fc (-DCMAKE_Fortran_COMPILER) and--cc (-DCMAKE_C_COMPILER)For example, for the Intel MPI compiler wrappers mpiifort and mpiicc use./cmakeconfig.py--mpi--fc=mpiifort--cc=mpiicc.

  • --mpi-with-scalapack/-DENABLE_SCALAPACK=OFF. Enables linking toScaLAPACK. This requires that MPI is enabled and that a ScaLAPACKimplementation is available.

  • --omp/-DENABLE_OPENMP=ON. Enables OpenMP parallelization. CMake willcheck which flags are supported by your choice of compilers and add them tothe compiler flags.

  • --blas=auto/-DENABLE_BLAS=auto. Triggers autodetection of BLAS libraries.See below for math libraries detection issues.

  • --lapack=auto/-DENABLE_LAPACK=auto. Triggers autodetection of BLAS libraries.See below for math libraries detection issues.

  • --mkl=VALUE/-DMKL_FLAG=VALUE. Sets the -mkl=VALUE flag for the Intelcompiler and linker. Valid values are sequential, parallel, cluster, oroff, with off being the default.

    Warning

    Passing this option overrides automatic detection of math libraries

  • --scalapack='link-line'/-DSCALAPACK_LIBRARIES='link-line'. Link line for ScaLAPACK libraries.If using Intel MKL, CMake will be able to correctly locate and set these foryou. Use this option in case you run into trouble with detecting ScaLAPACKand prefer setting the link line explicitly.

  • --blacs=openmpi/-DBLACS_IMPLEMENTATION=openmpi. Sets the implementation ofBLACS for the Intel MKL ScaLAPACK libraries. Valid values are openmpi,intelmpi and sgimpt, with openmpi being the default.

  • --explicit-libs='link-line'/-DEXPLICIT_LIBS='link-line'. Sets explicit linker options forextra libraries to be linked in.See below for math libraries detection issues.

  • --dsfmt-mexp=VALUE/-DHANDE_DSFMT_MEXP=VALUE. Set exponent for the period of theMersenne Twister (MT) random number generator (RNG). Valid values are 521,1279, 2203, 4253, 11213, 19937, 44497, 86243, 1322049, and 216091. with 19937being the default.

  • --det-size=VALUE/-DHANDE_DET_SIZE=VALUE. Set the integer length for representingSlater determinants as bit strings. Valid values are 32 and 64, with 32being the default.

  • --pop-size=VALUE/-DHANDE_POP_SIZE=VALUE. Set the integer length for storingwalker populations. Valid values are 32 and 64, with 32being the default.

  • --exe-name=NAME/-DHANDE_EXE_NAME=NAME. Set the name for the generated HANDE executable.The default is hande.cmake.x. The executable is copied to the bindirectory in the root of the project and symlinked to hande.x. Passingthe executable name will let you preserve executables generated withdifferent configuration settings.

  • --hdf5=<HDF5>/-DENABLE_HDF5=<ON/OFF>-DHDF5_ROOT=<HDF5>.Enables use of HDF5 and specifies the path to the HDF5 installation to use.By default, use of HDF5 is turned on. At least HDF5 1.8.15 is required andwith Fortran 2003 bindings enabled. CMake will search for a suitable versionof HDF5 and check that all necessary components are available. In addition,CMake will check the compatibility of the chosen HDF5 implementation andFortran compiler.See below for HDF5 detection issues.

  • --uuid=<ON/OFF>/-DENABLE_UUID=<ON/OFF>. Enables use of the UUID library.By default, this is turned on.

  • --single/-DENABLE_SINGLE_PRECISION=ON. Enables use of singleprecision, where appropriate.

  • --backtrace/-DENABLE_BACKTRACE=ON. Enables backtrace functionality.

  • --popcnt/-DENABLE_INTRINSIC_POPCNT=ON. Enables usage of popcntintrinsic (requires hardware support)

  • --type=debug/-DCMAKE_BUILD_TYPE=Debug. Switches build type. Validvalues are debug, release, releasewithdebinfo and minsizerel.The default is a debug build.

  • --cmake-options='-DTHIS-DTHAT'. Sets options to be forwarded as-is toCMake.

Lapack

Installation¶

It is possible to install HANDE either running outside the build directory:

or from within the build directory:

By default, CMake will set the install prefix to /usr/local and you mighthence not have permissions to successfully install. The install prefix can beset via the --prefix option to the frontend script or, equivalently,passing the desired path to CMake via the CMAKE_INSTALL_PREFIX variable.The HANDE executable and static library will be installed to the bin andlib (lib64 on 64-bit systems) subdirectories of the install prefix.

Note

It might be advisable to install pyhande to the same prefix as the HANDEexecutable. Refer to pyhande’s READMEfor detailed instructions.

Assuming the install prefix to have been set to $HOME/Software/hande, theinstall tree will thus look as follows:

The `DESTDIR mechanism <https://www.gnu.org/prep/standards/html_node/DESTDIR.html>`_ can be used toadjust the install location:

will result in the following install tree:

CMake compilation issues¶

When dependencies are not in standard search paths, CMake needs to be nudgedand pointed in the right direction. This can be done directly using either cmake orcmakeconfig.py; the equivalent commands for both are given below but only one should beused.

  • Detection of math libraries is usually the trickiest part. The CMake mathdetection scripts shipped with HANDE rely on the MATH_ROOT environmentvariable being set to point to the root of the math libraries installationyou want to use.The detection scripts will attempt to provide a link line for math librariesbased on the search order in the CMake variable MATH_LIB_SEARCH_ORDER.By default, Intel MKL is searched for first, using the MKLROOTenvironment variable.If math detection fails, libraries can be set manually:

  • Lua in a non-standard directory. Exporting the root directory of the Luainstallation as LUA_ROOT (or LUA_DIR) or directly passing it as an option:

  • HDF5 in a non-standard directory. Exporting the root directory of the HDF5installation as HDF5_ROOT os directly passing it as an option:

    CMake will check that the chosen HDF5 library and Fortran compiler arecompatible. If this test fails, configuration will abort. The output from thecompatibility file will be saved to the log fileHDF5_HAS_Fortran2003-test.log in the build directory.Note that is is possible to completely deactivate usage of HDF5:

Mkl Lapack

Cmake Lapack

Cmake Lapack 2

For compiler- and library-specific issues, see Compiler and library issues.

Compiling with MPI¶

To compile with MPI it is necessary to pass both the --mpi optionand the correct compiler wrappers with the --cc and --fc:

CMake can in fact botch the identification of the compiler wrappers and MPIlibraries, a mismatch that will result in linker errors.Here are some examples of configuration lines. In all cases, remember to setthe MATH_ROOT variable to point to the location of the math libraries:

Lapack Windows 64

  • OpenMPI with GNU compilers.

  • OpenMPI with Intel compilers.

  • IntelMPI with Intel compiler.

  • OpenMPI with GNU compilers and OpenBLAS ScaLAPACK.

  • OpenMPI with Intel compilers and MKL ScaLAPACK. The math detection scriptwill use the OpenMPI implementation of BLACS by default.

  • IntelMPI with Intel compiler and MKL ScaLAPACK. In this case we need to tellCMake what BLACS implementation to use with ScaLAPACK.