xref: /libCEED/include/ceed/jit-source/hip/hip-ref-qfunction.h (revision 07328cdeb7cc6fe1ac9596b69aea7fe9a5beddd3)
1 // Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors.
2 // All Rights Reserved. See the top-level LICENSE and NOTICE files for details.
3 //
4 // SPDX-License-Identifier: BSD-2-Clause
5 //
6 // This file is part of CEED:  http://github.com/ceed
7 
8 /// @file
9 /// Internal header for HIP backend QFunction read/write kernels
10 #ifndef CEED_HIP_REF_QFUNCTION_H
11 #define CEED_HIP_REF_QFUNCTION_H
12 
13 #include <ceed.h>
14 
15 //------------------------------------------------------------------------------
16 // Read from quadrature points
17 //------------------------------------------------------------------------------
18 template <int SIZE>
19 inline __device__ void readQuads(const CeedInt quad, const CeedInt num_qpts, const CeedScalar* d_u, CeedScalar* r_u) {
20   for (CeedInt comp = 0; comp < SIZE; comp++) {
21     r_u[comp] = d_u[quad + num_qpts * comp];
22   }
23 }
24 
25 //------------------------------------------------------------------------------
26 // Write at quadrature points
27 //------------------------------------------------------------------------------
28 template <int SIZE>
29 inline __device__ void writeQuads(const CeedInt quad, const CeedInt num_qpts, const CeedScalar* r_v, CeedScalar* d_v) {
30   for (CeedInt comp = 0; comp < SIZE; comp++) {
31     d_v[quad + num_qpts * comp] = r_v[comp];
32   }
33 }
34 
35 //------------------------------------------------------------------------------
36 
37 #endif  // CEED_HIP_REF_QFUNCTION_H
38