1 /* ----------------------------------------------------------------------
2    SPARTA - Stochastic PArallel Rarefied-gas Time-accurate Analyzer
3    http://sparta.sandia.gov
4    Steve Plimpton, sjplimp@sandia.gov, Michael Gallis, magalli@sandia.gov
5    Sandia National Laboratories
6 
7    Copyright (2014) Sandia Corporation.  Under the terms of Contract
8    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
9    certain rights in this software.  This software is distributed under
10    the GNU General Public License.
11 
12    See the README file in the top-level SPARTA directory.
13 ------------------------------------------------------------------------- */
14 
15 #ifndef SPARTA_COMM_KOKKOS_H
16 #define SPARTA_COMM_KOKKOS_H
17 
18 #include "comm.h"
19 #include "grid.h"
20 #include "particle_kokkos.h"
21 #include "kokkos_type.h"
22 #include "kokkos_copy.h"
23 
24 namespace SPARTA_NS {
25 
26 template<int NEED_ATOMICS, int HAVE_CUSTOM>
27 struct TagCommMigrateParticles{};
28 
29 template<int NEED_ATOMICS, int HAVE_CUSTOM>
30 struct TagCommMigrateUnpackParticles{};
31 
32 class CommKokkos : public Comm {
33  public:
34 
35   CommKokkos(class SPARTA *);
36   ~CommKokkos();
37   int migrate_particles(int, int*, DAT::t_int_1d);
38   void migrate_cells(int);
39 
40   template<int NEED_ATOMICS, int HAVE_CUSTOM>
41   KOKKOS_INLINE_FUNCTION
42   void operator()(TagCommMigrateParticles<NEED_ATOMICS,HAVE_CUSTOM>, const int&) const;
43 
44   template<int NEED_ATOMICS, int HAVE_CUSTOM>
45   KOKKOS_INLINE_FUNCTION
46   void operator()(TagCommMigrateUnpackParticles<NEED_ATOMICS,HAVE_CUSTOM>, const int&) const;
47 
48  private:
49   DAT::tdual_int_scalar k_nsend;
50   DAT::t_int_scalar d_nsend;
51   HAT::t_int_scalar h_nsend;
52   DAT::t_int_scalar d_nlocal;
53 
54   typedef Kokkos::
55     DualView<Grid::ChildCell*, Kokkos::LayoutRight, DeviceType> tdual_cell_1d;
56   typedef tdual_cell_1d::t_dev t_cell_1d;
57   t_cell_1d d_cells;
58 
59   typedef Kokkos::
60     DualView<Particle::OnePart*, Kokkos::LayoutRight, DeviceType> tdual_particle_1d;
61   typedef tdual_particle_1d::t_dev t_particle_1d;
62   t_particle_1d d_particles;
63 
64   DAT::t_int_1d d_plist;
65   DAT::t_int_1d d_pproc;
66   HAT::t_int_1d h_pproc;
67   DAT::t_char_1d d_sbuf;
68   DAT::t_char_1d d_rbuf;
69 
70   int nbytes_particle,nbytes_total;
71 
72   KKCopy<ParticleKokkos> particle_kk_copy;
73 };
74 
75 }
76 
77 #endif
78 
79 /* ERROR/WARNING messages:
80 
81 */
82