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

查看:27
本文介绍了为 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++ 提供了 IntelliSense,火箭科学家博客的技巧基本上依赖于 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 提出这种语法的人并不是语言专家,他碰巧选择了最糟糕的分隔符,然后将其增加了三倍,好吧,你会遇到麻烦.当 Intellisense 看到这一点时,它竟然还能工作,真是太神奇了.

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天全站免登陆