WarpX
QedWrapperCommons.H
Go to the documentation of this file.
1 /* Copyright 2019 Luca Fedeli
2  *
3  * This file is part of WarpX.
4  *
5  * License: BSD-3-Clause-LBNL
6  */
7 #ifndef WARPX_amrex_qed_wrapper_commons_h_
8 #define WARPX_amrex_qed_wrapper_commons_h_
9 /*
10  * This header contains some common #define directives
11  * used by the QED library wrappers and related components.
12  * It also provides a vector type suitable to be used
13  * as the building block of the picsar QED lookup tables
14  * when managed memory is not used.
15  */
16 
17 #include <AMReX_AmrCore.H>
18 #include <AMReX_Extension.H>
19 #include <AMReX_GpuDevice.H>
20 #include <AMReX_GpuQualifiers.H>
21 #include <AMReX_Vector.H>
22 
23 #include <vector>
24 
25 
31 #define PXRMP_WITH_GPU
32 #define PXRMP_GPU_QUALIFIER AMREX_GPU_HOST_DEVICE
33 //_________________________
34 
35 
42 #define PXRMP_RESTRICT AMREX_RESTRICT
43 #define PXRMP_FORCE_INLINE AMREX_FORCE_INLINE
44 //_________________________
45 
46 
47 #ifdef AMREX_USE_GPU
56 template <typename Real>
57 class PicsarQedVector : public std::vector<Real>
58 {
59  using HV = std::vector<Real>;
60  using AGDV = amrex::Gpu::DeviceVector<Real>;
61 
62  public:
63 
70  template<typename... Args>
71  PicsarQedVector(Args&&... args) : HV(std::forward<Args>(args)...)
72  {}
73 
79  void pxr_sync()
80  {
81  m_device_data.resize(this->size());
83  this->begin(), this->end(), m_device_data.begin());
85  }
86 
94  const Real* data() const
95  {
96  return m_device_data.data();
97  }
98 
99  private:
100  AGDV m_device_data;
101 };
102 #else
103 
104 template <typename Real>
105 using PicsarQedVector = std::vector<Real>;
106 
107 #endif
108 
109 #endif //WARPX_amrex_qed_wrapper_commons_h_
std::vector< Real > PicsarQedVector
Definition: QedWrapperCommons.H:105
static void streamSynchronize() noexcept
void copyAsync(HostToDevice, InIter begin, InIter end, OutIter result) noexcept
static constexpr HostToDevice hostToDevice
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Dim3 begin(Box const &box) noexcept
int size
Definition: plot_parallel.py:246
data
Definition: run_alltests_1node.py:325
args
Definition: stencil.py:413