Copying field evaluated at quadrature points to device via CUDA

21 views
Skip to first unread message

Lucas Myers

unread,
Aug 9, 2021, 2:21:59 PM8/9/21
to deal.II User Group
Hi folks,

As I understand it, the standard way of looping through a finite element problem is to iterate through (1) each cell in the mesh, (2) each quadrature point in the cell, (3) the ith shape functions, and (4) the jth shape functions. Given that, would it be possible to copy a finite element field evaluated at all of the quadrature points into an (n_cells x n_q_points_per_cell) array/vector/matrix/whatever? 

My purpose for doing this would be to copy this array over to a GPU device in order to perform a (somewhat complicated) function inversion in parallel on all of the quadrature point values, and then pass the inverted points back to the host. I have two questions regarding this business:
  1. If, after I have iterated through all cells/quadrature points and processed my data, I iterate again through the mesh/q_points/shape functions in order to fill in my matrix as in a typical FE problem, will the iteration go back through in the same way as the first time? That is, will I be able to index the processed data in the same way that I indexed the initial data that I copied over? This might be obvious, but I ask because the cell iterators are a seemingly complicated object that I don't understand fully yet.
  2. Is there a better way to do this process using already-written dealii objects (e.g. in the CUDAWrappers namespace)? I ask because I'm having a little bit of trouble parsing the step-64 comments, particularly regarding the management of different CUDA memory locations (e.g. how often does each object access global memory?). 
In any case, thank you for any help and for any general tips on the problem.

Kind regards,
Lucas

Daniel Arndt

unread,
Aug 9, 2021, 3:39:26 PM8/9/21
to dea...@googlegroups.com
Lucas,

In case you are using the GPU matrix-free framework as described in step-64, you can use CUDAWrappers::MatrixFree::evaluate_coefficients() to to perform the function inversion.
Otherwise, you need to keep track of the mapping from cells/quadrature points to vector indices yourself. So you would fill a CUDA accessible vector with the quadrature points and use that to fill the data vector you want to perform your function inversion one. LinearAlgebra::distributed::Vector with MemorySpace::CUDA should work well for that.

Best,
Daniel

--
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en
---
You received this message because you are subscribed to the Google Groups "deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dealii+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/05ff3360-2772-4740-97d5-47b41f2ad052n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages