I’m exploring various options for mapping common C # code constructs with C ++ CUDA code to work on the GPU. The structure of the system is as follows (arrows represent method calls):
C # program → C # GPU lib → C ++ CUDA implementation of lib
A method in the GPU library might look something like this:
public static void Map<T>(this ICollection<T> c, Func<T,T> f)
{
//Call 'f' on each element of 'c'
}
This is an extension method for ICollection <> types that run a function for each element. However, what I would like to do is call the C ++ library and make it run the methods on the GPU. This will require that the function be somehow translated into C ++ code. Is it possible?
To develop, if a user of my library executes a method (in C #) with some arbitrary code in it, I would like to translate this code into the C ++ equivalent so that I can run it on CUDA. I have the feeling that there is no easy way to do this, but I would like to know if there is a way to do this or achieve the same effect.
One thing that I was curious about was grabbing a function for translating in an expression and using it to match with the C ++ equivalent. Does anyone have any experience?
source
share