Reuse Code for CPU and GPU


i’g like to have my code to be used in cpu and gpu. Most of the algorithm is exactly the same. How can I achive this without copying the code into cuda functions to avoid redundancy. Of course, the cuda code got some stuff around it.

You can define functions with both attributes host and device this way you could use the same functions in both host. You will still need to have global kernels, though, but you could reuse the basic functions.

Move the common code to host device functions.