CUDA architecture Macro

Hi. I would like to use some of the architecture specifying macro, which I believe is “CUDA_ARCH”. I was trying the following code, but the macro appears not to be defined. How can I get this to work?

#if __CUDA_ARCH__ < 200

	// cache-shared memory configuring not possible, no cache

	printf("Cache configuration not possible\n");


	cudaError_t errorCachePref1 = cudaFuncSetCacheConfig("...", cudaFuncCachePreferShared);

	cudaError_t errorCachePref2 = cudaFuncSetCacheConfig("...", cudaFuncCachePreferShared);

	printf("Cache configuration done\n");



I read a few things on other forums that CUDA_ARCH is not defined on the C compiler side, and is defined only on the CDA compiler side. The file I am using is a .cu file, and is supposed to be compiled with nvcc, so I am not sure what I should do to make this work.


Use cudaGetDeviceProperties() to query the compute capability at runtime. It is returned in the [font=“Courier New”]major[/font] and [font=“Courier New”]minor[/font] fields.

The compute capability cannot be known in host code at compile time because it is possible to compile fat binaries with object code for multiple GPU architectures, where the right one is selected at run time.

Thanks I believe this is the better solution. :smile: