I\'ve been trying to transform some cuda/C code into a more OO code, but my goal doesn\'t seem to be easy to achieve for my current understanding of the cuda functionin
What has worked best for me is to only put regular CUDA functions, kernels and kernel launches in CUDA C (.cu
) files, and then build an object oriented interface on top of that, with classes in C++ (.cpp
) files.
So, in your class constructor, you call functions in your .cu
file that allocate and initialize memory and in your methods, you call functions that launch kernels, etc.
This can also make development turnaround faster because you can often change your classes without incurring recompile of .cu
files, which is much slower than compiling pure .cpp
files.