1# - Find MAGMA library 2# This module finds an installed MAGMA library, a matrix algebra library 3# similar to LAPACK for GPU and multicore systems 4# (see http://icl.cs.utk.edu/magma/). 5# 6# This module will look for MAGMA library under /usr/local/magma by 7# default. To use a different installed version of the library set 8# environment variable MAGMA_HOME before running cmake (e.g. 9# MAGMA_HOME=${HOME}/lib/magma instead of default /usr/local/magma) 10# 11# This module sets the following variables: 12# MAGMA_FOUND - set to true if the MAGMA library is found. 13# MAGMA_LIBRARIES - list of libraries to link against to use MAGMA 14# MAGMA_INCLUDE_DIR - include directory 15 16if(MAGMA_FOUND) 17 return() 18endif() 19 20include(FindPackageHandleStandardArgs) 21 22SET(MAGMA_LIBRARIES) 23SET(MAGMA_INCLUDE_DIR) 24 25FIND_LIBRARY(MAGMA_LIBRARIES magma 26 HINTS $ENV{MAGMA_HOME} /usr/local/magma 27 PATH_SUFFIXES lib) 28 29FIND_PATH(MAGMA_INCLUDE_DIR magma.h 30 HINTS $ENV{MAGMA_HOME} /usr/local/magma 31 PATH_SUFFIXES include) 32 33IF (MAGMA_LIBRARIES) 34 SET(MAGMA_FOUND TRUE) 35ELSE (MAGMA_LIBRARIES) 36 SET(MAGMA_FOUND FALSE) 37ENDIF (MAGMA_LIBRARIES) 38 39add_library(torch::magma INTERFACE IMPORTED) 40set_property(TARGET torch::magma 41 PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${MAGMA_INCLUDE_DIR}") 42set_property(TARGET torch::magma 43 PROPERTY INTERFACE_LINK_LIBRARIES "${MAGMA_LIBRARIES}") 44 45# Check for Magma V2 46include(CheckPrototypeDefinition) 47check_prototype_definition(magma_get_sgeqrf_nb 48 "magma_int_t magma_get_sgeqrf_nb( magma_int_t m, magma_int_t n );" 49 "0" 50 "magma.h" 51 MAGMA_V2) 52if(MAGMA_V2) 53 set_property(TARGET torch::magma 54 PROPERTY INTERFACE_COMPILE_DEFINITIONS "MAGMA_V2") 55endif(MAGMA_V2) 56