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(sonine/grid/kk,ComputeSonineGridKokkos)
18 
19 #else
20 
21 #ifndef SPARTA_COMPUTE_SONINE_GRID_KOKKOS_H
22 #define SPARTA_COMPUTE_SONINE_GRID_KOKKOS_H
23 
24 #include "compute_sonine_grid.h"
25 #include "kokkos_base.h"
26 #include "kokkos_type.h"
27 
28 namespace SPARTA_NS {
29 
30 // vcom calculations
31 template<int NEED_ATOMICS>
32 struct TagComputeSonineGrid_compute_vcom_init_atomic{};
33 struct TagComputeSonineGrid_compute_vcom{};
34 struct TagComputeSonineGrid_normalize_vcom{};
35 
36 // compute_per_grid calculations
37 template<int NEED_ATOMICS>
38 struct TagComputeSonineGrid_compute_per_grid_atomic{};
39 struct TagComputeSonineGrid_compute_per_grid{};
40 
41 struct TagComputeSonineGrid_post_process_grid{};
42 
43 
44 class ComputeSonineGridKokkos : public ComputeSonineGrid, public KokkosBase {
45  public:
46   ComputeSonineGridKokkos(class SPARTA *, int, char **);
47   ~ComputeSonineGridKokkos();
48   void compute_per_grid();
49   void compute_per_grid_kokkos();
50   int query_tally_grid_kokkos(DAT::t_float_2d_lr &);
51   void post_process_grid_kokkos(int, int, DAT::t_float_2d_lr, int *,
52                                   DAT::t_float_1d_strided);
53   void reallocate();
54 
55   template<int NEED_ATOMICS>
56   KOKKOS_INLINE_FUNCTION
57   void operator()(TagComputeSonineGrid_compute_vcom_init_atomic<NEED_ATOMICS>, const int&) const;
58   KOKKOS_INLINE_FUNCTION
59   void operator()(TagComputeSonineGrid_normalize_vcom, const int&) const;
60   KOKKOS_INLINE_FUNCTION
61   void operator()(TagComputeSonineGrid_compute_vcom, const int&) const;
62 
63   template<int NEED_ATOMICS>
64   KOKKOS_INLINE_FUNCTION
65   void operator()(TagComputeSonineGrid_compute_per_grid_atomic<NEED_ATOMICS>, const int&) const;
66 
67   KOKKOS_INLINE_FUNCTION
68   void operator()(TagComputeSonineGrid_compute_per_grid, const int&) const;
69 
70   KOKKOS_INLINE_FUNCTION
71   void operator()(TagComputeSonineGrid_post_process_grid, const int&) const;
72 
73   DAT::tdual_float_1d k_vector_grid;
74 
75  private:
76   DAT::t_float_3d d_vcom;
77   Kokkos::Experimental::ScatterView<F_FLOAT***, typename DAT::t_float_3d::array_layout,DeviceType,typename Kokkos::Experimental::ScatterSum,typename Kokkos::Experimental::ScatterDuplicated> dup_vcom_tally;
78   Kokkos::Experimental::ScatterView<F_FLOAT***, typename DAT::t_float_3d::array_layout,DeviceType,typename Kokkos::Experimental::ScatterSum,typename Kokkos::Experimental::ScatterNonDuplicated> ndup_vcom_tally;
79 
80   DAT::tdual_float_2d_lr k_tally;
81   DAT::t_float_2d_lr d_tally;
82   int need_dup;
83   Kokkos::Experimental::ScatterView<F_FLOAT**, typename DAT::t_float_2d_lr::array_layout,DeviceType,typename Kokkos::Experimental::ScatterSum,typename Kokkos::Experimental::ScatterDuplicated> dup_tally;
84   Kokkos::Experimental::ScatterView<F_FLOAT**, typename DAT::t_float_2d_lr::array_layout,DeviceType,typename Kokkos::Experimental::ScatterSum,typename Kokkos::Experimental::ScatterNonDuplicated> ndup_tally;
85 
86   DAT::t_float_2d_lr d_etally;
87   DAT::t_float_1d_strided d_vec;
88 
89   t_cinfo_1d d_cinfo;
90   t_particle_1d d_particles;
91   t_species_1d d_species;
92   DAT::t_int_2d d_s2g;
93 
94   DAT::t_int_1d d_cellcount;
95   DAT::t_int_2d d_plist;
96 
97   DAT::tdual_int_1d k_which;
98   DAT::tdual_int_1d k_moment;
99   DAT::tdual_int_1d k_order;
100   DAT::t_int_1d d_which;
101   DAT::t_int_1d d_moment;
102   DAT::t_int_1d d_order;
103 
104   int mass,numerator;
105 };
106 
107 }
108 
109 #endif
110 #endif
111 
112 /* ERROR/WARNING messages:
113 
114 E: Illegal ... command
115 
116 Self-explanatory.  Check the input script syntax and compare to the
117 documentation for the command.  You can use -echo screen as a
118 command-line option when running SPARTA to see the offending line.
119 
120 E: Compute sonine/grid mixture ID does not exist
121 
122 Self-explanatory.
123 
124 E: Number of groups in compute sonine/grid mixture has changed
125 
126 This mixture property cannot be changed after this compute command is
127 issued.
128 
129 E: Invalid call to ComputeSonineGrid::post_process_grid()
130 
131 This indicates a coding error.  Please report the issue to the SPARTA
132 developers.
133 
134 */
135