My situation:
Requirements:
To reproduce:
Run CMake GUI
GPU_TARGET=Pascal
(My Card: GeForce GTX 1070 Compute Capability: 6.1) MKLROOT=D:/Program Files (x86)/IntelSWTools/parallel_studio_xe_2019.0.045/compilers_and_libraries_2019/windows/mkl
(as instructed in the README-Windows) LAPACK_LIBRARIES: use https://software.intel.com/en-us/articles/intel-mkl-link-line-advisor to determine
D:/Program Files (x86)/IntelSWTools/parallel_studio_xe_2019.0.045/compilers_and_libraries_2019/windows/mkl/lib/intel64_win/mkl_intel_lp64.lib;D:/Program Files (x86)/IntelSWTools/parallel_studio_xe_2019.0.045/compilers_and_libraries_2019/windows/mkl/lib/intel64_win/mkl_intel_thread.lib;D:/Program Files (x86)/IntelSWTools/parallel_studio_xe_2019.0.045/compilers_and_libraries_2019/windows/mkl/lib/intel64_win/mkl_core.lib;D:/Program Files (x86)/IntelSWTools/compilers_and_libraries_2019.0.117/windows/compiler/lib/intel64_win/libiomp5md.lib
From the generated VS solution, compile in Debug mode magma and magma_sparse projects (no need to compile the 600+ test projects)
In a separate folder put the example code and the CMakeLists.txt
add_executable(magma-test example_sparse.cpp) find_package( CUDA ) # just to set CUDA_INCLUDE_DIRS target_include_directories(magma-test PUBLIC D:/Work/Magma/magma-2.4.0/include D:/Work/Magma/magma-2.4.0/sparse/include ${CUDA_INCLUDE_DIRS}) target_link_libraries(magma-test debug D:/Work/Magma/magma-2.4.0/build/lib/Debug/magma.lib debug D:/Work/Magma/magma-2.4.0/build/lib/Debug/magma_sparse.lib) set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
Run CMake (Configure, Generate)
Problematic outcome:
1>magma_sparse.lib(magma_sparse_generated_djacobisetup.cu.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in magma.lib(interface.obj)
1>magma_sparse.lib(magma_sparse_generated_djacobisetup.cu.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MTd_StaticDebug' in magma.lib(interface.obj)
A CMakeLists.txt that "resolves" the above error, compiles and runs is:
add_executable(magma-test example_sparse.cpp)
find_package( CUDA )
set( MKLROOT "D:/Program Files (x86)/IntelSWTools/parallel_studio_xe_2019.0.045/compilers_and_libraries_2019/windows/mkl" )
set( LAPACK_LIBRARIES
"D:/Program Files (x86)/IntelSWTools/parallel_studio_xe_2019.0.045/compilers_and_libraries_2019/windows/mkl/lib/intel64_win/mkl_intel_lp64.lib"
"D:/Program Files (x86)/IntelSWTools/parallel_studio_xe_2019.0.045/compilers_and_libraries_2019/windows/mkl/lib/intel64_win/mkl_intel_thread.lib"
"D:/Program Files (x86)/IntelSWTools/parallel_studio_xe_2019.0.045/compilers_and_libraries_2019/windows/mkl/lib/intel64_win/mkl_core.lib"
"D:/Program Files (x86)/IntelSWTools/compilers_and_libraries_2019.0.117/windows/compiler/lib/intel64_win/libiomp5md.lib")
target_include_directories(magma-test PUBLIC
"D:/Work/Magma/magma-2.4.0/include"
"D:/Work/Magma/magma-2.4.0/sparse/include"
${CUDA_INCLUDE_DIRS}
${MKLROOT}/include)
target_link_libraries(magma-test
${CUDA_CUDART_LIBRARY}
${CUDA_CUBLAS_LIBRARIES}
${CUDA_cusparse_LIBRARY}
${LAPACK_LIBRARIES}
debug D:/Work/Magma/magma-2.4.0/build/lib/Debug/magma.lib
debug D:/Work/Magma/magma-2.4.0/build/lib/Debug/magma_sparse.lib
optimized D:/Work/Magma/magma-2.4.0/build/lib/Release/magma.lib
optimized D:/Work/Magma/magma-2.4.0/build/lib/Release/magma_sparse.lib)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
The CUDA and MKL libraries that MAGMA uses upon compilation seemingly also have to be provided for code that uses MAGMA libraries
EDIT: Wait, no. It's compiling and running in Release, but not in Debug..
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.