I need to pass in some arbitrary mathematical function to the CUDA kernel. Could some one please guide me on how to do this. Any starting point, examples or links to any existing libraries appreciated. Thanks
For reference, how are you currently implementating this functionality in your host (CPU) code? Can you provide more context?
One approach could be to compile kernel code on the fly (either by invoking nvcc from within your application, or creating your own PTX code generator) then loading the resulting binary through the low-level interface provided by the CUDA driver API. This is an approach used by various applications. You could also implement an interpreter in your CUDA kernel. That’s probably very slow but I have not tried it.