Skip to content

Commit

Permalink
Removing need to pass MICM_ENABLE_GPU to cmake and modified logic to …
Browse files Browse the repository at this point in the history
…use MICM_GPU_TYPE instead.
  • Loading branch information
mwaxmonsky committed Jun 4, 2024
1 parent 487bc64 commit 3068670
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 20 deletions.
9 changes: 1 addition & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,14 @@ option(MICM_ENABLE_COVERAGE "Enable code coverage output" OFF)
option(MICM_ENABLE_MEMCHECK "Enable memory checking in tests" OFF)
option(MICM_ENABLE_JSON "Enable json configuration file reading" ON)
option(MICM_BUILD_DOCS "Build the documentation" OFF)
option(MICM_ENABLE_CUDA "Build with Cuda support" OFF)
option(MICM_ENABLE_LLVM "Build with LLVM support for JIT-compiling" OFF)
option(MICM_ENABLE_TESTS "Build the tests" ON)
option(MICM_ENABLE_EXAMPLES "Build the examples" ON)
option(MICM_ENABLE_PROFILE "Profile MICM Solver" OFF)
set(MICM_GPU_TYPE "None" CACHE STRING "The GPU type being targeted")
set(MICM_DEFAULT_VECTOR_MATRIX_SIZE "4" CACHE STRING "Default size for vectorizable matrix types")

include(CMakeDependentOption)
# Option to collect custom OpenACC flags
cmake_dependent_option(MICM_ENABLE_GPU_TYPE "Enable custom CUDA flags" OFF
"MICM_ENABLE_CUDA" ON)

if(MICM_ENABLE_GPU_TYPE)
set(MICM_GPU_TYPE "" CACHE STRING "The GPU type being targeted")
endif()

# on ubuntu with clang, an incorrect version of the c++ standard library was being linked
if (${CMAKE_HOST_SYSTEM_NAME} MATCHES "Linux" AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
Expand Down
18 changes: 7 additions & 11 deletions cmake/dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -113,24 +113,19 @@ endif()
################################################################################
# GPU Support

if(MICM_ENABLE_CUDA)
if(NOT MICM_GPU_TYPE)
message(FATAL_ERROR "MICM_GPU_TYPE is not set or is empty. Please provide a GPU type.")
endif()

if(NOT ${MICM_GPU_TYPE} STREQUAL "None")
set(cuda_arch_map_a100 80)
set(cuda_arch_map_v100 70)
set(cuda_arch_map_h100 90a)
set(cuda_arch_map_h200 90a)
set(cuda_arch_map_b100 95)
set(cuda_arch_map_b200 95)
set(MICM_GPU_ARCH ${cuda_arch_map_${MICM_GPU_TYPE}})

if(NOT MICM_GPU_ARCH)
message(FATAL_ERROR "MICM_GPU_TYPE (${MICM_GPU_TYPE}) is not recognized. Available options are [a100, v100, h1/200].")
endif()
set(cuda_arch_map_ all-major)
# Setting CUDAARCHS does not override CMAKE_CUDA_ARCHITECTURES or CUDA_ARCHITECTURES
# until the current process has returned to the caller site in CMake.
set(ENV{CUDAARCHS} ${cuda_arch_map_${MICM_GPU_TYPE}})

message(STATUS "GPU architecture ${MICM_GPU_ARCH}")
message(STATUS "GPU architecture ENV{CUDAARCHS}")

include(CheckLanguage)
check_language(CUDA)
Expand All @@ -141,6 +136,7 @@ if(MICM_ENABLE_CUDA)

enable_language(CUDA)
find_package(CUDAToolkit REQUIRED)
set(MICM_ENABLE_CUDA ON)
endif()

################################################################################
Expand Down
1 change: 0 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ if(MICM_ENABLE_CUDA)
target_link_libraries(micm_cuda
PUBLIC CUDA::cudart CUDA::cublas
)
set_target_properties(micm_cuda PROPERTIES CUDA_ARCHITECTURES "${MICM_GPU_ARCH}")
endif()

if (MICM_ENABLE_PROFILE)
Expand Down

0 comments on commit 3068670

Please sign in to comment.