How to fix error : unrecognized token in Cuda code with nvcc compiler
3 次查看(过去 30 天)
显示 更早的评论
I wrote this simple code Cuda in Notepad, which I followed in example: http://www.mathworks.com/help/distcomp/executing-cuda-or-ptx-code-on-the-gpu.html
_global_ void add1( double * pi, double c ) { *pi += c; }
>>then I run it on command line in the current directory: nvcc test.cu I received error with a lot of line "error : unrecognized token"
I don't know what is it and how to fix it. Please help me! I use Cuda 5.0, GPU 720M with Cuda-capable 2.0 Thanks!
0 个评论
采纳的回答
Ben Tordoff
2013-7-26
There are two problems with what you have attempted, one just a typo and the solution to the other will depend on what you are trying to do. First the typo: you are missing an underscore from each side of the global decorator - they should be double underscores:
__global__ void add1(double * pi, double c)
{
*pi += c;
}
Now the more important question: what are you trying to achieve? If you are trying to create a PTX file for use with parallel.gpu.CUDAKernel then you need to compile to PTX:
$ nvcc -ptx -arch=sm_20 <filename>.cu
which will procude <filename>.ptx. If you are trying to make a standalone executable then you need to also define a main function as you would for any C++ program.
4 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 GPU Computing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!