[英]How to compile code that uses MAGMA in Visual Studio
我的首選方式是使用CMake。
注意1:您還必須包括並鏈接CUDA和LAPACK(如果您最初是用來編譯MAGMA的,則還包括MKL)
注意2:如果您不希望靜態鏈接,則需要在運行時使DLL可被發現,方法是將其復制到項目文件夾中,或者將其位置添加到PATH中。
以下CMakeLists.txt生成一個VS項目,該項目可編譯並運行示例代碼。
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")
編輯:等等,不。 它是在Release中編譯和運行的,但不是在Debug中運行的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.