为CUDA内核调用设置Visual Studio Intellisense [英] Setting up Visual Studio Intellisense for CUDA kernel calls

查看:229
本文介绍了为CUDA内核调用设置Visual Studio Intellisense的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始CUDA编程,现在一切都很好,我的GPU可以识别。我在这里使用此非常有用的指南在Visual Studio中部分设置了Intellisense:
http://www.ademiller.com/blogs/tech/2010/10/visual-studio-2010-adding -intellisense-support-for-cuda-c /

I've just started CUDA programming and it's going quite nicely, my GPUs are recognized and everything. I've partially set up Intellisense in Visual Studio using this extremely helpful guide here: http://www.ademiller.com/blogs/tech/2010/10/visual-studio-2010-adding-intellisense-support-for-cuda-c/

此处:
http:// www.ademiller.com/blogs/tech/2011/05/visual-studio-2010-and-cuda-easier-with-rc2 /

但是,Intellisense仍然没有像这样进行内核调用:

However, Intellisense still doesn't pick up on kernel calls like this:

// KernelCall.cu
#include <iostream>
#include "cuda.h"
#include "cuda_runtime.h"
#include "device_launch_parameters.h"

__global__ void kernel(void){}

int main()
{
    kernel<<<1,1>>>();

    system("pause");
    return 0;
}

行内核<<< 1,1 >>>()用红色下划线标记,特别是第一个箭头左侧的一个箭头,错误显示为错误:期望和表达式。但是,如果将鼠标悬停在该函数上,它将正确显示其返回类型和参数。仍然可以正常编译,我想知道如何摆脱这种小麻烦。

The line kernel<<<1,1>>>() is underlined in red, specifically the one arrow to the left of the first one with the error reading "Error: expected and expression". However, if I hover over the function, its return type and parameters are displayed properly. It still compiles just fine, I'm just wondering how to get rid of this little annoyance.

推荐答案

Visual Studio为C ++,这是火箭科学家博客中的窍门,基本上是依靠CUDA-C与C ++的相似之处,仅此而已。

Visual Studio provides IntelliSense for C++, the trick from the rocket scientist's blog is basically relying on the similarity CUDA-C has to C++, nothing more.

在C ++语言中,正确解析角度括号很麻烦。对于模板,您有< 小于和,模板有<< ,请记住不要长

In the C++ language, the proper parsing of angle brackets is troublesome. You've got < as less than and for templates, and << as shift, remember not long ago when we had to put a space in between nested template declarations.

因此,事实证明NVIDIA提出此语法的人不是语言专家,碰巧选择了最糟糕的定界符,然后将其增加了三倍,那么,您将遇到麻烦。

So it turns out that the guy at NVIDIA who came up with this syntax was not a language expert, and happened to choose the worst possible delimiter, then tripled it, well, you're going to have trouble. It's amazing that Intellisense works at all when it sees this.

我知道在CUDA中获得完整IntelliSense的唯一方法是从运行时API切换到驱动程序API。 C ++只是C ++,而CUDA仍是C ++(的其中一种),对于语言解析,没有<<<>> 的缺点。必须解决。

The only way I know to get full IntelliSense in CUDA is to switch from the Runtime API to the Driver API. The C++ is just C++, and the CUDA is still (sort of) C++, there is no <<<>>> badness for the language parsing to have to work around.

这篇关于为CUDA内核调用设置Visual Studio Intellisense的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆