List of "whitelisted" sm_ values for CUDA is incomplete

Issue #32 new
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 (3)

  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. Log in to comment