1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487
|
9a10
> enable_language(Fortran)
34,86d34
< # don't regenerate files during make.
< # (I think this means you have to manually re-run CMake if CMakeLists changes.
< # It fixes the huge problems with CMake interrupting Visual Studio.)
< set(CMAKE_SUPPRESS_REGENERATION on)
<
<
< # ----------------------------------------
< # force an out-of-source build, to not overwrite the existing Makefiles
< # (out-of-source is cleaner, too)
< string( COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" MAGMA_COMPILE_INPLACE )
< if (MAGMA_COMPILE_INPLACE)
< message( FATAL_ERROR "Compiling MAGMA with CMake requires an out-of-source build. To proceed:
< rm -rf CMakeCache.txt CMakeFiles/ # delete files in ${CMAKE_SOURCE_DIR}
< mkdir build
< cd build
< cmake ..
< make" )
< endif()
<
<
< # ----------------------------------------
< # prefer shared libraries
< option( BUILD_SHARED_LIBS "If on, build shared libraries, otherwise build static libraries" ON )
<
< # prefer /usr/local/magma, instead of /usr/local.
< if (UNIX AND CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
< set(CMAKE_INSTALL_PREFIX "/usr/local/magma" CACHE PATH "..." FORCE)
< endif()
<
< # ----------------------------------------
< # use C++11 and C99
< # see http://stackoverflow.com/questions/10851247/how-to-activate-c-11-in-cmake
< include(CheckCXXCompilerFlag)
< include(CheckCCompilerFlag)
< CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
< CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
< if (COMPILER_SUPPORTS_CXX11)
< set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
< elseif(COMPILER_SUPPORTS_CXX0X)
< set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
< else()
< message( WARNING "The compiler ${CMAKE_CXX_COMPILER} doesn't support the -std=c++11 flag. Some code may not compile.")
< endif()
<
< CHECK_C_COMPILER_FLAG("-std=c99" COMPILER_SUPPORTS_C99)
< if (COMPILER_SUPPORTS_C99)
< set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
< else()
< message( WARNING "The compiler ${CMAKE_C_COMPILER} doesn't support the -std=c99 flag. Some code may not compile.")
< endif()
<
<
< # ----------------------------------------
90c38
< FortranCInterface_HEADER( ${CMAKE_SOURCE_DIR}/include/magma_mangling_cmake.h MACRO_NAMESPACE MAGMA_ )
---
> FortranCInterface_HEADER( ${CMAKE_CURRENT_SOURCE_DIR}/include/magma_mangling_cmake.h MACRO_NAMESPACE MAGMA_ )
93d40
< message( STATUS "Building without Fortran compiler" )
96d42
< message( STATUS " Using ${FORTRAN_CONVENTION} for Fortran calling convention" )
105c51
< find_package( OpenMP )
---
> find_package( OpenMP QUIET )
107,109d52
< message( STATUS "Found OpenMP" )
< message( STATUS " OpenMP_C_FLAGS ${OpenMP_C_FLAGS}" )
< message( STATUS " OpenMP_CXX_FLAGS ${OpenMP_CXX_FLAGS}" )
121,124d63
< if (CUDAToolkit_FOUND)
< message( STATUS "Found CUDA ${CUDA_VERSION}" )
< message( STATUS " CUDA_CUDART_LIBRARY: CUDA::cudart" )
< #message( STATUS " CUDA_CUBLAS_LIBRARIES: CUDA::cublas" )
130,293c69,84
< set(CUDA_SEPARABLE_COMPILATION ON)
<
< set(__cuda_architectures)
<
< include_directories( ${CUDAToolkit_INCLUDE_DIRS} )
<
< if (GPU_TARGET MATCHES Fermi)
< set( GPU_TARGET "${GPU_TARGET} sm_20" )
< endif()
<
< if (GPU_TARGET MATCHES Kepler)
< set( GPU_TARGET "${GPU_TARGET} sm_30 sm_35 sm_37" )
< endif()
<
< if (GPU_TARGET MATCHES Maxwell)
< set( GPU_TARGET "${GPU_TARGET} sm_50" )
< endif()
<
< if (GPU_TARGET MATCHES Pascal)
< set( GPU_TARGET "${GPU_TARGET} sm_60" )
< endif()
<
< if (GPU_TARGET MATCHES Volta)
< set( GPU_TARGET "${GPU_TARGET} sm_70" )
< endif()
<
< if (GPU_TARGET MATCHES Turing)
< set( GPU_TARGET "${GPU_TARGET} sm_75" )
< endif()
<
< if (GPU_TARGET MATCHES Ampere)
< set( GPU_TARGET "${GPU_TARGET} sm_80" )
< endif()
<
< if (GPU_TARGET MATCHES sm_20)
< if (NOT MIN_ARCH)
< set( MIN_ARCH 200 )
< endif()
< list(APPEND __cuda_architectures 20)
< message( STATUS " compile for CUDA arch 2.0 (Fermi)" )
< endif()
<
< if (GPU_TARGET MATCHES sm_30)
< if (NOT MIN_ARCH)
< set( MIN_ARCH 300 )
< endif()
< list(APPEND __cuda_architectures 30)
< message( STATUS " compile for CUDA arch 3.0 (Kepler)" )
< endif()
<
< if (GPU_TARGET MATCHES sm_35)
< if (NOT MIN_ARCH)
< set( MIN_ARCH 300 )
< endif()
< list(APPEND __cuda_architectures 35)
< message( STATUS " compile for CUDA arch 3.5 (Kepler)" )
< endif()
<
< if (GPU_TARGET MATCHES sm_37)
< if (NOT MIN_ARCH)
< set( MIN_ARCH 300 )
< endif()
< list(APPEND __cuda_architectures 37)
< message( STATUS " compile for CUDA arch 3.7 (Kepler)" )
< endif()
<
< if (GPU_TARGET MATCHES sm_50)
< if (NOT MIN_ARCH)
< set( MIN_ARCH 500 )
< endif()
< list(APPEND __cuda_architectures 50)
< message( STATUS " compile for CUDA arch 5.0 (Maxwell)" )
< endif()
<
< if (GPU_TARGET MATCHES sm_52)
< if (NOT MIN_ARCH)
< set( MIN_ARCH 520 )
< endif()
< list(APPEND __cuda_architectures 52)
< message( STATUS " compile for CUDA arch 5.2 (Maxwell)" )
< endif()
<
< if (GPU_TARGET MATCHES sm_53)
< if (NOT MIN_ARCH)
< set( MIN_ARCH 530 )
< endif()
< list(APPEND __cuda_architectures 53)
< message( STATUS " compile for CUDA arch 5.3 (Maxwell)" )
< endif()
<
< if (GPU_TARGET MATCHES sm_60)
< if (NOT MIN_ARCH)
< set( MIN_ARCH 600 )
< endif()
< list(APPEND __cuda_architectures 60)
< message( STATUS " compile for CUDA arch 6.0 (Pascal)" )
< endif()
<
< if (GPU_TARGET MATCHES sm_61)
< if (NOT MIN_ARCH)
< set( MIN_ARCH 610 )
< endif()
< list(APPEND __cuda_architectures 61)
< message( STATUS " compile for CUDA arch 6.1 (Pascal)" )
< endif()
<
< if (GPU_TARGET MATCHES sm_62)
< if (NOT MIN_ARCH)
< set( MIN_ARCH 620 )
< endif()
< list(APPEND __cuda_architectures 62)
< message( STATUS " compile for CUDA arch 6.2 (Pascal)" )
< endif()
<
< if (GPU_TARGET MATCHES sm_70)
< if (NOT MIN_ARCH)
< set( MIN_ARCH 700 )
< endif()
< list(APPEND __cuda_architectures 70)
< message( STATUS " compile for CUDA arch 7.0 (Volta)" )
< endif()
<
< if (GPU_TARGET MATCHES sm_71)
< if (NOT MIN_ARCH)
< set( MIN_ARCH 710 )
< endif()
< list(APPEND __cuda_architectures 71)
< message( STATUS " compile for CUDA arch 7.1 (Volta)" )
< endif()
<
< if (GPU_TARGET MATCHES sm_75)
< if (NOT MIN_ARCH)
< set( MIN_ARCH 750 )
< endif()
< list(APPEND __cuda_architectures 75)
< message( STATUS " compile for CUDA arch 7.5 (Turing)" )
< endif()
<
< if (GPU_TARGET MATCHES sm_80)
< if (NOT MIN_ARCH)
< set( MIN_ARCH 800 )
< endif()
< list(APPEND __cuda_architectures 80)
< message( STATUS " compile for CUDA arch 8.0 (Ampere)" )
< endif()
<
< if (NOT MIN_ARCH)
< message( FATAL_ERROR "GPU_TARGET must contain one or more of Fermi, Kepler, Maxwell, Pascal, Volta, Turing, Ampere, or valid sm_[0-9][0-9]" )
< endif()
<
< set(CUDA_ARCHITECTURES "${__cuda_architectures}")
<
< add_library(magma_nvcc_flags INTERFACE)
< target_compile_options(magma_nvcc_flags
< INTERFACE
< $<$<COMPILE_LANGUAGE:CUDA>:--compiler-options;-fPIC,${FORTRAN_CONVENTION}>
< )
<
< set(MAGMA_HAVE_CUDA "1")
< set(MAGMA_CUDA_ARCH_MIN "${MIN_ARCH}")
< message( STATUS "Define -DMAGMA_HAVE_CUDA -DMAGMA_CUDA_ARCH_MIN=${MIN_ARCH}" )
< else()
< message( STATUS "Could not find CUDA" )
< endif()
---
> list(GET CMAKE_CUDA_ARCHITECTURES 0 MIN_ARCH) # MIN_ARCH is the first specified arch
> foreach(__cuda_arch ${CMAKE_CUDA_ARCHITECTURES})
> if (${__cuda_arch} LESS ${MIN_ARCH})
> set(MIN_ARCH ${__cuda_arch})
> endif()
> endforeach()
>
> add_library(magma_nvcc_flags INTERFACE)
> target_compile_options(magma_nvcc_flags
> INTERFACE
> $<$<COMPILE_LANGUAGE:CUDA>:--compiler-options;${FORTRAN_CONVENTION}>
> )
>
> set(MAGMA_HAVE_CUDA "1")
> set(MAGMA_CUDA_ARCH_MIN "${MIN_ARCH}")
> message( STATUS "Define -DMAGMA_HAVE_CUDA -DMAGMA_CUDA_ARCH_MIN=${MIN_ARCH}" )
298,348c89,93
< set( GPU_TARGET "gfx900" CACHE STRING "HIP architectures to compile for" )
< list(APPEND CMAKE_PREFIX_PATH /opt/rocm /opt/rocm/hip)
< find_package( HIP )
< if (HIP_FOUND)
< message( STATUS "Found HIP ${HIP_VERSION}" )
< message( STATUS " HIP_INCLUDE_DIRS: ${HIP_INCLUDE_DIRS}" )
< message( STATUS "GPU_TARGET: ${GPU_TARGET}" )
<
< include_directories( ${HIP_INCLUDE_DIRS} )
<
< set(HIP_SEPARABLE_COMPILATION ON)
<
< if (GPU_TARGET MATCHES kaveri)
< set( GPU_TARGET ${GPU_TARGET} gfx700 )
< endif()
<
< if (GPU_TARGET MATCHES hawaii)
< set( GPU_TARGET ${GPU_TARGET} gfx701 )
< endif()
<
< if (GPU_TARGET MATCHES kabini)
< set( GPU_TARGET ${GPU_TARGET} gfx703 )
< endif()
<
< if (GPU_TARGET MATCHES mullins)
< set( GPU_TARGET ${GPU_TARGET} gfx703 )
< endif()
<
< if (GPU_TARGET MATCHES bonaire)
< set( GPU_TARGET ${GPU_TARGET} gfx704 )
< endif()
<
< if (GPU_TARGET MATCHES carrizo)
< set( GPU_TARGET ${GPU_TARGET} gfx801 )
< endif()
<
< if (GPU_TARGET MATCHES iceland)
< set( GPU_TARGET ${GPU_TARGET} gfx802 )
< endif()
<
< if (GPU_TARGET MATCHES tonga)
< set( GPU_TARGET ${GPU_TARGET} gfx802 )
< endif()
<
< if (GPU_TARGET MATCHES fiji)
< set( GPU_TARGET ${GPU_TARGET} gfx803 )
< endif()
<
< if (GPU_TARGET MATCHES polaris10)
< set( GPU_TARGET ${GPU_TARGET} gfx803 )
< endif()
---
> list (APPEND CMAKE_PREFIX_PATH /opt/rocm/hip /opt/rocm)
> if (IS_DIRECTORY Tasmanian_ENABLE_ROCM)
> list (APPEND CMAKE_PREFIX_PATH ${Tasmanian_ENABLE_ROCM})
> endif()
> enable_language(HIP)
350,352c95,96
< if (GPU_TARGET MATCHES tongapro)
< set( GPU_TARGET ${GPU_TARGET} gfx805 )
< endif()
---
> find_package( HIP )
> set(MAGMA_HAVE_HIP "1")
354,356c98,99
< if (GPU_TARGET MATCHES stoney)
< set( GPU_TARGET ${GPU_TARGET} gfx810 )
< endif()
---
> set_property(TARGET hip::device APPEND PROPERTY COMPATIBLE_INTERFACE_BOOL INTERFACE_HIP_DEVICE_COMPILE)
> set_property(TARGET hip::device PROPERTY INTERFACE_HIP_DEVICE_COMPILE ON)
358,377c101,105
< set( DEVCCFLAGS "" )
< set(VALID_GFXS "700;701;702;703;704;705;801;802;803;805;810;900;902;904;906;908;909;90c;1010;1011;1012;1030;1031;1032;1033")
< foreach( GFX ${VALID_GFXS} )
< if ( GPU_TARGET MATCHES gfx${GFX} )
< set( DEVCCFLAGS ${DEVCCFLAGS} --amdgpu-target=gfx${GFX} )
< endif()
< endforeach()
<
< set( DEVCCFLAGS ${DEVCCFLAGS} -fPIC ${FORTRAN_CONVENTION} )
< set(MAGMA_HAVE_HIP "1")
< message( STATUS "Define -DMAGMA_HAVE_HIP" )
<
< set_property(TARGET hip::device APPEND PROPERTY COMPATIBLE_INTERFACE_BOOL INTERFACE_HIP_DEVICE_COMPILE)
< set_property(TARGET hip::device PROPERTY INTERFACE_HIP_DEVICE_COMPILE ON)
< set(GPU_ARCH_FLAGS ${DEVCCFLAGS})
<
< #add_compile_options(${GPU_ARCH_FLAGS})
< else()
< message( STATUS "Could not find HIP" )
< endif()
---
> add_library(magma_hip_flags INTERFACE)
> target_compile_options(magma_hip_flags
> INTERFACE
> $<$<COMPILE_LANGUAGE:HIP>:${FORTRAN_CONVENTION}>
> )
400d127
< message( STATUS "Searching for BLAS and LAPACK. To override, set LAPACK_LIBRARIES using ccmake." )
405d131
< message( STATUS "User set LAPACK_LIBRARIES. To change, edit LAPACK_LIBRARIES using ccmake (set to empty to enable search)." )
443c169
< include( ${CMAKE_SOURCE_DIR}/CMake.src.cuda )
---
> include( ${CMAKE_CURRENT_SOURCE_DIR}/CMake.src.cuda )
445c171
< include( ${CMAKE_SOURCE_DIR}/CMake.src.hip )
---
> include( ${CMAKE_CURRENT_SOURCE_DIR}/CMake.src.hip )
500c226
< include_directories( "${CMAKE_BINARY_DIR}/include" )
---
> include_directories( "${CMAKE_CURRENT_BINARY_DIR}/include" )
509c235
<
---
>
519c245
< configure_file(${CMAKE_SOURCE_DIR}/include/magma_config.h.in ${CMAKE_BINARY_DIR}/include/magma_config.h)
---
> configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/magma_config.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/magma_config.h)
573c299,300
< )
---
> )
> target_include_directories(magma PUBLIC ${CUDAToolkit_INCLUDE_DIRS})
576,578d302
< if (hipBLAS_FOUND)
< message( STATUS "Found rocBLAS ${rocBLAS_VERSION}" )
< endif()
580,582d303
< if (hipSPARSE_FOUND)
< message( STATUS "Found rocSPARSE ${rocSPARSE_VERSION}" )
< endif()
589a311
> magma_hip_flags
590a313,319
> target_include_directories(magma PUBLIC ${HIP_INCLUDE_DIRS})
> foreach(__magma_src ${libmagma_all})
> if (NOT ${__magma_src} MATCHES ".F90")
> set_source_files_properties(${__magma_src} PROPERTIES LANGUAGE HIP)
> endif()
> endforeach()
>
592c321
<
---
>
599c328
< list( APPEND modules "${CMAKE_BINARY_DIR}/${fmod}.mod" )
---
> list( APPEND modules "${CMAKE_CURRENT_BINARY_DIR}/${fmod}.mod" )
648a378
> include_directories( ${CUDAToolkit_INCLUDE_DIRS} )
651a382,383
> include_directories( ${HIP_INCLUDE_DIRS} )
> include_directories( ${HIP_INCLUDE_DIRS}/../ )
668a401
> target_include_directories(magma_sparse PUBLIC ${CUDAToolkit_INCLUDE_DIRS})
677a411
> magma_hip_flags
678a413,418
> target_include_directories(magma_sparse PUBLIC ${HIP_INCLUDE_DIRS})
> foreach(__magma_src ${libsparse_all})
> if (NOT ${__magma_src} MATCHES ".F90")
> set_source_files_properties(${__magma_src} PROPERTIES LANGUAGE HIP)
> endif()
> endforeach()
681a422,425
> set_property(TARGET magma PROPERTY CXX_STANDARD 11)
> set_property(TARGET magma_sparse PROPERTY CXX_STANDARD 11)
> set_property(TARGET magma PROPERTY C_STANDARD 99)
> set_property(TARGET magma_sparse PROPERTY C_STANDARD 99)
690a435,444
> if (MAGMA_ENABLE_HIP AND IS_DIRECTORY /opt/rocm/llvm/lib)
> get_target_property(__magma_rpath magma INSTALL_RPATH)
> list(APPEND __magma_rpath /opt/rocm/llvm/lib)
> set_target_properties(magma PROPERTIES
> BUILD_WITH_INSTALL_RPATH "ON"
> INSTALL_RPATH "${__magma_rpath}")
> set_target_properties(magma_sparse PROPERTIES
> BUILD_WITH_INSTALL_RPATH "ON"
> INSTALL_RPATH "${__magma_rpath}")
> endif()
720d473
< cmake_policy( SET CMP0037 OLD)
739c492
< file( GLOB headers include/*.h sparse/include/*.h "${CMAKE_BINARY_DIR}/include/*.h" )
---
> file( GLOB headers include/*.h sparse/include/*.h "${CMAKE_CURRENT_BINARY_DIR}/include/*.h" )
741c494
< file( GLOB headers include/*.h sparse_hip/include/*.h "${CMAKE_BINARY_DIR}/include/*.h" )
---
> file( GLOB headers include/*.h sparse_hip/include/*.h "${CMAKE_CURRENT_BINARY_DIR}/include/*.h" )
758d510
< message( STATUS "pkgconfig ${pkgconfig}" )
774c526
< install( FILES "${CMAKE_BINARY_DIR}/${pkgconfig}"
---
> install( FILES "${CMAKE_CURRENT_BINARY_DIR}/${pkgconfig}"
779,803d530
<
< message( STATUS "Flags" )
< message( STATUS " CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}" )
< message( STATUS " CFLAGS: ${CMAKE_C_FLAGS}" )
< message( STATUS " CXXFLAGS: ${CMAKE_CXX_FLAGS}" )
< if (MAGMA_ENABLE_CUDA)
< message( STATUS " NVCCFLAGS: ${CUDA_NVCC_FLAGS}" )
< else()
< message( STATUS " DEVCCFLAGS: ${DEVCCFLAGS}" )
< endif()
< message( STATUS " FFLAGS: ${CMAKE_Fortran_FLAGS}" )
< message( STATUS " LIBS: ${LIBS}" )
< message( STATUS " blas_fix: ${blas_fix} (MacOS Accelerate only)" )
< message( STATUS " LAPACK_LIBRARIES: ${LAPACK_LIBRARIES}" )
< message( STATUS " INCLUDE_DIRECTORIES: ${MAGMA_INCLUDE}" )
< if (MAGMA_ENABLE_CUDA)
< message( STATUS " CUDA_CUDART_LIBRARY: CUDA::cudart" )
< message( STATUS " CUDA_CUBLAS_LIBRARIES: CUDA::cublas" )
< message( STATUS " CUDA_cusparse_LIBRARY: CUDA::cusparse" )
< else()
< message( STATUS " HIP_LIBRARY: hip::device" )
< message( STATUS " HIP_BLAS_LIBRARIES: roc::hipblas" )
< message( STATUS " HIP_sparse_LIBRARY: roc::hipsparse" )
< endif()
< message( STATUS " Fortran modules: ${modules}" )
|