4

I have the following files:

// Main.cpp
#include "kernel_util.cuh"

int main()
{
    call_kernel();
}

// kernel_util.cuh
#ifndef KERNEL_UTIL
#define KERNEL_UTIL

#include <cuda_runtime.h>

void call_kernel();

#endif

// kernel_util.cu
#include "kernel_util.cuh"
#include "kernel.curnel"

#define thread 16

void call_kernel() {

    dim3 blocks( ( width + thread - 1 ) / thread, ( height + thread - 1 ) / thread );

    dim3 threads( thread, thread );

    kernel<<<blocks, threads>>>();
}

// kernel.curnel
#ifndef KERNEL
#define KERNEL

#include <cuda_runtime.h>

__global__ void kernel() {

}

#endif

I have Visual Studio 2010 with 64 bit compiler and CUDA 5.0 toolkit installed. Above code compiles successfully but line

kernel<<<blocks, threads>>>();

3rd < gives "expected an expression" error, but code compiles without problems and reaches kernel function.

Configuration properties:

  • cpp file item type c/c++ compiler
  • cu file item type cuda c/c++
  • cuh file item type Does not participate in build
  • curnel file item type Does not participate in build
tomix86
  • 1,336
  • 2
  • 18
  • 29
Ian Decks
  • 241
  • 1
  • 5
  • 14
  • I assume the problem shows up in Intellisense? – Timo Geusch Mar 04 '13 at 15:52
  • what do you mean by that. can you be more specific?? – Ian Decks Mar 04 '13 at 15:53
  • Where do you get the error? Obviously not while compiling, as you said the code compiles cleanly. So the only other area where the error could show up would be the background syntax check in VS, aka Intellisense. – Timo Geusch Mar 04 '13 at 15:56
  • possible duplicate of [Setting up VS 2010 Intellisense for CUDA kernel calls](http://stackoverflow.com/questions/6061565/setting-up-vs-2010-intellisense-for-cuda-kernel-calls) – sgarizvi Mar 04 '13 at 18:18

1 Answers1

2

The IDE (MSVC++) and the compiler front-end used by it for IntelliSense (the autocomplete suggestions, and the red lines under 'incorrect' code) have no idea about CUDA and its peculiar syntax. There are some ways for VS to make sense of most CUDA code, but the choice of <<< >>> for blocks/threads in CUDA is a very unfortunate one that C++ compiler frontends cannot make sense of (at least, it would require very extensive modifications to the parser).

All in all, you have to live with the red squiggly lines below <<< >>>.

us2012
  • 16,083
  • 3
  • 46
  • 62
  • 1
    another answer that i found http://stackoverflow.com/questions/6061565/setting-up-vs-2010-intellisense-for-cuda-kernel-calls – Ian Decks Mar 04 '13 at 16:13