如何让 VS 2010 识别某些 CUDA 函数
目前 CUDA 已经识别了关键的 CUDA C/C++ 函数,例如 cudaMalloc
、cudaFree
、cudaEventCreate
等。
它还识别某些类型,例如dim3
和 cudaEvent_t
。
但是,它无法识别其他函数和类型,例如纹理模板、__syncthreads 函数或atomicCAS 函数。
一切都编译得很好,但我厌倦了看到到处都是红色下划线,我想看到当您键入任何可识别的函数时显示的示例参数。
如何让 VS 捕获这些函数?
At the moment CUDA already recognizes a key CUDA C/C++ function such as cudaMalloc
, cudaFree
, cudaEventCreate
, etc.
It also recognizes certain types like dim3
and cudaEvent_t
.
However, it doesn't recognize other functions and types such as the texture template, the __syncthreads
functions, or the atomicCAS
function.
Everything compiles just fine, but I'm tired of seeing red underlinings all over the place and I want to the see the example parameters displayed when you type in any recognizable function.
How do I get VS to catch these functions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以创建以下形式的虚拟 #include 文件:
这应该对 CUDA 和 Visual C++ 编译器隐藏假原型,但仍使它们对 IntelliSense 可见。
__INTELLISENSE__
宏的来源:http ://blogs.msdn.com/b/vcblog/archive/2011/03/29/10146895.aspxYou could create a dummy #include file of the following form:
This should hide the fake prototypes from the CUDA and Visual C++ compilers, but still make them visible to IntelliSense.
Source for
__INTELLISENSE__
macro: http://blogs.msdn.com/b/vcblog/archive/2011/03/29/10146895.aspx您需要将 CUDA 特定的关键字(例如 __syncthreads)添加到 Visual Studio 的 usertype.dat 文件中。 NVIDIA CUDA SDK 中包含一个示例 usertype.dat 文件。您还需要确保 Visual Studio 将 .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
You need to add CUDA-specific keywords like __syncthreads to the usertype.dat file for visual studio. An example usertype.dat file is included with the NVIDIA CUDA SDK. You also need to make sure that visual studio recognizes .cu files as c/c++ files as described in this post:
Note however that where that post uses
$(CUDA_INC_PATH)
, with recent versions of CUDA you should use$(CUDA_PATH)/include
.Also, I would recommend Visual Assist X -- not free, but worth the money -- to improve intellisense. It works well with CUDA if you follow these instructions:
http://www.wholetomato.com/forum/topic.asp?TOPIC_ID=5481
http://forums.nvidia.com/index.php?showtopic=53690