VS: CUDA_ARCHITECTURES generates wrong flags for real architectures
Setting CUDA_ARCHITECTURES
results in wrong flags when specifying real architectures (e.g. 86-real
) if using a Visual Studio generator. The generated flags are correct using other generators like Ninja, including on Linux, using the same version of CMake.
CMake: 3.23.1
Generator: Visual Studio 17 2022
CUDA: 11.6.2
For example:
86-real
results in -gencode=arch=compute_86,code=\"sm_86,compute_86\"
, which generates code for both real (sm_86
) and virtual (compute_86
) architectures but it should generate only for the real one. The correct flag would be -gencode arch=compute_86,code=sm_86
The following cases work correctly but the generated flags are quite odd and redundant:
86-virtual
results in -gencode=arch=compute_86,code=\"compute_86,compute_86\"
, which is correct but it could be simply -gencode arch=compute_86,code=compute_86
86
results in -gencode=arch=compute_86,code=\"compute_86,compute_86\" -gencode=arch=compute_86,code=\"sm_86,compute_86\"
, which is also correct but could be replaced with a single flag: -gencode arch=compute_86,code=[sm_86,compute_86]
. Using Ninja this more compact flag is generated.