Question about the workflow of JCuda

Hi, Marco13,
Firstly thanks for your great work of providing us the JCuda which makes it convenient for JAVAers to use the GPU. I am curious about the workflow of JCuda. When the .cubin files are made, we can use JCuda to load them. I wonder the steps to do that are to use JAVA to call the CUDA driver APIs(C version) with JNI and then handle the values returned by JNI. Another problem is that why the extern “c” is essential when writing the .cu files, is it used to tell the compiler that is a C version program? Eager for your reply, thanks~~;P

Hello

I’m afraid that I did not understand the first question, about the driver API and JNI…

The ‘extern "C’" is required to avoid name mangling. The NVCC is internally using a C++ Compiler to compile parts of the Code. With a C++ compiler, you can, for example, have two functions
void doSomething(int value) { … }
void doSomething(float value) { … }
They both have the same name. So to identify the right function, the compiler internally converts the name “doSomething” into two different names, which may look as crazy as “_TZdoSomething_1I” or so.

When you write a function as ‘extern “C”’ then there may only be ONE function with this name, and you can easily identify it with this name, when you want to load the function from the module.

Also see http://en.wikipedia.org/wiki/Name_mangling

bye