English 中文(简体)
如何让VS 2010识别某些CUDA功能
原标题:How to get VS 2010 to recognize certain CUDA functions

目前,CUDA已经识别出一个关键的CUDA C/C++函数,如cudaMalloccudaFreecudaEventCreate等。

它还可以识别某些类型,如dim3cudaEvent_t

但是,它无法识别其他函数和类型,例如纹理模板、__syncthreads函数或atomicCAS功能。

一切都编译得很好,但我厌倦了到处都是红色的下划线,我想看看当你输入任何可识别的函数时显示的示例参数。

如何让VS捕获这些函数?

问题回答

您可以创建以下形式的伪#include文件:

#pragma once
#ifdef __INTELLISENSE__
void __syncthreads();
...
#endif

这应该会对CUDA和Visual C++编译器隐藏伪原型,但仍然使它们对IntelliSense可见。

__INTELLISENSE__宏的来源:http://blogs.msdn.com/b/vcblog/archive/2011/03/29/10146895.aspx

您需要将特定于CUDA的关键字(如__syncthreads)添加到visualstudio的usertype.dat文件中。NVIDIA CUDA SDK中包含一个示例usertype.dat文件。您还需要确保visualstudio将.cu文件识别为c/c++文件,如这篇文章

但是,请注意,如果该帖子使用$(CUDA_INC_PATH),则对于最新版本的CUDA,应使用$(CUDA _PATH)/include

此外,我建议Visual Assist X--不是免费的,但物有所值--可以提高智能。如果您遵循以下说明,它可以很好地与CUDA配合使用:

http://www.wholetomato.com/forum/topic.asp?TOPIC_ID=5481

http://forums.nvidia.com/index.php?showtopic=53690





相关问题
Why won t OpenCV compile in NVCC?

I am trying to integrate CUDA and openCV in a project. Problem is openCV won t compile when NVCC is used, while a normal c++ project compiles just fine. This seems odd to me, as I thought NVCC ...

error in CUDA compilation

I m getting this error while trying to run sample codes in CUDA SDK. I have CUDA 2.3 and Visual studio 2008 LINK : fatal error LNK1181: cannot open input file cutil32D.lib Any pointers how to ...

CUDA Memory Allocation accessible for both host and device

I m trying to figure out a way to allocate a block of memory that is accessible by both the host (CPU) and device (GPU). Other than using cudaHostAlloc() function to allocate page-locked memory that ...

热门标签