Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting up Visual Studio Intellisense for CUDA kernel calls

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/

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

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; } 

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.

like image 325
sj755 Avatar asked May 19 '11 16:05

sj755


People also ask

Can I use CUDA with Visual Studio code?

Remote Development SupportNsight Visual Studio Code Edition enables developers to implement CUDA code in various cluster environments such as Virtual Machines or remote Docker containers. It also supports code development for Linux systems via the Remote – WSL extension.

Are CUDA calls blocking?

Most CUDA calls are synchronous (often called “blocking”). An example of a blocking call is cudaMemcpy().


1 Answers

Wow, lots of dust on this thread. I came up with a macro fix (well, more like workaround...) for this that I thought I would share:

// nvcc does not seem to like variadic macros, so we have to define // one for each kernel parameter list: #ifdef __CUDACC__ #define KERNEL_ARGS2(grid, block) <<< grid, block >>> #define KERNEL_ARGS3(grid, block, sh_mem) <<< grid, block, sh_mem >>> #define KERNEL_ARGS4(grid, block, sh_mem, stream) <<< grid, block, sh_mem, stream >>> #else #define KERNEL_ARGS2(grid, block) #define KERNEL_ARGS3(grid, block, sh_mem) #define KERNEL_ARGS4(grid, block, sh_mem, stream) #endif  // Now launch your kernel using the appropriate macro: kernel KERNEL_ARGS2(dim3(nBlockCount), dim3(nThreadCount)) (param1);  

I prefer this method because for some reason I always lose the '<<<' in my code, but the macro gets some help via syntax coloring :).

like image 192
Randy Avatar answered Sep 28 '22 17:09

Randy