Hi Everyone,
I got on this project where a bunch of C++ code was written, and my job is to distribute the work across the many processors of a GPU. So, the code is broken up as follows:
Main.cpp → does CPU calculations for a while
passData() → change format from vectors, classes, etc., to fit in C-style CUDA code (i.e. going C++ → C)
Kernel.cu → allocate GPU, etc.
I have a method called kernelCall() inside Kernel.cu, but I get the errors:
“error: identifier “kernelCall” is undefined”
I think that’s because I have had to use a Kernel.h method to the prototype of my extern “C” method passData() inside it. So, the compiler seems to complain that there’s no prototype definition of “kernelCall” inside Kernel.h.
If I do add a prototype definition to kernelCall to Kernel.h, then I get the following error:
“error C2144: syntax error : ‘void’ should be preceded by ‘;’”
I suppose this makes sense. How would regular C/C++ style code recognize the CUDA-specific command like global? It can’t.
What am I supposed to do?
EDIT: I excluded Kernel.h from the code, and it literally made no difference. Exact same error. For some reason, my function kernelCall inside of passData(), all of which is in Kernel.cu, cannot be found by the compiler. I don’t know what is up with this. I can’t make any kernel calls.
BTW, I’m running Windows XP Professional 32-bit, CUDA 3.0, Visual Studio 2008. I use the CUDA wizard to setup the project, and several days ago I setup the program to do a dummy test call from inside Kernel.cu to access the GPU, and it worked fine then. I haven’t changed anything in the .cu file until today, but that shouldn’t affect whether or not I can even call the GPU.
EDIT 2: Oh, wow… I didn’t know that the global function had to literally be before the passData() function inside Kernel.cu. Apparently, the order of appearance of code really matters. No one told me this. Oh well, it works!
Thanks in advance,
Daniel