I have been working with CUDA 4.2 for a week now and I have a little problem. When I write the __syncthreads() function it becomes underlined and looks like it is wrong...
我已经和CUDA 4.2合作了一个星期了,我有一个小问题。当我编写__syncthreads()函数时,它就会下划线,看起来好像是错误的……
Then if I put the mouse on the function it appears a message writing:
然后,如果我把鼠标放在函数上,它就会显示一条消息:
identifier __syncthreads(); is undefined.
标识符__syncthreads();是未定义的。
but when i compile my project the output form build says:
但当我编译我的项目时,输出表单构建说:
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
= = = = = = = = = =构建:1成功,0失败了,最新的,0跳过= = = = = = = = = =
So I am guessing that everything works fine but the fact that Visual Studio underlines the function is confusing me...How can I make Visual studio to know that this function is defined before the compiling process?
所以我猜一切都很好,但是Visual Studio强调这个功能的事实让我很困惑……如何让Visual studio知道在编译过程之前定义了这个函数?
NOTE:The same thing happens with the kernel call: kernel<<<...,...>>> where the third "<" is underlined red too...
注意:内核调用也会发生同样的事情:内核<<…>>>,第三个“<”下划线为红色……
I know that this probably is a minor problem but i want to solve it...Thanks a lot! I am using Visual Studio 2010 on win7 with Cuda 4.2 and Nsight 2.2
我知道这可能是一个小问题,但我想解决它……谢谢!我在win7上使用Visual Studio 2010, Cuda 4.2和Nsight 2.2
3 个解决方案
#1
2
I added the following few lines to the top of the cu file and it began to recognize these functions. For some reason, Intellisense did not pick up this #define:
我在cu文件的顶部添加了以下几行,它开始识别这些函数。出于某种原因,Intellisense并没有接收到这个#define:
#ifndef __CUDACC__
#define __CUDACC__
#endif
I lost some color-coding in the code, but I no longer get strange false positive errors.
我在代码中丢失了一些颜色编码,但我不再得到奇怪的假阳性错误。
#2
0
I have CUDA 8.0
and Visual Studio 2015
and I had the same issue. The below lines helped me:
After these lines: (already in code)
我有CUDA 8.0和Visual Studio 2015,我也有同样的问题。以下几行帮助了我:在这些行之后:(已经在代码中)
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
I added these lines:
我添加了这些线:
//for __syncthreads()
#ifndef __CUDACC_RTC__
#define __CUDACC_RTC__
#endif // !(__CUDACC_RTC__)
#include <device_functions.h>
It's based on this link: https://devtalk.nvidia.com/default/topic/1009723/__syncthreads-and-atomicadd-are-undefined-in-visual-studio-2015/
它基于这个链接:https://devtalk.nvidia.com/default/topic/1009723/ __syncthread-atomicadd - undefin- in- visualstudio -2015/
#3
0
I am using CUDA 9.1
and Visual Studio 2017 15.6.4
. The following code helps me eliminate the "__syncthreads() is undefined" error.
我正在使用CUDA 9.1和Visual Studio 2017 15.6.4。下面的代码帮助我消除了“__syncthreads()是未定义的”错误。
//for __syncthreads()
#ifndef __CUDACC__
#define __CUDACC__
#endif
#include <device_functions.h>
However, this method is not recommended because it may bring unpredictable side effects. Another method to solve this intellisense warning is:
然而,不推荐这种方法,因为它可能带来不可预知的副作用。解决这个智能感知警告的另一种方法是:
#ifdef __INTELLISENSE___
// in here put whatever is your favorite flavor of intellisense workarounds
#endif
Reference: __syncthreads(); is undefined need a help
参考:__syncthreads();未定义需要帮助吗
#1
2
I added the following few lines to the top of the cu file and it began to recognize these functions. For some reason, Intellisense did not pick up this #define:
我在cu文件的顶部添加了以下几行,它开始识别这些函数。出于某种原因,Intellisense并没有接收到这个#define:
#ifndef __CUDACC__
#define __CUDACC__
#endif
I lost some color-coding in the code, but I no longer get strange false positive errors.
我在代码中丢失了一些颜色编码,但我不再得到奇怪的假阳性错误。
#2
0
I have CUDA 8.0
and Visual Studio 2015
and I had the same issue. The below lines helped me:
After these lines: (already in code)
我有CUDA 8.0和Visual Studio 2015,我也有同样的问题。以下几行帮助了我:在这些行之后:(已经在代码中)
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
I added these lines:
我添加了这些线:
//for __syncthreads()
#ifndef __CUDACC_RTC__
#define __CUDACC_RTC__
#endif // !(__CUDACC_RTC__)
#include <device_functions.h>
It's based on this link: https://devtalk.nvidia.com/default/topic/1009723/__syncthreads-and-atomicadd-are-undefined-in-visual-studio-2015/
它基于这个链接:https://devtalk.nvidia.com/default/topic/1009723/ __syncthread-atomicadd - undefin- in- visualstudio -2015/
#3
0
I am using CUDA 9.1
and Visual Studio 2017 15.6.4
. The following code helps me eliminate the "__syncthreads() is undefined" error.
我正在使用CUDA 9.1和Visual Studio 2017 15.6.4。下面的代码帮助我消除了“__syncthreads()是未定义的”错误。
//for __syncthreads()
#ifndef __CUDACC__
#define __CUDACC__
#endif
#include <device_functions.h>
However, this method is not recommended because it may bring unpredictable side effects. Another method to solve this intellisense warning is:
然而,不推荐这种方法,因为它可能带来不可预知的副作用。解决这个智能感知警告的另一种方法是:
#ifdef __INTELLISENSE___
// in here put whatever is your favorite flavor of intellisense workarounds
#endif
Reference: __syncthreads(); is undefined need a help
参考:__syncthreads();未定义需要帮助吗