How to reimplement Function::eval in cuda-compatible cpp ?


89
views
0
4 months ago by
Hello, I am trying to rebuild a silicon detector simulator including Cuda implementatio of the electron drifting. I do not need GPU for solving Poisson's equation, only for moving particles inside the calculated electric field. The problem I encounter is that I need to call Function::eval from the GPU in order to get the value of the fields in a given point but I cannot call directly fenics' specific functions withing device(GPU) code in cuda. My first approach is to create my own map of values and pass that to the GPU but it seems very inneficient to me.

Is there a way to replace Function::eval with a function of my own that would have similar behaviour but would not require calling fenics functions for sampling the given field?
Maybe there is a cuda-compatible version of fenics that I am not aware of? If so it would be ideal if it was 1.6 or lower since I would have to fix compatibility of the simulator for higher versions.

In case it helps, the code (only for CPU) can be seen here: https://github.com/IFCA-HEP/TRACS/ . The part of the simulation I am focusing on implementing in Cuda is Carrier::simulate_drift(double dt, double max_time, double x_init, double y_init )

Thank you very much for any help 

Alvaro Diez
Community: FEniCS Project

1 Answer


0
4 months ago by
@Alvaro:
I don't see how the problem is any different than passing an array of values from the cpu to  gpu.  The values must be evaluated at whatever spatial points you use in the gpu algorithm and then transferred.  However, if you can use the dof points, then you can just transfer the u->vector() of dofs directly (which skips calling eval() method).  You can find the mapping of dofs to spatial (x,y) points via the mesh->coords().  However, if you need points interpolated between the dofs, you will have to call eval(), or make the interpolation yourself.

I do not know of any gpu implemented dolfin code.  Perhaps just xfer of the vector of dofs is what you want.
Please login to add an answer/comment or follow this question.

Similar posts:
Search »