Skip to content

Instantly share code, notes, and snippets.

@keichi
Created April 27, 2021 08:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keichi/f12abe7ff807de1d6b47c9847d363b66 to your computer and use it in GitHub Desktop.
Save keichi/f12abe7ff807de1d6b47c9847d363b66 to your computer and use it in GitHub Desktop.
diff --git a/cmake/kokkos_arch.cmake b/cmake/kokkos_arch.cmake
index ec18e70a..597f49fb 100644
--- a/cmake/kokkos_arch.cmake
+++ b/cmake/kokkos_arch.cmake
@@ -95,6 +95,9 @@ ENDIF()
#------------------------------- KOKKOS_CUDA_OPTIONS ---------------------------
#clear anything that might be in the cache
GLOBAL_SET(KOKKOS_CUDA_OPTIONS)
+
+GLOBAL_APPEND(KOKKOS_CUDA_OPTIONS "-arch=sm_60")
+
# Construct the Makefile options
IF (KOKKOS_ENABLE_CUDA_LAMBDA)
IF(KOKKOS_CXX_COMPILER_ID STREQUAL NVIDIA)
@@ -369,18 +372,15 @@ ENDIF()
SET(CUDA_ARCH_ALREADY_SPECIFIED "")
FUNCTION(CHECK_CUDA_ARCH ARCH FLAG)
IF(KOKKOS_ARCH_${ARCH})
- IF(CUDA_ARCH_ALREADY_SPECIFIED)
- MESSAGE(FATAL_ERROR "Multiple GPU architectures given! Already have ${CUDA_ARCH_ALREADY_SPECIFIED}, but trying to add ${ARCH}. If you are re-running CMake, try clearing the cache and running again.")
- ENDIF()
SET(CUDA_ARCH_ALREADY_SPECIFIED ${ARCH} PARENT_SCOPE)
IF (NOT KOKKOS_ENABLE_CUDA AND NOT KOKKOS_ENABLE_OPENMPTARGET AND NOT KOKKOS_ENABLE_SYCL)
MESSAGE(WARNING "Given CUDA arch ${ARCH}, but Kokkos_ENABLE_CUDA and Kokkos_ENABLE_OPENMPTARGET are OFF. Option will be ignored.")
UNSET(KOKKOS_ARCH_${ARCH} PARENT_SCOPE)
ELSE()
SET(KOKKOS_CUDA_ARCH_FLAG ${FLAG} PARENT_SCOPE)
- GLOBAL_APPEND(KOKKOS_CUDA_OPTIONS "${CUDA_ARCH_FLAG}=${FLAG}")
+ GLOBAL_APPEND(KOKKOS_CUDA_OPTIONS "${FLAG}")
IF(KOKKOS_ENABLE_CUDA_RELOCATABLE_DEVICE_CODE OR KOKKOS_CXX_COMPILER_ID STREQUAL NVIDIA)
- GLOBAL_APPEND(KOKKOS_LINK_OPTIONS "${CUDA_ARCH_FLAG}=${FLAG}")
+ GLOBAL_APPEND(KOKKOS_LINK_OPTIONS "${FLAG}")
ENDIF()
ENDIF()
ENDIF()
@@ -393,20 +393,20 @@ ENDFUNCTION()
#These will define KOKKOS_CUDA_ARCH_FLAG
#to the corresponding flag name if ON
-CHECK_CUDA_ARCH(KEPLER30 sm_30)
-CHECK_CUDA_ARCH(KEPLER32 sm_32)
-CHECK_CUDA_ARCH(KEPLER35 sm_35)
-CHECK_CUDA_ARCH(KEPLER37 sm_37)
-CHECK_CUDA_ARCH(MAXWELL50 sm_50)
-CHECK_CUDA_ARCH(MAXWELL52 sm_52)
-CHECK_CUDA_ARCH(MAXWELL53 sm_53)
-CHECK_CUDA_ARCH(PASCAL60 sm_60)
-CHECK_CUDA_ARCH(PASCAL61 sm_61)
-CHECK_CUDA_ARCH(VOLTA70 sm_70)
-CHECK_CUDA_ARCH(VOLTA72 sm_72)
-CHECK_CUDA_ARCH(TURING75 sm_75)
-CHECK_CUDA_ARCH(AMPERE80 sm_80)
-CHECK_CUDA_ARCH(AMPERE86 sm_86)
+CHECK_CUDA_ARCH(KEPLER30 -gencode=arch=compute_30,code=sm_30)
+CHECK_CUDA_ARCH(KEPLER32 -gencode=arch=compute_32,code=sm_32)
+CHECK_CUDA_ARCH(KEPLER35 -gencode=arch=compute_35,code=sm_35)
+CHECK_CUDA_ARCH(KEPLER37 -gencode=arch=compute_37,code=sm_37)
+CHECK_CUDA_ARCH(MAXWELL50 -gencode=arch=compute_50,code=sm_50)
+CHECK_CUDA_ARCH(MAXWELL52 -gencode=arch=compute_52,code=sm_52)
+CHECK_CUDA_ARCH(MAXWELL53 -gencode=arch=compute_53,code=sm_53)
+CHECK_CUDA_ARCH(PASCAL60 -gencode=arch=compute_60,code=sm_60)
+CHECK_CUDA_ARCH(PASCAL61 -gencode=arch=compute_61,code=sm_61)
+CHECK_CUDA_ARCH(VOLTA70 -gencode=arch=compute_70,code=sm_70)
+CHECK_CUDA_ARCH(VOLTA72 -gencode=arch=compute_72,code=sm_72)
+CHECK_CUDA_ARCH(TURING75 -gencode=arch=compute_75,code=sm_75)
+CHECK_CUDA_ARCH(AMPERE80 -gencode=arch=compute_80,code=sm_80)
+CHECK_CUDA_ARCH(AMPERE86 -gencode=arch=compute_86,code=sm_86)
SET(AMDGPU_ARCH_ALREADY_SPECIFIED "")
FUNCTION(CHECK_AMDGPU_ARCH ARCH FLAG)
@keichi
Copy link
Author

keichi commented Apr 27, 2021

This is a patch for Kokkos 3.4.0 to allow targeting multiple CUDA architectures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment