From 1955d3162d7f8812112906ef2f5391443f87e1c6 Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Fri, 8 Dec 2017 09:19:32 -0700 Subject: [PATCH 1/2] Add duplicated memory to force_lj --- src/force_types/force_lj_neigh.h | 1 + src/force_types/force_lj_neigh_impl.h | 12 +++++++++--- src/types.h | 2 ++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/force_types/force_lj_neigh.h b/src/force_types/force_lj_neigh.h index d918854..6019de1 100644 --- a/src/force_types/force_lj_neigh.h +++ b/src/force_types/force_lj_neigh.h @@ -31,6 +31,7 @@ class ForceLJNeigh: public Force { t_x_const_rnd x; t_f f; t_f_atomic f_a; + t_f_duplicated f_r; t_id id; t_type_const_rnd type; Binning::t_bincount bin_count; diff --git a/src/force_types/force_lj_neigh_impl.h b/src/force_types/force_lj_neigh_impl.h index e9ea403..583a9fe 100644 --- a/src/force_types/force_lj_neigh_impl.h +++ b/src/force_types/force_lj_neigh_impl.h @@ -68,7 +68,8 @@ void ForceLJNeigh::compute(System* system, Binning* binning, Neig N_local = system->N_local; x = system->x; f = system->f; - f_a = system->f; + //f_a = system->f; + f_r = Kokkos::Experimental::create_reduction_view<>(system->f); type = system->type; id = system->id; if (use_stackparams) { @@ -84,6 +85,11 @@ void ForceLJNeigh::compute(System* system, Binning* binning, Neig } Kokkos::fence(); + if(half_neigh) { + Kokkos::Experimental::contribute(system->f, f_r); + f_r = decltype(f_r)(); + } + step++; } @@ -95,8 +101,6 @@ T_V_FLOAT ForceLJNeigh::compute_energy(System* system, Binning* b N_local = system->N_local; x = system->x; - f = system->f; - f_a = system->f; type = system->type; id = system->id; T_V_FLOAT energy; @@ -171,6 +175,8 @@ template template KOKKOS_INLINE_FUNCTION void ForceLJNeigh::operator() (TagHalfNeigh, const T_INT& i) const { + auto f_a = f_r.access(); + const T_F_FLOAT x_i = x(i,0); const T_F_FLOAT y_i = x(i,1); const T_F_FLOAT z_i = x(i,2); diff --git a/src/types.h b/src/types.h index 25d1334..31f7ce8 100644 --- a/src/types.h +++ b/src/types.h @@ -1,6 +1,7 @@ #ifndef TYPES_H #define TYPES_H #include +#include // Module Types etc // Units to be used @@ -60,6 +61,7 @@ typedef Kokkos::View> #endif t_f_atomic; // Force +typedef Kokkos::Experimental::ReductionView t_f_duplicated; // Force typedef Kokkos::View t_f_const; // Force typedef Kokkos::View t_type; // Type (int is enough as type) From a77a1b944616ef4ccafbb249f75328011c65ba28 Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Fri, 8 Dec 2017 10:26:14 -0700 Subject: [PATCH 2/2] Rename ReductionView to ScatterView --- src/force_types/force_lj_neigh_impl.h | 2 +- src/types.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/force_types/force_lj_neigh_impl.h b/src/force_types/force_lj_neigh_impl.h index 583a9fe..f853d9c 100644 --- a/src/force_types/force_lj_neigh_impl.h +++ b/src/force_types/force_lj_neigh_impl.h @@ -69,7 +69,7 @@ void ForceLJNeigh::compute(System* system, Binning* binning, Neig x = system->x; f = system->f; //f_a = system->f; - f_r = Kokkos::Experimental::create_reduction_view<>(system->f); + f_r = Kokkos::Experimental::create_scatter_view<>(system->f); type = system->type; id = system->id; if (use_stackparams) { diff --git a/src/types.h b/src/types.h index 31f7ce8..14eee9a 100644 --- a/src/types.h +++ b/src/types.h @@ -1,7 +1,7 @@ #ifndef TYPES_H #define TYPES_H #include -#include +#include // Module Types etc // Units to be used @@ -61,7 +61,7 @@ typedef Kokkos::View> #endif t_f_atomic; // Force -typedef Kokkos::Experimental::ReductionView t_f_duplicated; // Force +typedef Kokkos::Experimental::ScatterView t_f_duplicated; // Force typedef Kokkos::View t_f_const; // Force typedef Kokkos::View t_type; // Type (int is enough as type)