I have some calls in a .cpp file, to the cuSPARSE library, that are not available in older toolkits. In order to support systems with older toolkits, I want to compile different sections of code using compiler directives. In particular, I want to solve sparse triangular systems using matrices in CSR format for old toolkits and BSR format for new toolkits.
The problem is, I'm not compiling any actual CUDA code in this section with nvcc, just making library calls, so the nvcc macros to get version information are not available.
There is a #define of __CUDA_API_VERSION in cuda.h, but it is 0 when compiling my .cpp regardless of whether I include cuda.h.
How can I get information about the toolkit version at compile time in this case? I'm working in CentOS 7 and compiling my .cpp with g++.
cuda_runtime_api.h
in your .cpp file, and use theCUDART_VERSION
define that is included there.8000
= CUDA 8.0.7050
= CUDA 7.5, etc. You are probably includingcuda_runtime_api.h
anyway if you are for example usingcudaMalloc
/cudaMemcpy
in your .cpp file – Robert Crovella