dev-cafe / autocmake

CMake plugin composer.
http://autocmake.org
BSD 3-Clause "New" or "Revised" License
42 stars 18 forks source link

Test fc_blas not linking MKL library #45

Closed miroi closed 9 years ago

miroi commented 9 years ago

On my Linux machine with Intel/MKL installed it founds MKL as the first library:

milias@login.grid.umb.sk:~/Work/qch/software/software_projects/autocmake_devel/autocmake_miroi/test/fc_blas/.setup.py --fc=ifort --int64  build_ifort_i8_mkl
FC=ifort cmake -DEXTRA_FCFLAGS="''" -DENABLE_64BIT_INTEGERS=True -DENABLE_BLAS=auto -DENABLE_LAPACK=auto -DMKL_FLAG=off -DMATH_LIB_SEARCH_ORDER="MKL;ESSL;ATLAS;ACML;SYSTEM_NATIVE" -DBLAS_LANG=Fortran -DLAPACK_LANG=Fortran -DCMAKE_BUILD_TYPE=release -G "Unix Makefiles" None /home/milias/Work/qch/software/software_projects/autocmake_devel/autocmake_miroi/test/fc_blas

-- The C compiler identification is GNU 4.4.7
-- The CXX compiler identification is GNU 4.4.7
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- The Fortran compiler identification is Intel
-- Check for working Fortran compiler: /mnt/apps/intel/composer_xe_2013_sp1.1.106/bin/intel64/ifort
-- Check for working Fortran compiler: /mnt/apps/intel/composer_xe_2013_sp1.1.106/bin/intel64/ifort  -- works
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Checking whether /mnt/apps/intel/composer_xe_2013_sp1.1.106/bin/intel64/ifort supports Fortran 90
-- Checking whether /mnt/apps/intel/composer_xe_2013_sp1.1.106/bin/intel64/ifort supports Fortran 90 -- yes
-- BLAS will be searched for based on MKLROOT=/mnt/apps/intel/composer_xe_2013_sp1.1.106/mkl
-- Searching for BLAS using search order MKL;ESSL;ATLAS;ACML;SYSTEM_NATIVE
-- Found BLAS: MKL (-Wl,--start-group;/mnt/apps/intel/composer_xe_2013_sp1.1.106/mkl/lib/intel64/libmkl_intel_ilp64.so;/mnt/apps/intel/composer_xe_2013_sp1.1.106/mkl/lib/intel64/libmkl_intel_thread.so;/mnt/apps/intel/composer_xe_2013_sp1.1.106/mkl/lib/intel64/libmkl_core.so;/usr/lib64/libpthread.so;/usr/lib64/libm.so;-openmp;-Wl,--end-group)
-- LAPACK will be searched for based on MKLROOT=/mnt/apps/intel/composer_xe_2013_sp1.1.106/mkl
-- Searching for LAPACK using search order MKL;ESSL;ATLAS;ACML;SYSTEM_NATIVE
-- Found LAPACK: MKL (-Wl,--start-group;/mnt/apps/intel/composer_xe_2013_sp1.1.106/mkl/lib/intel64/libmkl_lapack95_ilp64.a;/mnt/apps/intel/composer_xe_2013_sp1.1.106/mkl/lib/intel64/libmkl_intel_ilp64.so;-openmp;-Wl,--end-group)
-- Configuring done
-- Generating done
-- Build files have been written to: /home/milias/Work/qch/software/software_projects/autocmake_devel/autocmake_miroi/test/fc_blas/build_ifort_i8_mkl

   configure step is done
   now you need to compile the sources:
   $ cd build_ifort_i8_mkl
   $ make

but it does not link it:

milias@login.grid.umb.sk:~/Work/qch/software/software_projects/autocmake_devel/autocmake_miroi/test/fc_blas/build_ifort_i8_mkl/.make VERBOSE=1
/usr/bin/cmake -H/home/milias/Work/qch/software/software_projects/autocmake_devel/autocmake_miroi/test/fc_blas -B/home/milias/Work/qch/software/software_projects/autocmake_devel/autocmake_miroi/test/fc_blas/build_ifort_i8_mkl --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/milias/Work/qch/software/software_projects/autocmake_devel/autocmake_miroi/test/fc_blas/build_ifort_i8_mkl/CMakeFiles /home/milias/Work/qch/software/software_projects/autocmake_devel/autocmake_miroi/test/fc_blas/build_ifort_i8_mkl/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory `/home/milias/Work/qch/software/software_projects/autocmake_devel/autocmake_miroi/test/fc_blas/build_ifort_i8_mkl'
make -f src/CMakeFiles/example.dir/build.make src/CMakeFiles/example.dir/depend
make[2]: Entering directory `/home/milias/Work/qch/software/software_projects/autocmake_devel/autocmake_miroi/test/fc_blas/build_ifort_i8_mkl'
cd /home/milias/Work/qch/software/software_projects/autocmake_devel/autocmake_miroi/test/fc_blas/build_ifort_i8_mkl && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/milias/Work/qch/software/software_projects/autocmake_devel/autocmake_miroi/test/fc_blas /home/milias/Work/qch/software/software_projects/autocmake_devel/autocmake_miroi/test/fc_blas/src /home/milias/Work/qch/software/software_projects/autocmake_devel/autocmake_miroi/test/fc_blas/build_ifort_i8_mkl /home/milias/Work/qch/software/software_projects/autocmake_devel/autocmake_miroi/test/fc_blas/build_ifort_i8_mkl/src /home/milias/Work/qch/software/software_projects/autocmake_devel/autocmake_miroi/test/fc_blas/build_ifort_i8_mkl/src/CMakeFiles/example.dir/DependInfo.cmake --color=
make[2]: Leaving directory `/home/milias/Work/qch/software/software_projects/autocmake_devel/autocmake_miroi/test/fc_blas/build_ifort_i8_mkl'
make -f src/CMakeFiles/example.dir/build.make src/CMakeFiles/example.dir/requires
make[2]: Entering directory `/home/milias/Work/qch/software/software_projects/autocmake_devel/autocmake_miroi/test/fc_blas/build_ifort_i8_mkl'
make[2]: Nothing to be done for `src/CMakeFiles/example.dir/requires'.
make[2]: Leaving directory `/home/milias/Work/qch/software/software_projects/autocmake_devel/autocmake_miroi/test/fc_blas/build_ifort_i8_mkl'
make -f src/CMakeFiles/example.dir/build.make src/CMakeFiles/example.dir/build
make[2]: Entering directory `/home/milias/Work/qch/software/software_projects/autocmake_devel/autocmake_miroi/test/fc_blas/build_ifort_i8_mkl'
/usr/bin/cmake -E cmake_progress_report /home/milias/Work/qch/software/software_projects/autocmake_devel/autocmake_miroi/test/fc_blas/build_ifort_i8_mkl/CMakeFiles 1
[100%] Building Fortran object src/CMakeFiles/example.dir/example.f90.o
cd /home/milias/Work/qch/software/software_projects/autocmake_devel/autocmake_miroi/test/fc_blas/build_ifort_i8_mkl/src && /mnt/apps/intel/composer_xe_2013_sp1.1.106/bin/intel64/ifort  -DHAVE_MKL_BLAS -DHAVE_MKL_LAPACK -i8 -O3 -module ../modules -I/home/milias/Work/qch/software/software_projects/autocmake_devel/autocmake_miroi/test/fc_blas/build_ifort_i8_mkl/modules    -c /home/milias/Work/qch/software/software_projects/autocmake_devel/autocmake_miroi/test/fc_blas/src/example.f90 -o CMakeFiles/example.dir/example.f90.o
Linking Fortran executable ../bin/example
cd /home/milias/Work/qch/software/software_projects/autocmake_devel/autocmake_miroi/test/fc_blas/build_ifort_i8_mkl/src && /usr/bin/cmake -E cmake_link_script CMakeFiles/example.dir/link.txt --verbose=1
/mnt/apps/intel/composer_xe_2013_sp1.1.106/bin/intel64/ifort       -i8 -O3 CMakeFiles/example.dir/example.f90.o  -o ../bin/example -i_dynamic -lblas 
make[2]: Leaving directory `/home/milias/Work/qch/software/software_projects/autocmake_devel/autocmake_miroi/test/fc_blas/build_ifort_i8_mkl'
/usr/bin/cmake -E cmake_progress_report /home/milias/Work/qch/software/software_projects/autocmake_devel/autocmake_miroi/test/fc_blas/build_ifort_i8_mkl/CMakeFiles  1
[100%] Built target example
make[1]: Leaving directory `/home/milias/Work/qch/software/software_projects/autocmake_devel/autocmake_miroi/test/fc_blas/build_ifort_i8_mkl'
/usr/bin/cmake -E cmake_progress_start /home/milias/Work/qch/software/software_projects/autocmake_devel/autocmake_miroi/test/fc_blas/build_ifort_i8_mkl/CMakeFiles 0
milias@login.grid.umb.sk:~/Work/qch/software/software_projects/autocmake_devel/autocmake_miroi/test/fc_blas/build_ifort_i8_mkl/.

what is linked is the GNU blas (-lblas ), see also

milias@login.grid.umb.sk:~/Work/qch/software/software_projects/autocmake_devel/autocmake_miroi/test/fc_blas/build_ifort_i8_mkl/.ldd bin/example 
        linux-vdso.so.1 =>  (0x00007fff2d72f000)
        libblas.so.3 => /usr/lib64/libblas.so.3 (0x00007ffd9037f000)
        libifport.so.5 => /mnt/apps/intel/composer_xe_2013_sp1.1.106/compiler/lib/intel64/libifport.so.5 (0x00007ffd9014f000)
        libifcore.so.5 => /mnt/apps/intel/composer_xe_2013_sp1.1.106/compiler/lib/intel64/libifcore.so.5 (0x00007ffd8fe0f000)
        libimf.so => /mnt/apps/intel/composer_xe_2013_sp1.1.106/compiler/lib/intel64/libimf.so (0x00007ffd8f948000)
        libsvml.so => /mnt/apps/intel/composer_xe_2013_sp1.1.106/compiler/lib/intel64/libsvml.so (0x00007ffd8ed50000)
        libm.so.6 => /lib64/libm.so.6 (0x00007ffd8eacc000)
        libintlc.so.5 => /mnt/apps/intel/composer_xe_2013_sp1.1.106/compiler/lib/intel64/libintlc.so.5 (0x00007ffd8e876000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007ffd8e658000)
        libc.so.6 => /lib64/libc.so.6 (0x00007ffd8e2c4000)
        libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007ffd8e0ae000)
        libdl.so.2 => /lib64/libdl.so.2 (0x00007ffd8dea9000)
        libgfortran.so.3 => /usr/lib64/libgfortran.so.3 (0x00007ffd8dbb7000)
        /lib64/ld-linux-x86-64.so.2 (0x00007ffd905ef000)
milias@login.grid.umb.sk:~/Work/qch/software/software_projects/autocmake_devel/autocmake_miroi/test/fc_blas/build_ifort_i8_mkl/.
miroi commented 9 years ago

The same problem without "--int64". Also I provided the PR for minor fix for Ifort (https://github.com/scisoft/autocmake/pull/46).

miroi commented 9 years ago

Ah,

the autocmake/test/fc_blas/src/CMakeFiles.txt in has default linking of GNU blas:

if(BLAS_FOUND)
    add_executable(example example.f90)
    target_link_libraries(example blas)
else()
    message(FATAL_ERROR "BLAS library not found for the test fc_blas!")
endif()

This has to be rewritten for more intelligent linking of the available BLAS library.

bast commented 9 years ago

Aha. Yes. I will correct it.

miroi commented 9 years ago

Fine; the same correction would be needed for the future fc_lapack test as well.