List of "whitelisted" sm_ values for CUDA is incomplete

Issue #32 resolved
Alexander Grund created an issue

The CMake code allows to specify -DGPU_TARGET="sm_30 sm_50" and so on.

However that list is incomplete. From my CUDA 10.1 installation: 'sm_30','sm_32','sm_35','sm_37','sm_50','sm_52','sm_53','sm_60','sm_61','sm_62','sm_70','sm_72','sm_75'

The CMake code does not handle 3.2 and 3.7 and uses 7.1 instead of 7.2.

Moreover: Keeping the code up to date might be problematic as newer nvcc add new valid values.

I’d hence like to propose using a regex or a double-nested loop (for major and minor version) to extract all such values allowing users full control over which arch is used.

While being at it: if (${GPU_TARGET} MATCHES Pascal) style code is problematic. The correct code would be if (GPU_TARGET MATCHES "Pascal"). This is due to CMake variable expansion, see the docs for details.

Comments (4)

  1. Mark Gates

    Agreed. Instead of listing every value, it should probably have a loop, something like (untested!):

    string( REGEX MATCHALL "sm_(\d\d)" sms "${GPU_TARGET}")
    foreach (sm sms)
        if (NOT min_arch)
            set( min_arch "${sm}0" )  # 35 => 350
        endif()
        set( NV_SM ${NV_SM} -gencode arch=compute_${sm},code=sm_${sm} )
        set( NV_COMP        -gencode arch=compute_${sm},code=compute_${sm} )
    endforeach()
    

  2. Mark Gates

    Accept any sm_xx passed to GPU_TARGET in CMakeLists

    Previously valid arguments were silently ignored, e.g. sm_32 and future values had to be added manually, see sm_80

    Fixes #32

    → <<cset 19c9526d1a8a>>

  3. Log in to comment