问题
Why can't I use these compiler intrinsics in CUDA 5.0?
In Visual Studio 2010, with CUDA toolkit 5.0 and Nsight installed I am able to compile and run most CUDA code, but __fadd_ru
etc are reported as undefined. This is the code I am trying to compile.
Edit: It seems that the intrinsics become undefined when either of the following includes are made in the same project:
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
回答1:
The problem is caused (somehow), by including CUDA runtime headers in the project.
The NVCC compiler manages the includes for the cuda runtime automatically, so you don't need to include it manually to compile. The main reason you would add
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
to your code is so that your IDE won't show false syntax errors. For some reason adding device_launch_parameters.h
(which cuda_runtime.h
depends on), will cause NVCC's intrinsic compiler functions for arithmetic to appear undefined.
So the fix: remove those two includes from the project when you want to compile.
来源:https://stackoverflow.com/questions/13966469/why-dont-the-cuda-compiler-intrinsics-fadd-rd-etc-work-for-me