__syncthreads(); is undefined need a help

Ive got a big problem, cause my MS Visual Studio 2010 dont recognise __syncthreads();
Here’s a screenshot from my PC, keep in mind that ive opened mine first program on the list,
it doesent matter what does it do, its completely relevant. I just put a standart __syncthreads();
to show You all whats seems to be a problem. In everyone case ive go same result, its reports me,
that __syncthreads(); is undefined.

Im using MS Visual Studio Ultimate 2010, with Paralel Nsight 2.1, and ofcourse CUDA Tollkit 4.1.
All other things, commands, includes seems to work, except this one. I cant do much without thread synchronistaion,
and this is really annoying. Ive already tried to manualy include aditional path of includes from CUDA Toolkit 4.1 directory,
but still got the same problem. Please, help me.

What are the

#include <cuda.h>

#include <cuda_runtime_api.h>

#include <device_launch_parameters.h>

lines for? Seems to me the code gets compiled as normal C++ code and not as CUDA code, otherwise these lines would be unnecessary.

I have no experience with CUDA under Visual Studio/Windows though, so somebody else needs to help you with setting it up.

Hey Naiilo

Try adding :

#include <device_functions.h>

Stefan

@Stefano5 Still, same result :(

@tera yes you are right, cuda_runtime_api.h is in fact unnesesary while cuda.h is included, the other header is helping to read the correct device parameters, while using PC with different graphic cards.

This one worked for me:

#ifndef CUDACC
#define CUDACC
#endif
#include “cuda_runtime.h”
#include “device_launch_parameters.h”
#include <cuda.h>
#include <device_functions.h>
#include <cuda_runtime_api.h>

@see this:http://stackoverflow.com/questions/13893919/cuda-syncthreads-compiles-fine-but-is-underlined-with-red

This is just an intellisense warning. It can be safely ignored if your project is set up properly.

I’m not sure defining CUDACC in host code is a good idea.

@txbob is right. I am using only
#include “cuda_runtime.h”
#include “device_launch_parameters.h”
and it still compiles although the Intellisense says it’s wrong.

If you’re going to work this hard to get rid of the red underlines that you want to define CUDACC, I would suggest wrapping it in an INTELLISENSE ifdef as discussed here:

By doing it that way, I think you are minimizing the possibility of unintended side-effects.

Hi i’m suffring from the same problem. Did you find any solution ?

A simple solution is to hide it from Visual Studio such as

#ifdef __CUDACC__
#define cuda_SYNCTHREADS() __syncthreads()
#else
#define cuda_SYNCTHREADS()
#endif

try adding:

#ifndef CUDACC
#define CUDACC
#endif
#include <cuda.h>
#include <device_functions.h>

I suggest that you should not define CUDACC in your code all the time. Instead, do something like this:

#ifdef __INTELLISENSE___

// in here put whatever is your favorite flavor of intellisense workarounds

#endif

not directly related to CUDA, but discusses how to modify intellisense “behavior”:
https://blogs.msdn.microsoft.com/vcblog/2011/03/29/troubleshooting-tips-for-intellisense-slowness/