Re: [deal.II] Copying field evaluated at quadrature points to device via CUDA

2021-08-09 Thread Daniel Arndt
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

Am Mo., 9. Aug. 2021 um 14:22 Uhr schrieb Lucas Myers <
lucasmyer...@gmail.com>:

> 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
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/dealii/05ff3360-2772-4740-97d5-47b41f2ad052n%40googlegroups.com
> 
> .
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/CAOYDWbL4yyj3%3DNJhqnVd5xoy7ufzpNeH698ioP4kRAzZ4p41%2Bg%40mail.gmail.com.


[deal.II] Copying field evaluated at quadrature points to device via CUDA

2021-08-09 Thread Lucas Myers
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

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/05ff3360-2772-4740-97d5-47b41f2ad052n%40googlegroups.com.