Following the sample code in CUDA samples about C++ integration I was writing the wrapper functions that call CUDA code in a .cu
file.
In that file I have a function that initializes CUDA context and allocates global memory and puts some data in constant memory.
extern "C" void initEngine(int *d_data, int *d_coefA, int *d_coefB)
{
//Allocations
//Copy to constant memory
}
Now what I want to do is overload that initEngine
function to receive to more parameters but I think there's no way to overload that function as it has C linkage am I right?
extern "C" void initEngine(int *d_data, int *d_coefA, int *d_coefB, int *d_coefC,
int *d_random)
{
//Allocations
//Copy to constant memory
}
Could you give me some advise to have only one initEngine
function? or is not possible and I have to have 2 functions or probably have only one function with all the parameters and just pass NULL references or something like that.
Yes, overloading is a C++ feature.
If you want to have overloaded functions that are callable from other modules, use C++ throughout (i.e. don't use extern "C"
, and keep all your files as .cpp or .cu).
If you don't wish to do that, you could try resorting to macros or some other magic.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With