CUDA:编译我的第一个 cuda 程序时出错
我对 CUDA 编程非常陌生。我编写了第一个代码,当我编译它时,它向我显示了很多错误。谁能告诉我
代码
#include <stdio.h>
#include "cuda.h"
#include <stdlib.h>
__global__ void kernel(void) {
}
int main(int argc, char *argv[])
{
kernel<<<1,1>>>();
printf("finished \n");
return 0;
}
出了什么问题这些错误是
cuda.c:5: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before âvoidâ
cuda.c:7: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before âvoidâ
cuda.c: In function âmainâ:
cuda.c:12: error: âkernelâ undeclared (first use in this function)
cuda.c:12: error: (Each undeclared identifier is reported only once
cuda.c:12: error: for each function it appears in.)
cuda.c:12: error: expected expression before â<â token
我使用编译的
nvcc cuda.c
谁能告诉我我犯了什么错误......
I am very new to CUDA programming.. I wrote my first code and when I compiled it, it is showing me a lots of error. Can anyone tell me what is wrong
the code
#include <stdio.h>
#include "cuda.h"
#include <stdlib.h>
__global__ void kernel(void) {
}
int main(int argc, char *argv[])
{
kernel<<<1,1>>>();
printf("finished \n");
return 0;
}
The errors are
cuda.c:5: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before âvoidâ
cuda.c:7: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before âvoidâ
cuda.c: In function âmainâ:
cuda.c:12: error: âkernelâ undeclared (first use in this function)
cuda.c:12: error: (Each undeclared identifier is reported only once
cuda.c:12: error: for each function it appears in.)
cuda.c:12: error: expected expression before â<â token
I compiled using
nvcc cuda.c
Can anyone tell me what mistake I am making....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
nvcc
通过普通 C 编译器运行.c
文件。将文件重命名为cuda.cu
。nvcc
runs.c
files through the normal C compiler. Rename your file tocuda.cu
.