kernel calling a library function? newbie question

Hi everybody,

I just started developing in cuda and my first test programs worked fine.

The setting:
I have a 2D-array of dimensions [n,t] in the memory, and for every n, I want to perform a certain function with the column vector. In my first tests, I just summed up all elements in the vector. But now, I want to call a function from library, passing the vector to the function.

Now the question is: do I have to compile the whole library with nvcc,(and even worse, add device-qualifiers to each function,) or can I just include the header and call the library functions directly from the kernel, without recompiling them?

Oh, and I’m working on Ubuntu 8.04 with gcc 4.2, if that matters.

Best regards,

Michael

Kernel functions (Global/Device) can only invoke other device functions. This can either be a hand-written device function or a device function from the CUDA library.

You cannot just invoke a library function from inside a kernel. Purely recompiling the library file using nvcc will not help either. You will have to recode the function to run on the GPU.

On a side note, do check if the function you need to invoke is in CUBLAS (since you are working with 2D data and vectors) before writing your own.

Oh dear. That was exactly the answer I was afraid of.

Looks like you don’t get the CUDA acceleration for free…

But thanks for the answer, anyway!

There’s no such thing as a free lunch, especially when it comes to writing Parallel Programs! :blink:

In fact, most technology pundits and evangelists are referring to parallel programming as the next computing crisis.

CUDA and GPGPU is just a part of an evolutionary solution to this crisis, much like what SIMULA did for Object Orientation. Hopefully, sometime in the future a programming methodology will be born that amalgamates the best practices and concepts from the clutter of all the solutions out there, much like what C++ or Java did for OOP.