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 #ifdef COMPUTE_CLASS
16 
17 ComputeStyle(grid/kk,ComputeGridKokkos)
18 
19 #else
20 
21 #ifndef SPARTA_COMPUTE_GRID_KOKKOS_H
22 #define SPARTA_COMPUTE_GRID_KOKKOS_H
23 
24 #include "compute_grid.h"
25 #include "kokkos_base.h"
26 #include "kokkos_type.h"
27 
28 namespace SPARTA_NS {
29 
30 template<int NEED_ATOMICS>
31 struct TagComputeGrid_compute_per_grid_atomic{};
32 
33 struct TagComputeGrid_compute_per_grid{};
34 struct TagComputeGrid_NUM{};
35 struct TagComputeGrid_MASS{};
36 struct TagComputeGrid_NRHO{};
37 struct TagComputeGrid_MASSRHO{};
38 struct TagComputeGrid_NFRAC{};
39 struct TagComputeGrid_U{};
40 struct TagComputeGrid_KE{};
41 struct TagComputeGrid_TEMPERATURE{};
42 struct TagComputeGrid_EROT{};
43 struct TagComputeGrid_TROT{};
44 struct TagComputeGrid_PXRHO{};
45 struct TagComputeGrid_KERHO{};
46 
47 class ComputeGridKokkos : public ComputeGrid, public KokkosBase {
48  public:
49   ComputeGridKokkos(class SPARTA *, int, char **);
50   ~ComputeGridKokkos();
51   void compute_per_grid();
52   void compute_per_grid_kokkos();
53   int query_tally_grid_kokkos(DAT::t_float_2d_lr &);
54   void post_process_grid_kokkos(int, int, DAT::t_float_2d_lr, int *,
55                                   DAT::t_float_1d_strided);
56   void reallocate();
57 
58   template<int NEED_ATOMICS>
59   KOKKOS_INLINE_FUNCTION
60   void operator()(TagComputeGrid_compute_per_grid_atomic<NEED_ATOMICS>, const int&) const;
61 
62   KOKKOS_INLINE_FUNCTION
63   void operator()(TagComputeGrid_compute_per_grid, const int&) const;
64 
65   KOKKOS_INLINE_FUNCTION
66   void operator()(TagComputeGrid_NUM, const int&) const;
67 
68   KOKKOS_INLINE_FUNCTION
69   void operator()(TagComputeGrid_MASS, const int&) const;
70 
71   KOKKOS_INLINE_FUNCTION
72   void operator()(TagComputeGrid_NRHO, const int&) const;
73 
74   KOKKOS_INLINE_FUNCTION
75   void operator()(TagComputeGrid_MASSRHO, const int&) const;
76 
77   KOKKOS_INLINE_FUNCTION
78   void operator()(TagComputeGrid_NFRAC, const int&) const;
79 
80   KOKKOS_INLINE_FUNCTION
81   void operator()(TagComputeGrid_U, const int&) const;
82 
83   KOKKOS_INLINE_FUNCTION
84   void operator()(TagComputeGrid_KE, const int&) const;
85 
86   KOKKOS_INLINE_FUNCTION
87   void operator()(TagComputeGrid_TEMPERATURE, const int&) const;
88 
89   KOKKOS_INLINE_FUNCTION
90   void operator()(TagComputeGrid_EROT, const int&) const;
91 
92   KOKKOS_INLINE_FUNCTION
93   void operator()(TagComputeGrid_TROT, const int&) const;
94 
95   KOKKOS_INLINE_FUNCTION
96   void operator()(TagComputeGrid_PXRHO, const int&) const;
97 
98   KOKKOS_INLINE_FUNCTION
99   void operator()(TagComputeGrid_KERHO, const int&) const;
100 
101   DAT::tdual_float_1d k_vector_grid;
102 
103  private:
104   DAT::tdual_float_2d_lr k_tally;
105   DAT::t_float_2d_lr d_tally;
106   int need_dup;
107   Kokkos::Experimental::ScatterView<F_FLOAT**, typename DAT::t_float_2d_lr::array_layout,DeviceType,typename Kokkos::Experimental::ScatterSum,typename Kokkos::Experimental::ScatterDuplicated> dup_tally;
108   Kokkos::Experimental::ScatterView<F_FLOAT**, typename DAT::t_float_2d_lr::array_layout,DeviceType,typename Kokkos::Experimental::ScatterSum,typename Kokkos::Experimental::ScatterNonDuplicated> ndup_tally;
109 
110   DAT::t_float_2d_lr d_etally;
111   DAT::t_float_1d_strided d_vec;
112 
113   t_cinfo_1d d_cinfo;
114   t_particle_1d d_particles;
115   t_species_1d d_species;
116   DAT::t_int_2d d_s2g;
117 
118   DAT::t_int_1d d_cellcount;
119   DAT::t_int_2d d_plist;
120 
121   DAT::tdual_int_1d k_unique;
122   DAT::t_int_1d d_unique;
123 
124   double fnum;
125   int count,mass,count_or_mass,cell_count_or_mass;
126   int velocity,mvsq,eng,dof,mom,ke;
127   int nsample,nstride;
128 };
129 
130 }
131 
132 #endif
133 #endif
134 
135 /* ERROR/WARNING messages:
136 
137 E: Illegal ... command
138 
139 Self-explanatory.  Check the input script syntax and compare to the
140 documentation for the command.  You can use -echo screen as a
141 command-line option when running SPARTA to see the offending line.
142 
143 E: Compute grid mixture ID does not exist
144 
145 Self-explanatory.
146 
147 E: Number of groups in compute grid mixture has changed
148 
149 This mixture property cannot be changed after this compute command is
150 issued.
151 
152 E: Invalid call to ComputeGridKokkos::post_process_grid()
153 
154 This indicates a coding error.  Please report the issue to the SPARTA
155 developers.
156 
157 */
158