Skip to content

Commit

Permalink
Allow overriding compiler's chosen GPU arch via cmake (ingonyama-zk#518)
Browse files Browse the repository at this point in the history
## Describe the changes

This PR modifies icicle/cmake/Common.cmake to set
CMAKE_CUDA_ARCHITECTURES to ${CUDA_ARCH} if the user defines the arch,
to set CMAKE_CUDA_ARCHITECTURES to native if the cmake version is
greater than or equal to 3.24.0. This change has been successfully
tested with cmake 3.22.0 and 3.25.2.

## Linked Issues

Resolves ingonyama-zk#167.
  • Loading branch information
jeremyfelder committed May 19, 2024
2 parents 76a82bf + cfea6eb commit 1e343f1
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions icicle/cmake/Common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ endfunction()
function(set_gpu_env)
# add the target cuda architectures
# each additional architecture increases the compilation time and output file size
if(${CMAKE_VERSION} VERSION_LESS "3.24.0")
set(CMAKE_CUDA_ARCHITECTURES ${CUDA_ARCH} PARENT_SCOPE)
if(DEFINED CUDA_ARCH) # user defined arch takes priority
set(CMAKE_CUDA_ARCHITECTURES ${CUDA_ARCH} PARENT_SCOPE)
elseif(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.24.0") # otherwise, use native to detect GPU arch
set(CMAKE_CUDA_ARCHITECTURES native PARENT_SCOPE)
else()
find_program(_nvidia_smi "nvidia-smi")
find_program(_nvidia_smi "nvidia-smi")

if(_nvidia_smi)
set(DETECT_GPU_COUNT_NVIDIA_SMI 0)
Expand Down Expand Up @@ -69,4 +71,4 @@ function(set_gpu_env)
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --expt-relaxed-constexpr" PARENT_SCOPE)
set(CMAKE_CUDA_FLAGS_RELEASE "" PARENT_SCOPE)
set(CMAKE_CUDA_FLAGS_DEBUG "${CMAKE_CUDA_FLAGS_DEBUG} -g -lineinfo" PARENT_SCOPE)
endfunction()
endfunction()

0 comments on commit 1e343f1

Please sign in to comment.