On Linux I can compile CUDA code for several different gencodes, and then the nvcc will do a JIT to pick the right version to use. This technique is shown in basically every CUDA sample’s makefile:
# CUDA code generation flags
ifneq ($(OS_ARCH),armv7l)
GENCODE_SM10 := -gencode arch=compute_10,code=sm_10
endif
GENCODE_SM20 := -gencode arch=compute_20,code=sm_20
GENCODE_SM30 := -gencode arch=compute_30,code=sm_30
GENCODE_SM32 := -gencode arch=compute_32,code=sm_32
GENCODE_SM35 := -gencode arch=compute_35,code=sm_35
GENCODE_SM50 := -gencode arch=compute_50,code=sm_50
GENCODE_SMXX := -gencode arch=compute_50,code=compute_50
GENCODE_FLAGS ?= $(GENCODE_SM10) $(GENCODE_SM20) $(GENCODE_SM30) $(GENCODE_SM32) $(GENCODE_SM35) $(GENCODE_SM50) $(GENCODE_SMXX)
How do I do this in Visual Studio? Is it possible? Right now I have a props file with just this line:
<CodeGeneration>compute_20,sm_20</CodeGeneration>
I tried:
<CodeGeneration>compute_20,sm_20,compute_30,sm_30</CodeGeneration>
But get this error:
Code Generation value is not in the expected format ‘[Arch],[Code]’.
I looked this up on google but haven’t found any one trying to compile for more than one architecture at a time on Visual Studio.