Hello,
I have a working C++ code wich is compiled using cmake. I am trying to call a CUDA wrapper function declared in a .cu file with the corresponding kernel but i get the error: undefined reference to “cuda_wrapper()”
I am including the corresponding .h of the .cu inside the .cpp file where the wrapper is called and for some reason i still get the error. An interesting thing is that i have tried to call this wrapper doing the same modificatios in other.cpp files in the same folder and for some of them, compiling is completed succesfully. I don’t know why it works for some .cpp but not in the one i need, even though they are all in the same folder and i include everything the exact same way.
Here there are some simplified versions of my files to make it clearer:
cuda.cu looks like this
#include "cuda.h"
__global__ void kernel(a,b) {
... some calculations...
}
void cuda_wrapper() {
...
kernel<<<dimGrid, dimBlock>>>(a,b);
...
}
cuda.h looks like this
void cuda_wrapper();
file.cpp looks like this
#include "cuda.h"
...
cuda_wrapper(); // Calling the wrapper from C++ file -> undefined reference error
I am not being able to make the cuda_wrapper() callable from the C++ file, what can i do to make it work?