简体   繁体   中英

How to compile code that uses MAGMA in Visual Studio

给定MAGMA随附的示例代码 ,如何在Visual Studio中进行编译(或使用MAGMA的其他任何代码)?

My preferred way is making use of CMake.

Note1: You must also include and link CUDA and the LAPACK (plus include MKL, if you used that to compile MAGMA originally)

Note2: If you do not wish to link statically, you'll need to make the DLL's discoverable at run time, either by copying them into your project folder, or adding their location to PATH

The following CMakeLists.txt generates a VS Project that compiles and runs the example code.

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)

# Sets flags that cause static linking
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT") 
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM