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(thermal/grid/kk,ComputeThermalGridKokkos)
18 
19 #else
20 
21 #ifndef SPARTA_COMPUTE_THERMAL_GRID_KOKKOS_H
22 #define SPARTA_COMPUTE_THERMAL_GRID_KOKKOS_H
23 
24 #include "compute_thermal_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 TagComputeThermalGrid_compute_per_grid_atomic{};
32 
33 struct TagComputeThermalGrid_compute_per_grid{};
34 struct TagComputeThermalGrid_post_process_grid{};
35 
36 class ComputeThermalGridKokkos : public ComputeThermalGrid, public KokkosBase {
37  public:
38   ComputeThermalGridKokkos(class SPARTA *, int, char **);
39   ~ComputeThermalGridKokkos();
40   void compute_per_grid();
41   void compute_per_grid_kokkos();
42   int query_tally_grid_kokkos(DAT::t_float_2d_lr &);
43   void post_process_grid_kokkos(int, int, DAT::t_float_2d_lr, int *,
44                                   DAT::t_float_1d_strided);
45   void reallocate();
46 
47   template<int NEED_ATOMICS>
48   KOKKOS_INLINE_FUNCTION
49   void operator()(TagComputeThermalGrid_compute_per_grid_atomic<NEED_ATOMICS>, const int&) const;
50 
51   KOKKOS_INLINE_FUNCTION
52   void operator()(TagComputeThermalGrid_compute_per_grid, const int&) const;
53 
54   KOKKOS_INLINE_FUNCTION
55   void operator()(TagComputeThermalGrid_post_process_grid, const int&) const;
56 
57 
58   DAT::tdual_float_1d k_vector_grid;
59 
60  private:
61   DAT::tdual_float_2d_lr k_tally;
62   DAT::t_float_2d_lr d_tally;
63   int need_dup;
64   Kokkos::Experimental::ScatterView<F_FLOAT**, typename DAT::t_float_2d_lr::array_layout,DeviceType,typename Kokkos::Experimental::ScatterSum,typename Kokkos::Experimental::ScatterDuplicated> dup_tally;
65   Kokkos::Experimental::ScatterView<F_FLOAT**, typename DAT::t_float_2d_lr::array_layout,DeviceType,typename Kokkos::Experimental::ScatterSum,typename Kokkos::Experimental::ScatterNonDuplicated> ndup_tally;
66 
67   DAT::t_float_2d_lr d_etally;
68   DAT::t_float_1d_strided d_vec;
69 
70   t_cinfo_1d d_cinfo;
71   t_particle_1d d_particles;
72   t_species_1d d_species;
73   DAT::t_int_2d d_s2g;
74 
75   DAT::t_int_1d d_cellcount;
76   DAT::t_int_2d d_plist;
77 
78   int nstride,nsample,n,tflag;
79   double prefactor;
80 };
81 
82 }
83 
84 #endif
85 #endif
86 
87 /* ERROR/WARNING messages:
88 
89 E: Illegal ... command
90 
91 Self-explanatory.  Check the input script syntax and compare to the
92 documentation for the command.  You can use -echo screen as a
93 command-line option when running SPARTA to see the offending line.
94 
95 E: Compute sonine/grid mixture ID does not exist
96 
97 Self-explanatory.
98 
99 E: Number of groups in compute sonine/grid mixture has changed
100 
101 This mixture property cannot be changed after this compute command is
102 issued.
103 
104 E: Invalid call to ComputeSonineGrid::post_process_grid()
105 
106 This indicates a coding error.  Please report the issue to the SPARTA
107 developers.
108 
109 */
110