1 /* -*- c++ -*- ----------------------------------------------------------
2    SPARTA - Large-scale Atomic/Molecular Massively Parallel Simulator
3    http://sparta.sandia.gov, Sandia National Laboratories
4    Steve Plimpton, sjplimp@sandia.gov
5 
6    Copyright (2003) Sandia Corporation.  Under the terms of Contract
7    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
8    certain rights in this software.  This software is distributed under
9    the GNU General Public License.
10 
11    See the README file in the top-level SPARTA directory.
12 ------------------------------------------------------------------------- */
13 
14 #ifndef SPARTA_STYPE_KOKKOS_H
15 #define SPARTA_STYPE_KOKKOS_H
16 
17 #include <Kokkos_Core.hpp>
18 #include <Kokkos_DualView.hpp>
19 #include <impl/Kokkos_Timer.hpp>
20 #include <Kokkos_Vectorization.hpp>
21 #include <Kokkos_ScatterView.hpp>
22 
23 #include "particle.h"
24 #include "grid.h"
25 #include "surf.h"
26 #include "spatype.h"
27 
28 #define MAX_TYPES_STACKPARAMS 12
29 #define NeighClusterSize 8
30 
31 #if defined(KOKKOS_ENABLE_CUDA) || defined(KOKKOS_ENABLE_HIP)
32 #define SPARTA_KOKKOS_GPU
33 #endif
34 
35   struct sparta_float3 {
36     float x,y,z;
37     KOKKOS_INLINE_FUNCTION
sparta_float3sparta_float338     sparta_float3():x(0.0f),z(0.0f),y(0.0f) {}
39 
40     KOKKOS_INLINE_FUNCTION
41     void operator += (const sparta_float3& tmp) {
42       x+=tmp.x;
43       y+=tmp.y;
44       z+=tmp.z;
45     }
46     KOKKOS_INLINE_FUNCTION
47     void operator += (const sparta_float3& tmp) volatile {
48       x+=tmp.x;
49       y+=tmp.y;
50       z+=tmp.z;
51     }
52     KOKKOS_INLINE_FUNCTION
53     void operator = (const sparta_float3& tmp) {
54       x=tmp.x;
55       y=tmp.y;
56       z=tmp.z;
57     }
58     KOKKOS_INLINE_FUNCTION
59     void operator = (const sparta_float3& tmp) volatile {
60       x=tmp.x;
61       y=tmp.y;
62       z=tmp.z;
63     }
64   };
65 
66   struct sparta_double3 {
67     double x,y,z;
68     KOKKOS_INLINE_FUNCTION
sparta_double3sparta_double369     sparta_double3():x(0.0),z(0.0),y(0.0) {}
70 
71     KOKKOS_INLINE_FUNCTION
72     void operator += (const sparta_double3& tmp) {
73       x+=tmp.x;
74       y+=tmp.y;
75       z+=tmp.z;
76     }
77     KOKKOS_INLINE_FUNCTION
78     void operator += (const sparta_double3& tmp) volatile {
79       x+=tmp.x;
80       y+=tmp.y;
81       z+=tmp.z;
82     }
83     KOKKOS_INLINE_FUNCTION
84     void operator = (const sparta_double3& tmp) {
85       x=tmp.x;
86       y=tmp.y;
87       z=tmp.z;
88     }
89     KOKKOS_INLINE_FUNCTION
90     void operator = (const sparta_double3& tmp) volatile {
91       x=tmp.x;
92       y=tmp.y;
93       z=tmp.z;
94     }
95   };
96 
97 // set SPAHostype and DeviceType from Kokkos Default Types
98 typedef Kokkos::DefaultExecutionSpace SPADeviceType;
99 typedef Kokkos::HostSpace::execution_space SPAHostType;
100 
101 typedef SPADeviceType DeviceType;
102 
103 // set ExecutionSpace stuct with variable "space"
104 
105 template<class Device>
106 struct ExecutionSpaceFromDevice;
107 
108 template<>
109 struct ExecutionSpaceFromDevice<SPAHostType> {
110   static const SPARTA_NS::ExecutionSpace space = SPARTA_NS::Host;
111 };
112 
113 #ifdef KOKKOS_ENABLE_CUDA
114 template<>
115 struct ExecutionSpaceFromDevice<Kokkos::Cuda> {
116   static const SPARTA_NS::ExecutionSpace space = SPARTA_NS::Device;
117 };
118 #endif
119 
120 #ifdef KOKKOS_ENABLE_HIP
121 template<>
122 struct ExecutionSpaceFromDevice<Kokkos::Experimental::HIP> {
123   static const SPARTA_NS::ExecutionSpace space = SPARTA_NS::Device;
124 };
125 #endif
126 
127 // Determine memory traits for atomic arrays
128 template<int NEED_ATOMICS>
129 struct AtomicView {
130   enum {value = Kokkos::Unmanaged};
131 };
132 
133 template<>
134 struct AtomicView<1> {
135   enum {value = Kokkos::Atomic|Kokkos::Unmanaged};
136 };
137 
138 template<>
139 struct AtomicView<-1> {
140   enum {value = Kokkos::Atomic|Kokkos::Unmanaged};
141 };
142 
143 // Determine memory traits for array
144 // Do atomic trait when running with CUDA
145 template<int NEED_ATOMICS, class DeviceType>
146 struct AtomicDup {
147   using value = Kokkos::Experimental::ScatterNonAtomic;
148 };
149 
150 #ifdef KOKKOS_ENABLE_CUDA
151 template<>
152 struct AtomicDup<1,Kokkos::Cuda> {
153   using value = Kokkos::Experimental::ScatterAtomic;
154 };
155 
156 template<>
157 struct AtomicDup<-1,Kokkos::Cuda> {
158   using value = Kokkos::Experimental::ScatterAtomic;
159 };
160 #endif
161 
162 #ifdef KOKKOS_ENABLE_HIP
163 template<>
164 struct AtomicDup<1,Kokkos::Experimental::HIP> {
165   using value = Kokkos::Experimental::ScatterAtomic;
166 };
167 
168 template<>
169 struct AtomicDup<-1,Kokkos::Experimental::HIP> {
170   using value = Kokkos::Experimental::ScatterAtomic;
171 };
172 #endif
173 
174 #ifdef SPARTA_KOKKOS_USE_ATOMICS
175 
176 #ifdef KOKKOS_ENABLE_OPENMP
177 template<>
178 struct AtomicDup<1,Kokkos::OpenMP> {
179   using value = Kokkos::Experimental::ScatterAtomic;
180 };
181 
182 template<>
183 struct AtomicDup<-1,Kokkos::OpenMP> {
184   using value = Kokkos::Experimental::ScatterAtomic;
185 };
186 #endif
187 
188 #ifdef KOKKOS_ENABLE_THREADS
189 template<>
190 struct AtomicDup<1,Kokkos::Threads> {
191   using value = Kokkos::Experimental::ScatterAtomic;
192 };
193 
194 template<>
195 struct AtomicDup<-1,Kokkos::Threads> {
196   using value = Kokkos::Experimental::ScatterAtomic;
197 };
198 #endif
199 
200 #endif
201 
202 
203 // Determine duplication traits for array
204 // Use duplication when running threaded and not using atomics
205 template<int NEED_ATOMICS, class DeviceType>
206 struct NeedDup {
207   using value = Kokkos::Experimental::ScatterNonDuplicated;
208 };
209 
210 #ifndef SPARTA_KOKKOS_USE_ATOMICS
211 
212 #ifdef KOKKOS_ENABLE_OPENMP
213 template<>
214 struct NeedDup<1,Kokkos::OpenMP> {
215   using value = Kokkos::Experimental::ScatterDuplicated;
216 };
217 
218 template<>
219 struct NeedDup<-1,Kokkos::OpenMP> {
220   using value = Kokkos::Experimental::ScatterDuplicated;
221 };
222 #endif
223 
224 #ifdef KOKKOS_ENABLE_THREADS
225 template<>
226 struct NeedDup<1,Kokkos::Threads> {
227   using value = Kokkos::Experimental::ScatterDuplicated;
228 };
229 
230 template<>
231 struct NeedDup<-1,Kokkos::Threads> {
232   using value = Kokkos::Experimental::ScatterDuplicated;
233 };
234 #endif
235 
236 #endif
237 
238 template<typename value, typename T1, typename T2>
239 class ScatterViewHelper {};
240 
241 template<typename T1, typename T2>
242 class ScatterViewHelper<Kokkos::Experimental::ScatterDuplicated,T1,T2> {
243 public:
244   KOKKOS_INLINE_FUNCTION
245   static T1 get(const T1 &dup, const T2 & /*nondup*/) {
246     return dup;
247   }
248 };
249 
250 template<typename T1, typename T2>
251 class ScatterViewHelper<Kokkos::Experimental::ScatterNonDuplicated,T1,T2> {
252 public:
253   KOKKOS_INLINE_FUNCTION
254   static T2 get(const T1 & /*dup*/, const T2 &nondup) {
255     return nondup;
256   }
257 };
258 
259 
260 // define precision
261 
262 #ifndef PRECISION
263 #define PRECISION 2
264 #endif
265 #if PRECISION==1
266 typedef float SPARTA_FLOAT;
267 #else
268 typedef double SPARTA_FLOAT;
269 #endif
270 
271 #ifndef PREC_FORCE
272 #define PREC_FORCE PRECISION
273 #endif
274 
275 #if PREC_FORCE==1
276 typedef float F_FLOAT;
277 #else
278 typedef double F_FLOAT;
279 #endif
280 
281 #ifndef PREC_ENERGY
282 #define PREC_ENERGY PRECISION
283 #endif
284 
285 #if PREC_ENERGY==1
286 typedef float E_FLOAT;
287 #else
288 typedef double E_FLOAT;
289 #endif
290 
291 struct s_EV_FLOAT {
292   E_FLOAT evdwl;
293   E_FLOAT ecoul;
294   E_FLOAT v[6];
295   KOKKOS_INLINE_FUNCTION
296   s_EV_FLOAT() {
297 	  evdwl = 0;
298 	  ecoul = 0;
299 	  v[0] = 0; v[1] = 0; v[2] = 0;
300 	  v[3] = 0; v[4] = 0; v[5] = 0;
301   }
302 
303   KOKKOS_INLINE_FUNCTION
304   void operator+=(const s_EV_FLOAT &rhs) {
305     evdwl += rhs.evdwl;
306     ecoul += rhs.ecoul;
307     v[0] += rhs.v[0];
308     v[1] += rhs.v[1];
309     v[2] += rhs.v[2];
310     v[3] += rhs.v[3];
311     v[4] += rhs.v[4];
312     v[5] += rhs.v[5];
313   }
314 
315   KOKKOS_INLINE_FUNCTION
316   void operator+=(const volatile s_EV_FLOAT &rhs) volatile {
317     evdwl += rhs.evdwl;
318     ecoul += rhs.ecoul;
319     v[0] += rhs.v[0];
320     v[1] += rhs.v[1];
321     v[2] += rhs.v[2];
322     v[3] += rhs.v[3];
323     v[4] += rhs.v[4];
324     v[5] += rhs.v[5];
325   }
326 };
327 typedef struct s_EV_FLOAT EV_FLOAT;
328 
329 #ifndef PREC_POS
330 #define PREC_POS PRECISION
331 #endif
332 
333 #if PREC_POS==1
334 typedef float X_FLOAT;
335 #else
336 typedef double X_FLOAT;
337 #endif
338 
339 #ifndef PREC_VELOCITIES
340 #define PREC_VELOCITIES PRECISION
341 #endif
342 
343 #if PREC_VELOCITIES==1
344 typedef float V_FLOAT;
345 #else
346 typedef double V_FLOAT;
347 #endif
348 
349 #if PREC_KSPACE==1
350 typedef float K_FLOAT;
351 #else
352 typedef double K_FLOAT;
353 #endif
354 
355 // ------------------------------------------------------------------------
356 
357 // SPARTA types
358 
359 namespace SPARTA_NS {
360 
361   typedef Kokkos::
362     DualView<Particle::OnePart*, DeviceType::array_layout, DeviceType> tdual_particle_1d;
363   typedef tdual_particle_1d::t_dev t_particle_1d;
364   typedef tdual_particle_1d::t_host t_host_particle_1d;
365 
366   typedef Kokkos::
367     DualView<Particle::Species*, DeviceType::array_layout, DeviceType> tdual_species_1d;
368   typedef tdual_species_1d::t_dev t_species_1d;
369   typedef tdual_species_1d::t_dev_const t_species_1d_const;
370   typedef tdual_species_1d::t_host t_host_species_1d;
371 
372   typedef Kokkos::
373     DualView<Grid::ChildCell*, DeviceType::array_layout, DeviceType> tdual_cell_1d;
374   typedef tdual_cell_1d::t_dev t_cell_1d;
375   typedef tdual_cell_1d::t_host t_host_cell_1d;
376 
377   typedef Kokkos::
378     DualView<Grid::ChildInfo*, DeviceType::array_layout, DeviceType> tdual_cinfo_1d;
379   typedef tdual_cinfo_1d::t_dev t_cinfo_1d;
380   typedef tdual_cinfo_1d::t_host t_host_cinfo_1d;
381 
382   typedef Kokkos::
383     DualView<Grid::SplitInfo*, DeviceType::array_layout, DeviceType> tdual_sinfo_1d;
384   typedef tdual_sinfo_1d::t_dev t_sinfo_1d;
385   typedef tdual_sinfo_1d::t_host t_host_sinfo_1d;
386 
387   typedef Kokkos::
388     DualView<Grid::ParentCell*, DeviceType::array_layout, DeviceType> tdual_pcell_1d;
389   typedef tdual_pcell_1d::t_dev t_pcell_1d;
390   typedef tdual_pcell_1d::t_host t_host_pcell_1d;
391 
392   typedef Kokkos::
393     DualView<Grid::ParentLevel*, DeviceType::array_layout, DeviceType> tdual_plevel_1d;
394   typedef tdual_pcell_1d::t_dev t_plevel_1d;
395   typedef tdual_pcell_1d::t_host t_host_plevel_1d;
396 
397   typedef Kokkos::
398     DualView<Surf::Line*, DeviceType::array_layout, DeviceType> tdual_line_1d;
399   typedef tdual_line_1d::t_dev t_line_1d;
400   typedef tdual_line_1d::t_host t_host_line_1d;
401 
402   typedef Kokkos::
403     DualView<Surf::Tri*, DeviceType::array_layout, DeviceType> tdual_tri_1d;
404   typedef tdual_tri_1d::t_dev t_tri_1d;
405   typedef tdual_tri_1d::t_host t_host_tri_1d;
406 }
407 
408 template <class DeviceType>
409 struct ArrayTypes;
410 
411 template <>
412 struct ArrayTypes<DeviceType> {
413 
414 // scalar types
415 
416 typedef Kokkos::
417   DualView<int, DeviceType::array_layout, DeviceType> tdual_int_scalar;
418 typedef tdual_int_scalar::t_dev t_int_scalar;
419 typedef tdual_int_scalar::t_dev_const t_int_scalar_const;
420 typedef tdual_int_scalar::t_dev_um t_int_scalar_um;
421 typedef tdual_int_scalar::t_dev_const_um t_int_scalar_const_um;
422 
423 typedef Kokkos::
424   DualView<SPARTA_FLOAT, DeviceType::array_layout, DeviceType>
425   tdual_float_scalar;
426 typedef tdual_float_scalar::t_dev t_float_scalar;
427 typedef tdual_float_scalar::t_dev_const t_float_scalar_const;
428 typedef tdual_float_scalar::t_dev_um t_float_scalar_um;
429 typedef tdual_float_scalar::t_dev_const_um t_float_scalar_const_um;
430 
431 // generic array types
432 
433 typedef Kokkos::
434   DualView<char*, DeviceType::array_layout, DeviceType> tdual_char_1d;
435 typedef tdual_char_1d::t_dev t_char_1d;
436 typedef tdual_char_1d::t_dev_const t_char_1d_const;
437 typedef tdual_char_1d::t_dev_um t_char_1d_um;
438 typedef tdual_char_1d::t_dev_const_um t_char_1d_const_um;
439 typedef tdual_char_1d::t_dev_const_randomread t_char_1d_randomread;
440 
441 typedef Kokkos::
442   DualView<int*, DeviceType::array_layout, DeviceType> tdual_int_1d;
443 typedef tdual_int_1d::t_dev t_int_1d;
444 typedef tdual_int_1d::t_dev_const t_int_1d_const;
445 typedef tdual_int_1d::t_dev_um t_int_1d_um;
446 typedef tdual_int_1d::t_dev_const_um t_int_1d_const_um;
447 typedef tdual_int_1d::t_dev_const_randomread t_int_1d_randomread;
448 
449 typedef Kokkos::
450   DualView<SPARTA_NS::bigint*, DeviceType::array_layout, DeviceType> tdual_bigint_1d;
451 typedef tdual_bigint_1d::t_dev t_bigint_1d;
452 typedef tdual_bigint_1d::t_dev_const t_bigint_1d_const;
453 typedef tdual_bigint_1d::t_dev_um t_bigint_1d_um;
454 typedef tdual_bigint_1d::t_dev_const_um t_bigint_1d_const_um;
455 typedef tdual_bigint_1d::t_dev_const_randomread t_bigint_1d_randomread;
456 
457 typedef Kokkos::
458   DualView<int*[3], Kokkos::LayoutRight, DeviceType> tdual_int_1d_3;
459 typedef tdual_int_1d_3::t_dev t_int_1d_3;
460 typedef tdual_int_1d_3::t_dev_const t_int_1d_3_const;
461 typedef tdual_int_1d_3::t_dev_um t_int_1d_3_um;
462 typedef tdual_int_1d_3::t_dev_const_um t_int_1d_3_const_um;
463 typedef tdual_int_1d_3::t_dev_const_randomread t_int_1d_3_randomread;
464 
465 typedef Kokkos::
466   DualView<int**, Kokkos::LayoutRight, DeviceType> tdual_int_2d;
467 typedef tdual_int_2d::t_dev t_int_2d;
468 typedef tdual_int_2d::t_dev_const t_int_2d_const;
469 typedef tdual_int_2d::t_dev_um t_int_2d_um;
470 typedef tdual_int_2d::t_dev_const_um t_int_2d_const_um;
471 typedef tdual_int_2d::t_dev_const_randomread t_int_2d_randomread;
472 
473 typedef Kokkos::
474   DualView<SPARTA_NS::cellint*, DeviceType::array_layout, DeviceType>
475   tdual_cellint_1d;
476 typedef tdual_cellint_1d::t_dev t_cellint_1d;
477 typedef tdual_cellint_1d::t_dev_const t_cellint_1d_const;
478 typedef tdual_cellint_1d::t_dev_um t_cellint_1d_um;
479 typedef tdual_cellint_1d::t_dev_const_um t_cellint_1d_const_um;
480 typedef tdual_cellint_1d::t_dev_const_randomread t_cellint_1d_randomread;
481 
482 typedef Kokkos::
483   DualView<SPARTA_NS::cellint**, Kokkos::LayoutRight, DeviceType>
484   tdual_cellint_2d;
485 typedef tdual_cellint_2d::t_dev t_cellint_2d;
486 typedef tdual_cellint_2d::t_dev_const t_cellint_2d_const;
487 typedef tdual_cellint_2d::t_dev_um t_cellint_2d_um;
488 typedef tdual_cellint_2d::t_dev_const_um t_cellint_2d_const_um;
489 typedef tdual_cellint_2d::t_dev_const_randomread t_cellint_2d_randomread;
490 
491 typedef Kokkos::
492   DualView<SPARTA_NS::surfint*, DeviceType::array_layout, DeviceType>
493   tdual_surfint_1d;
494 typedef tdual_surfint_1d::t_dev t_surfint_1d;
495 typedef tdual_surfint_1d::t_dev_const t_surfint_1d_const;
496 typedef tdual_surfint_1d::t_dev_um t_surfint_1d_um;
497 typedef tdual_surfint_1d::t_dev_const_um t_surfint_1d_const_um;
498 typedef tdual_surfint_1d::t_dev_const_randomread t_surfint_1d_randomread;
499 
500 typedef Kokkos::
501   DualView<SPARTA_NS::surfint**, Kokkos::LayoutRight, DeviceType>
502   tdual_surfint_2d;
503 typedef tdual_surfint_2d::t_dev t_surfint_2d;
504 typedef tdual_surfint_2d::t_dev_const t_surfint_2d_const;
505 typedef tdual_surfint_2d::t_dev_um t_surfint_2d_um;
506 typedef tdual_surfint_2d::t_dev_const_um t_surfint_2d_const_um;
507 typedef tdual_surfint_2d::t_dev_const_randomread t_surfint_2d_randomread;
508 
509 typedef Kokkos::
510   DualView<double*, Kokkos::LayoutRight, DeviceType> tdual_double_1d;
511 typedef tdual_double_1d::t_dev t_double_1d;
512 typedef tdual_double_1d::t_dev_const t_double_1d_const;
513 typedef tdual_double_1d::t_dev_um t_double_1d_um;
514 typedef tdual_double_1d::t_dev_const_um t_double_1d_const_um;
515 typedef tdual_double_1d::t_dev_const_randomread t_double_1d_randomread;
516 
517 typedef Kokkos::
518   DualView<double**, Kokkos::LayoutRight, DeviceType> tdual_double_2d;
519 typedef tdual_double_2d::t_dev t_double_2d;
520 typedef tdual_double_2d::t_dev_const t_double_2d_const;
521 typedef tdual_double_2d::t_dev_um t_double_2d_um;
522 typedef tdual_double_2d::t_dev_const_um t_double_2d_const_um;
523 typedef tdual_double_2d::t_dev_const_randomread t_double_2d_randomread;
524 
525 // 1d float array n
526 
527 typedef Kokkos::DualView<SPARTA_FLOAT*, DeviceType::array_layout, DeviceType> tdual_float_1d;
528 typedef tdual_float_1d::t_dev t_float_1d;
529 typedef tdual_float_1d::t_dev_const t_float_1d_const;
530 typedef tdual_float_1d::t_dev_um t_float_1d_um;
531 typedef tdual_float_1d::t_dev_const_um t_float_1d_const_um;
532 typedef tdual_float_1d::t_dev_const_randomread t_float_1d_randomread;
533 
534 // 1d float array n[3]
535 
536 typedef Kokkos::DualView<SPARTA_FLOAT*[3], DeviceType::array_layout, DeviceType> tdual_float_1d_3;
537 typedef tdual_float_1d_3::t_dev t_float_1d_3;
538 typedef tdual_float_1d_3::t_dev_const t_float_1d_3_const;
539 typedef tdual_float_1d_3::t_dev_um t_float_1d_3_um;
540 typedef tdual_float_1d_3::t_dev_const_um t_float_1d_3_const_um;
541 typedef tdual_float_1d_3::t_dev_const_randomread t_float_1d_3_randomread;
542 
543 //2d float array n
544 typedef Kokkos::DualView<SPARTA_FLOAT**, DeviceType::array_layout, DeviceType> tdual_float_2d;
545 typedef tdual_float_2d::t_dev t_float_2d;
546 typedef tdual_float_2d::t_dev_const t_float_2d_const;
547 typedef tdual_float_2d::t_dev_um t_float_2d_um;
548 typedef tdual_float_2d::t_dev_const_um t_float_2d_const_um;
549 typedef tdual_float_2d::t_dev_const_randomread t_float_2d_randomread;
550 
551 //3d float array n
552 typedef Kokkos::DualView<SPARTA_FLOAT***, DeviceType::array_layout, DeviceType> tdual_float_3d;
553 typedef tdual_float_3d::t_dev t_float_3d;
554 typedef tdual_float_3d::t_dev_const t_float_3d_const;
555 typedef tdual_float_3d::t_dev_um t_float_3d_um;
556 typedef tdual_float_3d::t_dev_const_um t_float_3d_const_um;
557 typedef tdual_float_3d::t_dev_const_randomread t_float_3d_randomread;
558 
559 //Position Types
560 //1d X_FLOAT array n
561 typedef Kokkos::DualView<X_FLOAT*, DeviceType::array_layout, DeviceType> tdual_xfloat_1d;
562 typedef tdual_xfloat_1d::t_dev t_xfloat_1d;
563 typedef tdual_xfloat_1d::t_dev_const t_xfloat_1d_const;
564 typedef tdual_xfloat_1d::t_dev_um t_xfloat_1d_um;
565 typedef tdual_xfloat_1d::t_dev_const_um t_xfloat_1d_const_um;
566 typedef tdual_xfloat_1d::t_dev_const_randomread t_xfloat_1d_randomread;
567 
568 //2d X_FLOAT array n*m
569 typedef Kokkos::DualView<X_FLOAT**, Kokkos::LayoutRight, DeviceType> tdual_xfloat_2d;
570 typedef tdual_xfloat_2d::t_dev t_xfloat_2d;
571 typedef tdual_xfloat_2d::t_dev_const t_xfloat_2d_const;
572 typedef tdual_xfloat_2d::t_dev_um t_xfloat_2d_um;
573 typedef tdual_xfloat_2d::t_dev_const_um t_xfloat_2d_const_um;
574 typedef tdual_xfloat_2d::t_dev_const_randomread t_xfloat_2d_randomread;
575 
576 //2d X_FLOAT array n*4
577 #ifdef SPARTA_KOKKOS_NO_LEGACY
578 typedef Kokkos::DualView<X_FLOAT*[3], Kokkos::LayoutLeft, DeviceType> tdual_x_array;
579 #else
580 typedef Kokkos::DualView<X_FLOAT*[3], Kokkos::LayoutRight, DeviceType> tdual_x_array;
581 #endif
582 typedef tdual_x_array::t_dev t_x_array;
583 typedef tdual_x_array::t_dev_const t_x_array_const;
584 typedef tdual_x_array::t_dev_um t_x_array_um;
585 typedef tdual_x_array::t_dev_const_um t_x_array_const_um;
586 typedef tdual_x_array::t_dev_const_randomread t_x_array_randomread;
587 
588 //Velocity Types
589 //1d V_FLOAT array n
590 typedef Kokkos::DualView<V_FLOAT*, DeviceType::array_layout, DeviceType> tdual_vfloat_1d;
591 typedef tdual_vfloat_1d::t_dev t_vfloat_1d;
592 typedef tdual_vfloat_1d::t_dev_const t_vfloat_1d_const;
593 typedef tdual_vfloat_1d::t_dev_um t_vfloat_1d_um;
594 typedef tdual_vfloat_1d::t_dev_const_um t_vfloat_1d_const_um;
595 typedef tdual_vfloat_1d::t_dev_const_randomread t_vfloat_1d_randomread;
596 
597 //2d V_FLOAT array n*m
598 typedef Kokkos::DualView<V_FLOAT**, Kokkos::LayoutRight, DeviceType> tdual_vfloat_2d;
599 typedef tdual_vfloat_2d::t_dev t_vfloat_2d;
600 typedef tdual_vfloat_2d::t_dev_const t_vfloat_2d_const;
601 typedef tdual_vfloat_2d::t_dev_um t_vfloat_2d_um;
602 typedef tdual_vfloat_2d::t_dev_const_um t_vfloat_2d_const_um;
603 typedef tdual_vfloat_2d::t_dev_const_randomread t_vfloat_2d_randomread;
604 
605 //2d V_FLOAT array n*3
606 typedef Kokkos::DualView<V_FLOAT*[3], Kokkos::LayoutRight, DeviceType> tdual_v_array;
607 //typedef Kokkos::DualView<V_FLOAT*[3], DeviceType::array_layout, DeviceType> tdual_v_array;
608 typedef tdual_v_array::t_dev t_v_array;
609 typedef tdual_v_array::t_dev_const t_v_array_const;
610 typedef tdual_v_array::t_dev_um t_v_array_um;
611 typedef tdual_v_array::t_dev_const_um t_v_array_const_um;
612 typedef tdual_v_array::t_dev_const_randomread t_v_array_randomread;
613 
614 //Force Types
615 //1d F_FLOAT array n
616 
617 typedef Kokkos::DualView<F_FLOAT*, DeviceType::array_layout, DeviceType> tdual_ffloat_1d;
618 typedef tdual_ffloat_1d::t_dev t_ffloat_1d;
619 typedef tdual_ffloat_1d::t_dev_const t_ffloat_1d_const;
620 typedef tdual_ffloat_1d::t_dev_um t_ffloat_1d_um;
621 typedef tdual_ffloat_1d::t_dev_const_um t_ffloat_1d_const_um;
622 typedef tdual_ffloat_1d::t_dev_const_randomread t_ffloat_1d_randomread;
623 
624 //2d F_FLOAT array n*m
625 
626 typedef Kokkos::DualView<F_FLOAT**, Kokkos::LayoutRight, DeviceType> tdual_float_2d_lr;
627 typedef tdual_float_2d_lr::t_dev t_float_2d_lr;
628 typedef tdual_float_2d_lr::t_dev_const t_float_2d_lr_const;
629 typedef tdual_float_2d_lr::t_dev_um t_float_2d_lr_um;
630 typedef tdual_float_2d_lr::t_dev_const_um t_float_2d_lr_const_um;
631 typedef tdual_float_2d_lr::t_dev_const_randomread t_float_2d_lr_randomread;
632 
633 //2d F_FLOAT array n*3
634 
635 typedef Kokkos::DualView<F_FLOAT*[3], Kokkos::LayoutRight, DeviceType> tdual_f_array;
636 //typedef Kokkos::DualView<F_FLOAT*[3], DeviceType::array_layout, DeviceType> tdual_f_array;
637 typedef tdual_f_array::t_dev t_f_array;
638 typedef tdual_f_array::t_dev_const t_f_array_const;
639 typedef tdual_f_array::t_dev_um t_f_array_um;
640 typedef tdual_f_array::t_dev_const_um t_f_array_const_um;
641 typedef tdual_f_array::t_dev_const_randomread t_f_array_randomread;
642 
643 //2d F_FLOAT array n*6 (for virial)
644 
645 typedef Kokkos::DualView<F_FLOAT*[6], Kokkos::LayoutRight, DeviceType> tdual_virial_array;
646 typedef tdual_virial_array::t_dev t_virial_array;
647 typedef tdual_virial_array::t_dev_const t_virial_array_const;
648 typedef tdual_virial_array::t_dev_um t_virial_array_um;
649 typedef tdual_virial_array::t_dev_const_um t_virial_array_const_um;
650 typedef tdual_virial_array::t_dev_const_randomread t_virial_array_randomread;
651 
652 //Energy Types
653 //1d E_FLOAT array n
654 
655 typedef Kokkos::DualView<E_FLOAT*, DeviceType::array_layout, DeviceType> tdual_efloat_1d;
656 typedef tdual_efloat_1d::t_dev t_efloat_1d;
657 typedef tdual_efloat_1d::t_dev_const t_efloat_1d_const;
658 typedef tdual_efloat_1d::t_dev_um t_efloat_1d_um;
659 typedef tdual_efloat_1d::t_dev_const_um t_efloat_1d_const_um;
660 typedef tdual_efloat_1d::t_dev_const_randomread t_efloat_1d_randomread;
661 
662 //2d E_FLOAT array n*m
663 
664 typedef Kokkos::DualView<E_FLOAT**, Kokkos::LayoutRight, DeviceType> tdual_efloat_2d;
665 typedef tdual_efloat_2d::t_dev t_efloat_2d;
666 typedef tdual_efloat_2d::t_dev_const t_efloat_2d_const;
667 typedef tdual_efloat_2d::t_dev_um t_efloat_2d_um;
668 typedef tdual_efloat_2d::t_dev_const_um t_efloat_2d_const_um;
669 typedef tdual_efloat_2d::t_dev_const_randomread t_efloat_2d_randomread;
670 
671 //2d E_FLOAT array n*3
672 
673 typedef Kokkos::DualView<E_FLOAT*[3], Kokkos::LayoutRight, DeviceType> tdual_e_array;
674 typedef tdual_e_array::t_dev t_e_array;
675 typedef tdual_e_array::t_dev_const t_e_array_const;
676 typedef tdual_e_array::t_dev_um t_e_array_um;
677 typedef tdual_e_array::t_dev_const_um t_e_array_const_um;
678 typedef tdual_e_array::t_dev_const_randomread t_e_array_randomread;
679 
680 //Neighbor Types
681 
682 typedef Kokkos::DualView<int**, DeviceType::array_layout, DeviceType> tdual_neighbors_2d;
683 typedef tdual_neighbors_2d::t_dev t_neighbors_2d;
684 typedef tdual_neighbors_2d::t_dev_const t_neighbors_2d_const;
685 typedef tdual_neighbors_2d::t_dev_um t_neighbors_2d_um;
686 typedef tdual_neighbors_2d::t_dev_const_um t_neighbors_2d_const_um;
687 typedef tdual_neighbors_2d::t_dev_const_randomread t_neighbors_2d_randomread;
688 
689 typedef Kokkos::DualView<double*,Kokkos::LayoutStride> tdual_float_1d_strided;
690 typedef tdual_float_1d_strided::t_dev t_float_1d_strided;
691 typedef tdual_float_1d_strided::t_dev_um t_float_1d_strided_um;
692 };
693 
694 #ifdef SPARTA_KOKKOS_GPU
695 template <>
696 struct ArrayTypes<SPAHostType> {
697 
698 //Scalar Types
699 
700 typedef Kokkos::DualView<int, DeviceType::array_layout, DeviceType> tdual_int_scalar;
701 typedef tdual_int_scalar::t_host t_int_scalar;
702 typedef tdual_int_scalar::t_host_const t_int_scalar_const;
703 typedef tdual_int_scalar::t_host_um t_int_scalar_um;
704 typedef tdual_int_scalar::t_host_const_um t_int_scalar_const_um;
705 
706 typedef Kokkos::DualView<SPARTA_FLOAT, DeviceType::array_layout, DeviceType> tdual_float_scalar;
707 typedef tdual_float_scalar::t_host t_float_scalar;
708 typedef tdual_float_scalar::t_host_const t_float_scalar_const;
709 typedef tdual_float_scalar::t_host_um t_float_scalar_um;
710 typedef tdual_float_scalar::t_host_const_um t_float_scalar_const_um;
711 
712 //Generic ArrayTypes
713 typedef Kokkos::
714   DualView<char*, DeviceType::array_layout, DeviceType> tdual_char_1d;
715 typedef tdual_char_1d::t_host t_char_1d;
716 typedef tdual_char_1d::t_host_const t_char_1d_const;
717 typedef tdual_char_1d::t_host_um t_char_1d_um;
718 typedef tdual_char_1d::t_host_const_um t_char_1d_const_um;
719 typedef tdual_char_1d::t_host_const_randomread t_char_1d_randomread;
720 
721 typedef Kokkos::DualView<int*, DeviceType::array_layout, DeviceType> tdual_int_1d;
722 typedef tdual_int_1d::t_host t_int_1d;
723 typedef tdual_int_1d::t_host_const t_int_1d_const;
724 typedef tdual_int_1d::t_host_um t_int_1d_um;
725 typedef tdual_int_1d::t_host_const_um t_int_1d_const_um;
726 typedef tdual_int_1d::t_host_const_randomread t_int_1d_randomread;
727 
728 typedef Kokkos::DualView<SPARTA_NS::bigint*, DeviceType::array_layout, DeviceType> tdual_bigint_1d;
729 typedef tdual_bigint_1d::t_host t_bigint_1d;
730 typedef tdual_bigint_1d::t_host_const t_bigint_1d_const;
731 typedef tdual_bigint_1d::t_host_um t_bigint_1d_um;
732 typedef tdual_bigint_1d::t_host_const_um t_bigint_1d_const_um;
733 typedef tdual_bigint_1d::t_host_const_randomread t_bigint_1d_randomread;
734 
735 typedef Kokkos::DualView<int*[3], Kokkos::LayoutRight, DeviceType> tdual_int_1d_3;
736 typedef tdual_int_1d_3::t_host t_int_1d_3;
737 typedef tdual_int_1d_3::t_host_const t_int_1d_3_const;
738 typedef tdual_int_1d_3::t_host_um t_int_1d_3_um;
739 typedef tdual_int_1d_3::t_host_const_um t_int_1d_3_const_um;
740 typedef tdual_int_1d_3::t_host_const_randomread t_int_1d_3_randomread;
741 
742 typedef Kokkos::DualView<int**, Kokkos::LayoutRight, DeviceType> tdual_int_2d;
743 typedef tdual_int_2d::t_host t_int_2d;
744 typedef tdual_int_2d::t_host_const t_int_2d_const;
745 typedef tdual_int_2d::t_host_um t_int_2d_um;
746 typedef tdual_int_2d::t_host_const_um t_int_2d_const_um;
747 typedef tdual_int_2d::t_host_const_randomread t_int_2d_randomread;
748 
749 typedef Kokkos::DualView<SPARTA_NS::cellint*, DeviceType::array_layout, DeviceType> tdual_cellint_1d;
750 typedef tdual_cellint_1d::t_host t_cellint_1d;
751 typedef tdual_cellint_1d::t_host_const t_cellint_1d_const;
752 typedef tdual_cellint_1d::t_host_um t_cellint_1d_um;
753 typedef tdual_cellint_1d::t_host_const_um t_cellint_1d_const_um;
754 typedef tdual_cellint_1d::t_host_const_randomread t_cellint_1d_randomread;
755 
756 typedef Kokkos::
757   DualView<SPARTA_NS::cellint**, Kokkos::LayoutRight, DeviceType>
758   tdual_cellint_2d;
759 typedef tdual_cellint_2d::t_host t_cellint_2d;
760 typedef tdual_cellint_2d::t_host_const t_cellint_2d_const;
761 typedef tdual_cellint_2d::t_host_um t_cellint_2d_um;
762 typedef tdual_cellint_2d::t_host_const_um t_cellint_2d_const_um;
763 typedef tdual_cellint_2d::t_host_const_randomread t_cellint_2d_randomread;
764 
765 typedef Kokkos::DualView<SPARTA_NS::surfint*, DeviceType::array_layout, DeviceType> tdual_surfint_1d;
766 typedef tdual_surfint_1d::t_host t_surfint_1d;
767 typedef tdual_surfint_1d::t_host_const t_surfint_1d_const;
768 typedef tdual_surfint_1d::t_host_um t_surfint_1d_um;
769 typedef tdual_surfint_1d::t_host_const_um t_surfint_1d_const_um;
770 typedef tdual_surfint_1d::t_host_const_randomread t_surfint_1d_randomread;
771 
772 typedef Kokkos::
773   DualView<SPARTA_NS::surfint**, Kokkos::LayoutRight, DeviceType>
774   tdual_surfint_2d;
775 typedef tdual_surfint_2d::t_host t_surfint_2d;
776 typedef tdual_surfint_2d::t_host_const t_surfint_2d_const;
777 typedef tdual_surfint_2d::t_host_um t_surfint_2d_um;
778 typedef tdual_surfint_2d::t_host_const_um t_surfint_2d_const_um;
779 typedef tdual_surfint_2d::t_host_const_randomread t_surfint_2d_randomread;
780 
781 typedef Kokkos::
782   DualView<double*, Kokkos::LayoutRight, DeviceType> tdual_double_1d;
783 typedef tdual_double_1d::t_host t_double_1d;
784 typedef tdual_double_1d::t_host_const t_double_1d_const;
785 typedef tdual_double_1d::t_host_um t_double_1d_um;
786 typedef tdual_double_1d::t_host_const_um t_double_1d_const_um;
787 typedef tdual_double_1d::t_host_const_randomread t_double_1d_randomread;
788 
789 typedef Kokkos::
790   DualView<double**, Kokkos::LayoutRight, DeviceType> tdual_double_2d;
791 typedef tdual_double_2d::t_host t_double_2d;
792 typedef tdual_double_2d::t_host_const t_double_2d_const;
793 typedef tdual_double_2d::t_host_um t_double_2d_um;
794 typedef tdual_double_2d::t_host_const_um t_double_2d_const_um;
795 typedef tdual_double_2d::t_host_const_randomread t_double_2d_randomread;
796 
797 //1d float array n
798 typedef Kokkos::DualView<SPARTA_FLOAT*, DeviceType::array_layout, DeviceType> tdual_float_1d;
799 typedef tdual_float_1d::t_host t_float_1d;
800 typedef tdual_float_1d::t_host_const t_float_1d_const;
801 typedef tdual_float_1d::t_host_um t_float_1d_um;
802 typedef tdual_float_1d::t_host_const_um t_float_1d_const_um;
803 typedef tdual_float_1d::t_host_const_randomread t_float_1d_randomread;
804 
805 //1d float array n[3]
806 typedef Kokkos::DualView<SPARTA_FLOAT*[3], DeviceType::array_layout, DeviceType> tdual_float_1d_3;
807 typedef tdual_float_1d_3::t_host t_float_1d_3;
808 typedef tdual_float_1d_3::t_host_const t_float_1d_3_const;
809 typedef tdual_float_1d_3::t_host_um t_float_1d_3_um;
810 typedef tdual_float_1d_3::t_host_const_um t_float_1d_3_const_um;
811 typedef tdual_float_1d_3::t_host_const_randomread t_float_1d_3_randomread;
812 
813 //2d float array n
814 typedef Kokkos::DualView<SPARTA_FLOAT**, DeviceType::array_layout, DeviceType> tdual_float_2d;
815 typedef tdual_float_2d::t_host t_float_2d;
816 typedef tdual_float_2d::t_host_const t_float_2d_const;
817 typedef tdual_float_2d::t_host_um t_float_2d_um;
818 typedef tdual_float_2d::t_host_const_um t_float_2d_const_um;
819 typedef tdual_float_2d::t_host_const_randomread t_float_2d_randomread;
820 
821 //3d float array n
822 typedef Kokkos::DualView<SPARTA_FLOAT***, DeviceType::array_layout, DeviceType> tdual_float_3d;
823 typedef tdual_float_3d::t_host t_float_3d;
824 typedef tdual_float_3d::t_host_const t_float_3d_const;
825 typedef tdual_float_3d::t_host_um t_float_3d_um;
826 typedef tdual_float_3d::t_host_const_um t_float_3d_const_um;
827 typedef tdual_float_3d::t_host_const_randomread t_float_3d_randomread;
828 
829 
830 //Position Types
831 //1d X_FLOAT array n
832 typedef Kokkos::DualView<X_FLOAT*, DeviceType::array_layout, DeviceType> tdual_xfloat_1d;
833 typedef tdual_xfloat_1d::t_host t_xfloat_1d;
834 typedef tdual_xfloat_1d::t_host_const t_xfloat_1d_const;
835 typedef tdual_xfloat_1d::t_host_um t_xfloat_1d_um;
836 typedef tdual_xfloat_1d::t_host_const_um t_xfloat_1d_const_um;
837 typedef tdual_xfloat_1d::t_host_const_randomread t_xfloat_1d_randomread;
838 
839 //2d X_FLOAT array n*m
840 typedef Kokkos::DualView<X_FLOAT**, Kokkos::LayoutRight, DeviceType> tdual_xfloat_2d;
841 typedef tdual_xfloat_2d::t_host t_xfloat_2d;
842 typedef tdual_xfloat_2d::t_host_const t_xfloat_2d_const;
843 typedef tdual_xfloat_2d::t_host_um t_xfloat_2d_um;
844 typedef tdual_xfloat_2d::t_host_const_um t_xfloat_2d_const_um;
845 typedef tdual_xfloat_2d::t_host_const_randomread t_xfloat_2d_randomread;
846 
847 //2d X_FLOAT array n*3
848 typedef Kokkos::DualView<X_FLOAT*[3], Kokkos::LayoutRight, DeviceType> tdual_x_array;
849 typedef tdual_x_array::t_host t_x_array;
850 typedef tdual_x_array::t_host_const t_x_array_const;
851 typedef tdual_x_array::t_host_um t_x_array_um;
852 typedef tdual_x_array::t_host_const_um t_x_array_const_um;
853 typedef tdual_x_array::t_host_const_randomread t_x_array_randomread;
854 
855 //Velocity Types
856 //1d V_FLOAT array n
857 typedef Kokkos::DualView<V_FLOAT*, DeviceType::array_layout, DeviceType> tdual_vfloat_1d;
858 typedef tdual_vfloat_1d::t_host t_vfloat_1d;
859 typedef tdual_vfloat_1d::t_host_const t_vfloat_1d_const;
860 typedef tdual_vfloat_1d::t_host_um t_vfloat_1d_um;
861 typedef tdual_vfloat_1d::t_host_const_um t_vfloat_1d_const_um;
862 typedef tdual_vfloat_1d::t_host_const_randomread t_vfloat_1d_randomread;
863 
864 //2d V_FLOAT array n*m
865 typedef Kokkos::DualView<V_FLOAT**, Kokkos::LayoutRight, DeviceType> tdual_vfloat_2d;
866 typedef tdual_vfloat_2d::t_host t_vfloat_2d;
867 typedef tdual_vfloat_2d::t_host_const t_vfloat_2d_const;
868 typedef tdual_vfloat_2d::t_host_um t_vfloat_2d_um;
869 typedef tdual_vfloat_2d::t_host_const_um t_vfloat_2d_const_um;
870 typedef tdual_vfloat_2d::t_host_const_randomread t_vfloat_2d_randomread;
871 
872 //2d V_FLOAT array n*3
873 typedef Kokkos::DualView<V_FLOAT*[3], Kokkos::LayoutRight, DeviceType> tdual_v_array;
874 //typedef Kokkos::DualView<V_FLOAT*[3], DeviceType::array_layout, DeviceType> tdual_v_array;
875 typedef tdual_v_array::t_host t_v_array;
876 typedef tdual_v_array::t_host_const t_v_array_const;
877 typedef tdual_v_array::t_host_um t_v_array_um;
878 typedef tdual_v_array::t_host_const_um t_v_array_const_um;
879 typedef tdual_v_array::t_host_const_randomread t_v_array_randomread;
880 
881 //Force Types
882 //1d F_FLOAT array n
883 typedef Kokkos::DualView<F_FLOAT*, DeviceType::array_layout, DeviceType> tdual_ffloat_1d;
884 typedef tdual_ffloat_1d::t_host t_ffloat_1d;
885 typedef tdual_ffloat_1d::t_host_const t_ffloat_1d_const;
886 typedef tdual_ffloat_1d::t_host_um t_ffloat_1d_um;
887 typedef tdual_ffloat_1d::t_host_const_um t_ffloat_1d_const_um;
888 typedef tdual_ffloat_1d::t_host_const_randomread t_ffloat_1d_randomread;
889 
890 //2d F_FLOAT array n*m
891 typedef Kokkos::DualView<F_FLOAT**, Kokkos::LayoutRight, DeviceType> tdual_float_2d_lr;
892 typedef tdual_float_2d_lr::t_host t_float_2d_lr;
893 typedef tdual_float_2d_lr::t_host_const t_float_2d_lr_const;
894 typedef tdual_float_2d_lr::t_host_um t_float_2d_lr_um;
895 typedef tdual_float_2d_lr::t_host_const_um t_float_2d_lr_const_um;
896 typedef tdual_float_2d_lr::t_host_const_randomread t_float_2d_lr_randomread;
897 
898 //2d F_FLOAT array n*3
899 typedef Kokkos::DualView<F_FLOAT*[3], Kokkos::LayoutRight, DeviceType> tdual_f_array;
900 //typedef Kokkos::DualView<F_FLOAT*[3], DeviceType::array_layout, DeviceType> tdual_f_array;
901 typedef tdual_f_array::t_host t_f_array;
902 typedef tdual_f_array::t_host_const t_f_array_const;
903 typedef tdual_f_array::t_host_um t_f_array_um;
904 typedef tdual_f_array::t_host_const_um t_f_array_const_um;
905 typedef tdual_f_array::t_host_const_randomread t_f_array_randomread;
906 
907 //2d F_FLOAT array n*6 (for virial)
908 typedef Kokkos::DualView<F_FLOAT*[6], Kokkos::LayoutRight, DeviceType> tdual_virial_array;
909 typedef tdual_virial_array::t_host t_virial_array;
910 typedef tdual_virial_array::t_host_const t_virial_array_const;
911 typedef tdual_virial_array::t_host_um t_virial_array_um;
912 typedef tdual_virial_array::t_host_const_um t_virial_array_const_um;
913 typedef tdual_virial_array::t_host_const_randomread t_virial_array_randomread;
914 
915 
916 
917 //Energy Types
918 //1d E_FLOAT array n
919 typedef Kokkos::DualView<E_FLOAT*, DeviceType::array_layout, DeviceType> tdual_efloat_1d;
920 typedef tdual_efloat_1d::t_host t_efloat_1d;
921 typedef tdual_efloat_1d::t_host_const t_efloat_1d_const;
922 typedef tdual_efloat_1d::t_host_um t_efloat_1d_um;
923 typedef tdual_efloat_1d::t_host_const_um t_efloat_1d_const_um;
924 typedef tdual_efloat_1d::t_host_const_randomread t_efloat_1d_randomread;
925 
926 //2d E_FLOAT array n*m
927 typedef Kokkos::DualView<E_FLOAT**, Kokkos::LayoutRight, DeviceType> tdual_efloat_2d;
928 typedef tdual_efloat_2d::t_host t_efloat_2d;
929 typedef tdual_efloat_2d::t_host_const t_efloat_2d_const;
930 typedef tdual_efloat_2d::t_host_um t_efloat_2d_um;
931 typedef tdual_efloat_2d::t_host_const_um t_efloat_2d_const_um;
932 typedef tdual_efloat_2d::t_host_const_randomread t_efloat_2d_randomread;
933 
934 //2d E_FLOAT array n*3
935 typedef Kokkos::DualView<E_FLOAT*[3], Kokkos::LayoutRight, DeviceType> tdual_e_array;
936 typedef tdual_e_array::t_host t_e_array;
937 typedef tdual_e_array::t_host_const t_e_array_const;
938 typedef tdual_e_array::t_host_um t_e_array_um;
939 typedef tdual_e_array::t_host_const_um t_e_array_const_um;
940 typedef tdual_e_array::t_host_const_randomread t_e_array_randomread;
941 
942 //Neighbor Types
943 typedef Kokkos::DualView<int**, DeviceType::array_layout, DeviceType> tdual_neighbors_2d;
944 typedef tdual_neighbors_2d::t_host t_neighbors_2d;
945 typedef tdual_neighbors_2d::t_host_const t_neighbors_2d_const;
946 typedef tdual_neighbors_2d::t_host_um t_neighbors_2d_um;
947 typedef tdual_neighbors_2d::t_host_const_um t_neighbors_2d_const_um;
948 typedef tdual_neighbors_2d::t_host_const_randomread t_neighbors_2d_randomread;
949 
950 typedef Kokkos::DualView<double*,Kokkos::LayoutStride> tdual_float_1d_strided;
951 typedef tdual_float_1d_strided::t_host t_float_1d_strided;
952 typedef tdual_float_1d_strided::t_host_um t_float_1d_strided_um;
953 };
954 #endif
955 
956 template <typename D>
957 struct Graph {
958   using Ints = Kokkos::View<int*, D>;
959   Ints offsets;
960   Ints at;
961   int nedges;
962   KOKKOS_INLINE_FUNCTION
963   int start(int i) const { return offsets(i); }
964   KOKKOS_INLINE_FUNCTION
965   int end(int i) const { return offsets(i + 1); }
966   KOKKOS_INLINE_FUNCTION
967   int count(int i) const { return end(i) - start(i); }
968   KOKKOS_INLINE_FUNCTION
969   int& get(int i, int j) const { return at(start(i) + j); }
970 };
971 
972 //default SPARTA Types
973 typedef struct ArrayTypes<DeviceType> DAT;
974 typedef struct ArrayTypes<SPAHostType> HAT;
975 
976 template<class DeviceType, class BufferView, class DualView>
977 void buffer_view(BufferView &buf, DualView &view,
978                  const size_t n0,
979                  const size_t n1 = 0,
980                  const size_t n2 = 0,
981                  const size_t n3 = 0,
982                  const size_t n4 = 0,
983                  const size_t n5 = 0,
984                  const size_t n6 = 0,
985                  const size_t n7 = 0) {
986 
987   buf = BufferView(
988           view.template d_view.data(),
989           n0,n1,n2,n3,n4,n5,n6,n7);
990 
991 }
992 
993 template<class DeviceType>
994 struct MemsetZeroFunctor {
995   typedef DeviceType  execution_space ;
996   void* ptr;
997   KOKKOS_INLINE_FUNCTION void operator()(const int i) const {
998     ((int*)ptr)[i] = 0;
999   }
1000 };
1001 
1002 template<class ViewType>
1003 void memset_kokkos (ViewType &view) {
1004   static MemsetZeroFunctor<typename ViewType::execution_space> f;
1005   f.ptr = view.data();
1006   Kokkos::parallel_for(view.scan()*sizeof(typename ViewType::value_type)/4, f);
1007   ViewType::execution_space::fence();
1008 }
1009 
1010 #define SPARTA_LAMBDA KOKKOS_LAMBDA
1011 
1012 namespace SPARTA_NS {
1013 template <typename Device>
1014 Kokkos::View<int*, Device> offset_scan(Kokkos::View<int*, Device> a, int& total);
1015 }
1016 
1017 #endif
1018