Quantcast
Channel: Intel® Software - Intel® oneAPI Math Kernel Library & Intel® Math Kernel Library
Viewing all articles
Browse latest Browse all 3005

Different BLAS performance between CMake dynamic and manuly static link

$
0
0

I tried to compile my program by using CMake at first and my CMakeLists file is as the following.

 

cmake_minimum_required(VERSION 3.11)
project(LMMNET LANGUAGES CXX)

include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)

set(CMAKE_CXX_FLAGS "-O2 -msse -msse2")
#set(CMAKE_CXX_COMPILER "icpc")

set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)

find_package(Boost 1.58.0 COMPONENTS program_options REQUIRED)
find_package(BLAS REQUIRED)
find_package(LAPACK REQUIRED)

target_link_libraries(dataIO PUBLIC ${Boost_LIBRARIES})
target_link_libraries(DataMatrix PUBLIC DataUtils
                                        ${Boost_LIBRARIES}
                                        ${LAPACK_LIBRARIES})
target_link_libraries(LMMNET PUBLIC dataIO
                                    DataMatrix)

 

I can link the Intel Math Kernel Library correctly and the program works well. However, I find it is interesting that when I link the Intel Math Kernel Library following the official instruction as 

-Wl,--start-group ${MKLROOT}/lib/intel64/libmkl_intel_ilp64.a ${MKLROOT}/lib/intel64/libmkl_gnu_thread.a ${MKLROOT}/lib/intel64/libmkl_core.a -Wl,--end-group -lgomp -lpthread -lm -ldl.

The performance of my program is much better than ever. My program even run faster four times than before. (I just do the matrix-matrix multiplication). Why it comes for that?


Viewing all articles
Browse latest Browse all 3005

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>