I’m developing a app in C programming language on Ubuntu Linux
I write my app in C (not c++) and I’m using OpenGL and OpenMP
now I need to accelerate my code with CUDA and I knew that nvcc compile host code to c++ not c
but I need an example to write c file that call cuda function that is written inside a .cu file and how to compile, link, execute them.
“I knew that nvcc compile host code to c++ not c”
i was under the impression that host cost is passed to the host compiler, as part of the complete tool chain (gnu in the case of linux)
you can extern c code, but i am not sure whether it is even necessary
i am not sure whether gnu is that tight about c/c++ interop
most of my code is c, and i hardly extern it
in any case, there is an c/c++ interop sample as part of the cuda samples, if my memory does not fail me
/* callee.cu */
__global__ void kernel_func(...) { ... }
extern "C" void kick_kernel(...) {
kernel_func<<<grid,block>>>(...);
}
and:
/* caller.c */
void kick_kernel(...);
int main() {
kick_kernel(...);
return 0;
}