Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Add duplicated memory to force_lj #21

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/force_types/force_lj_neigh.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,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;
Expand Down
12 changes: 9 additions & 3 deletions src/force_types/force_lj_neigh_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ void ForceLJNeigh<NeighborClass>::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_scatter_view<>(system->f);
type = system->type;
id = system->id;
if (use_stackparams) {
Expand All @@ -122,6 +123,11 @@ void ForceLJNeigh<NeighborClass>::compute(System* system, Binning* binning, Neig
}
Kokkos::fence();

if(half_neigh) {
Kokkos::Experimental::contribute(system->f, f_r);
f_r = decltype(f_r)();
}

step++;
}

Expand All @@ -133,8 +139,6 @@ T_V_FLOAT ForceLJNeigh<NeighborClass>::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;
Expand Down Expand Up @@ -209,6 +213,8 @@ template<class NeighborClass>
template<bool STACKPARAMS>
KOKKOS_INLINE_FUNCTION
void ForceLJNeigh<NeighborClass>::operator() (TagHalfNeigh<STACKPARAMS>, 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);
Expand Down
2 changes: 2 additions & 0 deletions src/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#ifndef TYPES_H
#define TYPES_H
#include<Kokkos_Core.hpp>
#include<Kokkos_ScatterView.hpp>

// Module Types etc
// Units to be used
Expand Down Expand Up @@ -98,6 +99,7 @@ typedef Kokkos::View<T_F_FLOAT*[3],
Kokkos::MemoryTraits<Kokkos::Atomic>>
#endif
t_f_atomic; // Force
typedef Kokkos::Experimental::ScatterView<T_F_FLOAT*[3]> t_f_duplicated; // Force
typedef Kokkos::View<const T_F_FLOAT*[3]> t_f_const; // Force

typedef Kokkos::View<int*> t_type; // Type (int is enough as type)
Expand Down