CUDA: error compiling my first cuda program

I am very new to CUDA programming. I wrote my first code, and when I compiled it, it shows me a lot of errors. Can someone 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;
}

Mistakes

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 with

nvcc cuda.c

Can anyone tell me what mistake I am making ....

+3
source share
1 answer

nvccruns files .cthrough the regular C compiler. Rename the file to cuda.cu.

+6
source

Source: https://habr.com/ru/post/1778649/


All Articles