CMake: Improve check and report of Magma (#117858)

- Only search for magma if it is used (GPU builds)
- Don't report it was not found when it isn't searched for
- Don't report if magma is disabled (currently: "MAGMA not found. Compiling without MAGMA support" is reported)

Pull Request resolved: https://github.com/pytorch/pytorch/pull/117858
Approved by: https://github.com/malfet
This commit is contained in:
Alexander Grund 2024-05-15 17:18:18 +00:00 committed by PyTorch MergeBot
parent f91cae461d
commit 490d72e4e6

View File

@ -1597,23 +1597,24 @@ if(NOT INTERN_BUILD_MOBILE)
set(CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE OFF)
if(USE_MAGMA)
find_package(MAGMA)
endif()
if((USE_CUDA OR USE_ROCM) AND MAGMA_FOUND)
set(USE_MAGMA 1)
message(STATUS "Compiling with MAGMA support")
message(STATUS "MAGMA INCLUDE DIRECTORIES: ${MAGMA_INCLUDE_DIR}")
message(STATUS "MAGMA LIBRARIES: ${MAGMA_LIBRARIES}")
message(STATUS "MAGMA V2 check: ${MAGMA_V2}")
if(USE_CUDA OR USE_ROCM)
if(USE_MAGMA)
find_package(MAGMA)
if(MAGMA_FOUND)
message(STATUS "Compiling with MAGMA support")
message(STATUS "MAGMA INCLUDE DIRECTORIES: ${MAGMA_INCLUDE_DIR}")
message(STATUS "MAGMA LIBRARIES: ${MAGMA_LIBRARIES}")
message(STATUS "MAGMA V2 check: ${MAGMA_V2}")
else()
message(STATUS "MAGMA not found. Compiling without MAGMA support")
caffe2_update_option(USE_MAGMA OFF)
endif()
endif()
elseif(USE_MAGMA)
message(WARNING
"Not compiling with MAGMA. Suppress this warning with "
"-DUSE_MAGMA=OFF.")
caffe2_update_option(USE_MAGMA OFF)
else()
message(STATUS "MAGMA not found. Compiling without MAGMA support")
caffe2_update_option(USE_MAGMA OFF)
endif()
# ARM specific flags