c - Cannot place kernel's prototype in header -


io.cuh:

#ifndef io_cuh #define io_cuh  #include <cuda.h>  typedef struct{     unsigned width;     unsigned height;     unsigned char *image; //rgba }rgb_image;  __global__ void transformtograykernel(rgb_image *img); void decodetwosteps(const char* filename, rgb_image *img); void encodeonestep(const char* filename, rgb_image *img); void processimage(const char *filename, rgb_image *img);  #endif // io_cuh 

i'm trying compile simple program using following makefile:

lodepng.o: lodepng.h         cc -c lodepng.c -o lodepng.o io.o: io.cuh lodepng.o         nvcc -c io.cu -o io.o main: io.o         nvcc main.c io.o -o main 

'main.c' uses 1 function io.cu, dependent on lodepng.c.

after minor warnings reference code, got following error:

nvcc main.c io.o -o main nvcc warning : 'compute_10' , 'sm_10' architectures deprecated, , may removed in future release. in file included main.c:1:0: io.cuh:12:12: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘void’ global void transformtograykernel(rgb_image *img); ^ makefile:6: recipe target 'main' failed make: *** [main] error 1

the error caused key word __global__, not kernel's prototype.

that's because compiler nvcc interpret input file, , choose corresponding rule compile it. although use nvcc compile "main.c", treated c source file, not cuda source code. compiler can not recognize cuda key word __global__ when compile file "main.c".

you can change file type "main.c" "main.cu", , treated cuda source code. compiler can recognize key word __global__.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -