Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

278 rindas
9.5 KiB

  1. https://sources.debian.org/data/main/a/arrayfire/3.3.2+dfsg1-4/debian/patches/Fix-LAPACKE-detection.patch
  2. From: Ghislain Antony Vaillant <ghisvail@gmail.com>
  3. Date: Wed, 2 Mar 2016 10:46:50 +0000
  4. Subject: Fix LAPACKE detection.
  5. ---
  6. CMakeModules/FindLAPACKE.cmake | 54 +++++++++++++++------------------------
  7. src/backend/cpu/CMakeLists.txt | 18 ++++++-------
  8. src/backend/cuda/CMakeLists.txt | 11 ++++----
  9. src/backend/opencl/CMakeLists.txt | 19 +++++++-------
  10. 4 files changed, 45 insertions(+), 57 deletions(-)
  11. diff --git a/CMakeModules/FindLAPACKE.cmake b/CMakeModules/FindLAPACKE.cmake
  12. index 9251ee9..1a73632 100644
  13. --- a/CMakeModules/FindLAPACKE.cmake
  14. +++ b/CMakeModules/FindLAPACKE.cmake
  15. @@ -4,13 +4,13 @@
  16. # FIND_PACKAGE(LAPACKE [REQUIRED] [QUIET] )
  17. #
  18. # It sets the following variables:
  19. -# LAPACK_FOUND ... true if LAPACKE is found on the system
  20. -# LAPACK_LIBRARIES ... full path to LAPACKE library
  21. -# LAPACK_INCLUDES ... LAPACKE include directory
  22. -#
  23. +# LAPACKE_FOUND ... true if LAPACKE is found on the system
  24. +# LAPACKE_INCLUDE_DIRS ... LAPACKE include directories
  25. +# LAPACKE_LIBRARIES ... path to LAPACKE libraries
  26. +# LAPACKE_LIBRARY_DIRS ... LAPACKE library directories
  27. SET(LAPACKE_ROOT_DIR CACHE STRING
  28. - "Root directory for custom LAPACK implementation")
  29. + "Root directory for custom LAPACKE implementation")
  30. IF (NOT INTEL_MKL_ROOT_DIR)
  31. SET(INTEL_MKL_ROOT_DIR $ENV{INTEL_MKL_ROOT})
  32. @@ -40,29 +40,20 @@ IF(PKG_CONFIG_FOUND AND NOT LAPACKE_ROOT_DIR)
  33. ENDIF()
  34. IF(PC_LAPACKE_FOUND)
  35. +
  36. + # Verify sanity of LAPACKE pkg-config file.
  37. FOREACH(PC_LIB ${PC_LAPACKE_LIBRARIES})
  38. FIND_LIBRARY(${PC_LIB}_LIBRARY NAMES ${PC_LIB} HINTS ${PC_LAPACKE_LIBRARY_DIRS} )
  39. IF (NOT ${PC_LIB}_LIBRARY)
  40. MESSAGE(FATAL_ERROR "Something is wrong in your pkg-config file - lib ${PC_LIB} not found in ${PC_LAPACKE_LIBRARY_DIRS}")
  41. ENDIF (NOT ${PC_LIB}_LIBRARY)
  42. - LIST(APPEND LAPACKE_LIB ${${PC_LIB}_LIBRARY})
  43. ENDFOREACH(PC_LIB)
  44. - FIND_PATH(
  45. - LAPACKE_INCLUDES
  46. - NAMES "lapacke.h"
  47. - PATHS
  48. - ${PC_LAPACKE_INCLUDE_DIRS}
  49. - ${INCLUDE_INSTALL_DIR}
  50. - /usr/include
  51. - /usr/local/include
  52. - /sw/include
  53. - /opt/local/include
  54. - DOC "LAPACKE Include Directory"
  55. - )
  56. + set(LAPACKE_LIBRARIES ${PC_LAPACKE_LIBRARIES})
  57. + set(LAPACKE_LIBRARY_DIRS ${PC_LAPACKE_LIBRARY_DIRS})
  58. - FIND_PACKAGE_HANDLE_STANDARD_ARGS(LAPACKE DEFAULT_MSG LAPACKE_LIB)
  59. - MARK_AS_ADVANCED(LAPACKE_INCLUDES LAPACKE_LIB)
  60. + FIND_PATH(LAPACKE_INCLUDE_DIRS NAMES "lapacke.h"
  61. + PATHS ${PC_LAPACKE_INCLUDE_DIRS})
  62. ELSE(PC_LAPACKE_FOUND)
  63. @@ -97,7 +88,6 @@ ELSE(PC_LAPACKE_FOUND)
  64. LAPACKE_LIB
  65. NAMES "lapacke" "liblapacke" "openblas" "mkl_rt"
  66. PATHS
  67. - ${PC_LAPACKE_LIBRARY_DIRS}
  68. ${LIB_INSTALL_DIR}
  69. /opt/intel/mkl/lib/ia32
  70. /opt/intel/mkl/lib/intel64
  71. @@ -113,7 +103,6 @@ ELSE(PC_LAPACKE_FOUND)
  72. LAPACK_LIB
  73. NAMES "lapack" "liblapack" "openblas" "mkl_rt"
  74. PATHS
  75. - ${PC_LAPACKE_LIBRARY_DIRS}
  76. ${LIB_INSTALL_DIR}
  77. /opt/intel/mkl/lib/ia32
  78. /opt/intel/mkl/lib/intel64
  79. @@ -129,7 +118,6 @@ ELSE(PC_LAPACKE_FOUND)
  80. LAPACKE_INCLUDES
  81. NAMES "lapacke.h" "mkl_lapacke.h"
  82. PATHS
  83. - ${PC_LAPACKE_INCLUDE_DIRS}
  84. ${INCLUDE_INSTALL_DIR}
  85. /opt/intel/mkl/include
  86. /usr/include
  87. @@ -141,17 +129,15 @@ ELSE(PC_LAPACKE_FOUND)
  88. lapacke
  89. )
  90. ENDIF(LAPACKE_ROOT_DIR)
  91. + SET(LAPACKE_INCLUDE_DIRS ${LAPACKE_INCLUDES})
  92. + SET(LAPACKE_LIBRARIES ${LAPACKE_LIB} ${LAPACK_LIB})
  93. + MARK_AS_ADVANCED(LAPACKE_INCLUDES LAPACKE_LIB LAPACK_LIB)
  94. ENDIF(PC_LAPACKE_FOUND)
  95. -IF(LAPACKE_LIB AND LAPACK_LIB)
  96. - SET(LAPACK_LIBRARIES ${LAPACKE_LIB} ${LAPACK_LIB})
  97. -ENDIF()
  98. -IF(LAPACKE_INCLUDES)
  99. - SET(LAPACK_INCLUDE_DIR ${LAPACKE_INCLUDES})
  100. -ENDIF()
  101. -
  102. INCLUDE(FindPackageHandleStandardArgs)
  103. -FIND_PACKAGE_HANDLE_STANDARD_ARGS(LAPACK DEFAULT_MSG
  104. - LAPACK_INCLUDE_DIR LAPACK_LIBRARIES)
  105. -
  106. -MARK_AS_ADVANCED(LAPACK_INCLUDES LAPACK_LIBRARIES)
  107. +FIND_PACKAGE_HANDLE_STANDARD_ARGS(LAPACKE DEFAULT_MSG
  108. + LAPACKE_LIBRARIES
  109. + LAPACKE_INCLUDE_DIRS)
  110. +MARK_AS_ADVANCED(LAPACKE_LIBRARIES
  111. + LAPACKE_INCLUDE_DIRS
  112. + LAPACKE_LIBRARY_DIRS)
  113. diff --git a/src/backend/cpu/CMakeLists.txt b/src/backend/cpu/CMakeLists.txt
  114. index ea57269..efe50a0 100644
  115. --- a/src/backend/cpu/CMakeLists.txt
  116. +++ b/src/backend/cpu/CMakeLists.txt
  117. @@ -55,7 +55,7 @@ MESSAGE(STATUS "FFTW Library: ${FFTW_LIBRARIES}")
  118. IF(APPLE)
  119. FIND_PACKAGE(LAPACKE QUIET) # For finding MKL
  120. - IF(NOT LAPACK_FOUND)
  121. + IF(NOT LAPACKE_FOUND)
  122. # UNSET THE VARIABLES FROM LAPACKE
  123. UNSET(LAPACKE_LIB CACHE)
  124. UNSET(LAPACK_LIB CACHE)
  125. @@ -67,11 +67,10 @@ ELSE(APPLE) # Linux and Windows
  126. FIND_PACKAGE(LAPACKE)
  127. ENDIF(APPLE)
  128. -IF(NOT LAPACK_FOUND)
  129. - MESSAGE(WARNING "LAPACK not found. Functionality will be disabled")
  130. -ELSE(NOT LAPACK_FOUND)
  131. +IF(NOT LAPACKE_FOUND)
  132. + MESSAGE(WARNING "LAPACKE not found. Functionality will be disabled")
  133. +ELSE(NOT LAPACKE_FOUND)
  134. ADD_DEFINITIONS(-DWITH_CPU_LINEAR_ALGEBRA)
  135. - MESSAGE(STATUS "LAPACK libraries found: ${LAPACK_LIBRARIES}")
  136. ENDIF()
  137. IF(NOT UNIX)
  138. @@ -99,8 +98,9 @@ INCLUDE_DIRECTORIES(
  139. ${CBLAS_INCLUDE_DIR}
  140. )
  141. -IF(LAPACK_FOUND)
  142. - INCLUDE_DIRECTORIES(${LAPACK_INCLUDE_DIR})
  143. +IF(LAPACKE_FOUND)
  144. + INCLUDE_DIRECTORIES(${LAPACKE_INCLUDE_DIRS})
  145. + LINK_DIRECTORIES(${LAPACKE_LIBRARY_DIRS})
  146. ENDIF()
  147. FILE(GLOB cpu_headers
  148. @@ -213,8 +213,8 @@ IF(FORGE_FOUND AND NOT USE_SYSTEM_FORGE)
  149. ADD_DEPENDENCIES(afcpu forge)
  150. ENDIF()
  151. -IF(LAPACK_FOUND)
  152. - TARGET_LINK_LIBRARIES(afcpu PRIVATE ${LAPACK_LIBRARIES})
  153. +IF(LAPACKE_FOUND)
  154. + TARGET_LINK_LIBRARIES(afcpu PRIVATE ${LAPACKE_LIBRARIES})
  155. ENDIF()
  156. IF(FORGE_FOUND)
  157. diff --git a/src/backend/cuda/CMakeLists.txt b/src/backend/cuda/CMakeLists.txt
  158. index 4efb427..24c6544 100644
  159. --- a/src/backend/cuda/CMakeLists.txt
  160. +++ b/src/backend/cuda/CMakeLists.txt
  161. @@ -105,7 +105,7 @@ ELSE(CUDA_cusolver_LIBRARY)
  162. ## Try to use CPU side lapack
  163. IF(APPLE)
  164. FIND_PACKAGE(LAPACKE QUIET) # For finding MKL
  165. - IF(NOT LAPACK_FOUND)
  166. + IF(NOT LAPACKE_FOUND)
  167. # UNSET THE VARIABLES FROM LAPACKE
  168. UNSET(LAPACKE_LIB CACHE)
  169. UNSET(LAPACK_LIB CACHE)
  170. @@ -117,9 +117,9 @@ ELSE(CUDA_cusolver_LIBRARY)
  171. FIND_PACKAGE(LAPACKE)
  172. ENDIF(APPLE)
  173. - IF(NOT LAPACK_FOUND)
  174. + IF(NOT LAPACKE_FOUND)
  175. MESSAGE(STATUS "CUDA Version ${CUDA_VERSION_STRING} does not contain cusolver library. Linear Algebra will not be available.")
  176. - ELSE(NOT LAPACK_FOUND)
  177. + ELSE(NOT LAPACKE_FOUND)
  178. MESSAGE(STATUS "CUDA Version ${CUDA_VERSION_STRING} does not contain cusolver library. But CPU LAPACK libraries are available. Will fallback to using host side code.")
  179. ADD_DEFINITIONS(-DWITH_CPU_LINEAR_ALGEBRA)
  180. IF(USE_CUDA_MKL) # Manual MKL Setup
  181. @@ -148,7 +148,8 @@ INCLUDE_DIRECTORIES(
  182. )
  183. IF(CUDA_LAPACK_CPU_FALLBACK)
  184. - INCLUDE_DIRECTORIES(${LAPACK_INCLUDE_DIR})
  185. + INCLUDE_DIRECTORIES(${LAPACKE_INCLUDE_DIRS})
  186. + LINK_DIRECTORIES(${LAPACKE_LIBRARY_DIRS})
  187. ENDIF()
  188. FILE(GLOB cuda_headers
  189. @@ -379,7 +380,7 @@ ENDIF()
  190. IF(CUDA_cusolver_LIBRARY)
  191. TARGET_LINK_LIBRARIES(afcuda PRIVATE ${CUDA_cusolver_LIBRARY})
  192. ELSEIF(CUDA_LAPACK_CPU_FALLBACK)
  193. - TARGET_LINK_LIBRARIES(afcuda PRIVATE ${LAPACK_LIBRARIES})
  194. + TARGET_LINK_LIBRARIES(afcuda PRIVATE ${LAPACKE_LIBRARIES})
  195. ENDIF()
  196. SET_TARGET_PROPERTIES(afcuda PROPERTIES
  197. diff --git a/src/backend/opencl/CMakeLists.txt b/src/backend/opencl/CMakeLists.txt
  198. index 71247ce..ded53bf 100644
  199. --- a/src/backend/opencl/CMakeLists.txt
  200. +++ b/src/backend/opencl/CMakeLists.txt
  201. @@ -12,7 +12,7 @@ ENDIF()
  202. IF(APPLE)
  203. FIND_PACKAGE(LAPACKE QUIET) # For finding MKL
  204. - IF(NOT LAPACK_FOUND)
  205. + IF(NOT LAPACKE_FOUND)
  206. # UNSET THE VARIABLES FROM LAPACKE
  207. UNSET(LAPACKE_LIB CACHE)
  208. UNSET(LAPACK_LIB CACHE)
  209. @@ -24,9 +24,9 @@ ELSE(APPLE) # Linux and Windows
  210. FIND_PACKAGE(LAPACKE)
  211. ENDIF(APPLE)
  212. -IF(NOT LAPACK_FOUND)
  213. - MESSAGE(WARNING "LAPACK not found. Functionality will be disabled")
  214. -ELSE(NOT LAPACK_FOUND)
  215. +IF(NOT LAPACKE_FOUND)
  216. + MESSAGE(WARNING "LAPACKE not found. Functionality will be disabled")
  217. +ELSE(NOT LAPACKE_FOUND)
  218. ADD_DEFINITIONS(-DWITH_OPENCL_LINEAR_ALGEBRA)
  219. IF(NOT USE_OPENCL_MKL)
  220. @@ -105,8 +105,9 @@ INCLUDE_DIRECTORIES(
  221. ${BoostCompute_INCLUDE_DIRS}
  222. ${CBLAS_INCLUDE_DIR}
  223. )
  224. -IF(LAPACK_FOUND)
  225. - INCLUDE_DIRECTORIES(${LAPACK_INCLUDE_DIR})
  226. +IF(LAPACKE_FOUND)
  227. + INCLUDE_DIRECTORIES(${LAPACKE_INCLUDE_DIRS})
  228. + LINK_DIRECTORIES(${LAPACKE_LIBRARY_DIRS})
  229. ENDIF()
  230. FILE(GLOB opencl_headers
  231. @@ -163,7 +164,7 @@ source_group(backend\\opencl\\kernel\\convolve\\Sources FILES ${conv_ker_sources
  232. source_group(backend\\opencl\\cpu\\Headers FILES ${cpu_headers})
  233. source_group(backend\\opencl\\cpu\\Sources FILES ${cpu_sources})
  234. -IF(LAPACK_FOUND)
  235. +IF(LAPACKE_FOUND)
  236. FILE(GLOB magma_sources
  237. "magma/*.cpp")
  238. @@ -313,9 +314,9 @@ IF(FORGE_FOUND AND NOT USE_SYSTEM_FORGE)
  239. ADD_DEPENDENCIES(afopencl forge)
  240. ENDIF()
  241. -IF(LAPACK_FOUND)
  242. +IF(LAPACKE_FOUND)
  243. TARGET_LINK_LIBRARIES(afopencl
  244. - PRIVATE ${LAPACK_LIBRARIES}
  245. + PRIVATE ${LAPACKE_LIBRARIES}
  246. PRIVATE ${CBLAS_LIBRARIES})
  247. ENDIF()