From 1ee85e59c3f25bb9fb70c8c703417cbac6b818bc Mon Sep 17 00:00:00 2001 From: Stefan Paquay Date: Fri, 1 Jun 2018 14:50:41 -0400 Subject: [PATCH 01/13] Removed obsolete changes to fix_nve-manifold_rattle --- src/USER-MANIFOLD/fix_nve_manifold_rattle.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/USER-MANIFOLD/fix_nve_manifold_rattle.cpp b/src/USER-MANIFOLD/fix_nve_manifold_rattle.cpp index 543d49278d..4dcc3f9704 100644 --- a/src/USER-MANIFOLD/fix_nve_manifold_rattle.cpp +++ b/src/USER-MANIFOLD/fix_nve_manifold_rattle.cpp @@ -513,6 +513,7 @@ void FixNVEManifoldRattle::rattle_manifold_x(double *x, double *v, const double c_inv = 1.0 / c; + while ( 1 ) { v[0] = vt[0] - l*no_dt[0]; v[1] = vt[1] - l*no_dt[1]; @@ -650,10 +651,10 @@ void FixNVEManifoldRattle::rattle_manifold_v(double *v, double *f, }while( (res > tolerance) && (iters < max_iter) ); if( iters >= max_iter && res >= tolerance ){ - char msg[2048]; - sprintf(msg,"Failed to constrain atom %d (x = (%f, %f, %f)! res = %e, iters = %d\n", - tagi, x[0], x[1], x[2], res, iters); - error->all(FLERR,msg); + char msg[2048]; + sprintf(msg,"Failed to constrain atom %d (x = (%f, %f, %f)! res = %e, iters = %d\n", + tagi, x[0], x[1], x[2], res, iters); + error->all(FLERR,msg); } stats.v_iters += iters; From 962946ee45df30722b1288afde0f7be334049842 Mon Sep 17 00:00:00 2001 From: Stefan Paquay Date: Fri, 1 Jun 2018 14:52:34 -0400 Subject: [PATCH 02/13] Ported fix enforce2d to Kokkos. --- doc/src/fix_enforce2d.txt | 1 + src/KOKKOS/fix_enforce2d_kokkos.cpp | 102 ++++++++++++++++++++++++++++ src/KOKKOS/fix_enforce2d_kokkos.h | 92 +++++++++++++++++++++++++ 3 files changed, 195 insertions(+) create mode 100644 src/KOKKOS/fix_enforce2d_kokkos.cpp create mode 100644 src/KOKKOS/fix_enforce2d_kokkos.h diff --git a/doc/src/fix_enforce2d.txt b/doc/src/fix_enforce2d.txt index 5d04e96677..01840254b6 100644 --- a/doc/src/fix_enforce2d.txt +++ b/doc/src/fix_enforce2d.txt @@ -7,6 +7,7 @@ :line fix enforce2d command :h3 +fix enforce2d/kk command :h3 [Syntax:] diff --git a/src/KOKKOS/fix_enforce2d_kokkos.cpp b/src/KOKKOS/fix_enforce2d_kokkos.cpp new file mode 100644 index 0000000000..b5fb964ea8 --- /dev/null +++ b/src/KOKKOS/fix_enforce2d_kokkos.cpp @@ -0,0 +1,102 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Contributing authors: Stefan Paquay (Brandeis University) +------------------------------------------------------------------------- */ + +#include "atom_masks.h" +#include "atom_kokkos.h" +#include "fix_enforce2d_kokkos.h" + +using namespace LAMMPS_NS; + + +template +FixEnforce2DKokkos::FixEnforce2DKokkos(LAMMPS *lmp, int narg, char **arg) : + FixEnforce2D(lmp, narg, arg) +{ + kokkosable = 1; + atomKK = (AtomKokkos *) atom; + execution_space = ExecutionSpaceFromDevice::space; + + datamask_read = X_MASK | V_MASK | F_MASK | MASK_MASK; + datamask_modify = X_MASK | V_MASK | F_MASK; +} + + +template +void FixEnforce2DKokkos::setup(int vflag) +{ + post_force(vflag); +} + + +template +void FixEnforce2DKokkos::post_force(int vflag) +{ + atomKK->sync(execution_space,datamask_read); + atomKK->modified(execution_space,datamask_modify); + + x = atomKK->k_x.view(); + v = atomKK->k_v.view(); + f = atomKK->k_f.view(); + + mask = atomKK->k_mask.view(); + + int nlocal = atomKK->nlocal; + if (igroup == atomKK->firstgroup) nlocal = atomKK->nfirst; + + FixEnforce2DKokkosPostForceFunctor functor(this); + Kokkos::parallel_for(nlocal,functor); + + // Probably sync here again? + atomKK->sync(execution_space,datamask_read); + atomKK->modified(execution_space,datamask_modify); + + for (int m = 0; m < nfixlist; m++) + flist[m]->enforce2d(); + + +} + + +template +void FixEnforce2DKokkos::post_force_item( int i ) const +{ + + if (mask[i] & groupbit){ + v(i,2) = 0; + x(i,2) = 0; + f(i,2) = 0; + + // Add for omega, angmom, torque... + } + +} + + +template +void FixEnforce2DKokkos::cleanup_copy() +{ + id = style = NULL; + vatom = NULL; +} + + +namespace LAMMPS_NS { +template class FixEnforce2DKokkos; +#ifdef KOKKOS_HAVE_CUDA +template class FixEnforce2DKokkos; +#endif +} diff --git a/src/KOKKOS/fix_enforce2d_kokkos.h b/src/KOKKOS/fix_enforce2d_kokkos.h new file mode 100644 index 0000000000..11cb213210 --- /dev/null +++ b/src/KOKKOS/fix_enforce2d_kokkos.h @@ -0,0 +1,92 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#ifdef FIX_CLASS + +FixStyle(enforce2d/kk,FixEnforce2DKokkos) +FixStyle(enforce2d/kk/device,FixEnforce2DKokkos) +FixStyle(enforce2d/kk/host,FixEnforce2DKokkos) + +#else + +#ifndef LMP_FIX_ENFORCE2D_KOKKOS_H +#define LMP_FIX_ENFORCE2D_KOKKOS_H + +#include "fix_enforce2d.h" +#include "kokkos_type.h" + +namespace LAMMPS_NS { + +template +class FixEnforce2DKokkos : public FixEnforce2D { + public: + FixEnforce2DKokkos(class LAMMPS *, int, char **); + // ~FixEnforce2DKokkos() {} + // void init(); + void cleanup_copy(); + void setup(int); + void post_force(int); + + KOKKOS_INLINE_FUNCTION + void post_force_item(int) const; + + // void min_setup(int); Kokkos does not support minimization (yet) + // void min_post_force(int); Kokkos does not support minimization (yet) + // void post_force_respa(int, int, int); No RRESPA support yet. + + private: + + typename ArrayTypes::t_x_array x; + typename ArrayTypes::t_v_array v; + typename ArrayTypes::t_f_array f; + + typename ArrayTypes::t_int_1d mask; +}; + + +template +struct FixEnforce2DKokkosPostForceFunctor { + typedef DeviceType device_type; + FixEnforce2DKokkos c; + + FixEnforce2DKokkosPostForceFunctor(FixEnforce2DKokkos* c_ptr): + c(*c_ptr) {c.cleanup_copy();}; + KOKKOS_INLINE_FUNCTION + void operator()(const int i) const { + c.post_force_item(i); + } +}; + + +} + +#endif +#endif + +/* ERROR/WARNING messages: + +E: Illegal ... command + +Self-explanatory. Check the input script syntax and compare to the +documentation for the command. You can use -echo screen as a +command-line option when running LAMMPS to see the offending line. + +E: Cannot use fix enforce2d with 3d simulation + +Self-explanatory. + +E: Fix enforce2d must be defined after fix %s + +UNDOCUMENTED + +*/ From 031077b4fa2c62d59da6720b68c7dd633eb87377 Mon Sep 17 00:00:00 2001 From: Stefan Paquay Date: Fri, 1 Jun 2018 17:19:53 -0400 Subject: [PATCH 03/13] Made enforce2d also set rotations to in-plane. --- src/KOKKOS/fix_enforce2d_kokkos.cpp | 104 ++++++++++++++++++++++++---- src/KOKKOS/fix_enforce2d_kokkos.h | 15 ++-- 2 files changed, 102 insertions(+), 17 deletions(-) diff --git a/src/KOKKOS/fix_enforce2d_kokkos.cpp b/src/KOKKOS/fix_enforce2d_kokkos.cpp index b5fb964ea8..88291ead6e 100644 --- a/src/KOKKOS/fix_enforce2d_kokkos.cpp +++ b/src/KOKKOS/fix_enforce2d_kokkos.cpp @@ -12,13 +12,16 @@ ------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- - Contributing authors: Stefan Paquay (Brandeis University) + Contributing authors: Stefan Paquay & Matthew Peterson (Brandeis University) ------------------------------------------------------------------------- */ #include "atom_masks.h" #include "atom_kokkos.h" +#include "comm.h" +#include "error.h" #include "fix_enforce2d_kokkos.h" + using namespace LAMMPS_NS; @@ -30,14 +33,21 @@ FixEnforce2DKokkos::FixEnforce2DKokkos(LAMMPS *lmp, int narg, char * atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; - datamask_read = X_MASK | V_MASK | F_MASK | MASK_MASK; - datamask_modify = X_MASK | V_MASK | F_MASK; + datamask_read = X_MASK | V_MASK | F_MASK | OMEGA_MASK | MASK_MASK; + /* TORQUE_MASK | ANGMOM_MASK | */ // MASK_MASK; + + datamask_modify = X_MASK | V_MASK | F_MASK | OMEGA_MASK; // | + /* TORQUE_MASK | ANGMOM_MASK */ ; } template void FixEnforce2DKokkos::setup(int vflag) { + if( comm->me == 0 ){ + fprintf(screen, "omega, angmom and torque flags are %d, %d, %d\n", + atomKK->omega_flag, atomKK->angmom_flag, atomKK->torque_flag ); + } post_force(vflag); } @@ -52,13 +62,71 @@ void FixEnforce2DKokkos::post_force(int vflag) v = atomKK->k_v.view(); f = atomKK->k_f.view(); + if( atomKK->omega_flag ) + omega = atomKK->k_omega.view(); + + if( atomKK->angmom_flag ) + angmom = atomKK->k_angmom.view(); + + if( atomKK->torque_flag ) + torque = atomKK->k_torque.view(); + + mask = atomKK->k_mask.view(); int nlocal = atomKK->nlocal; if (igroup == atomKK->firstgroup) nlocal = atomKK->nfirst; - FixEnforce2DKokkosPostForceFunctor functor(this); - Kokkos::parallel_for(nlocal,functor); + int flag_mask = 0; + if( atomKK->omega_flag ) flag_mask |= 1; + if( atomKK->angmom_flag ) flag_mask |= 2; + if( atomKK->torque_flag ) flag_mask |= 4; + + switch( flag_mask ){ + case 0:{ + FixEnforce2DKokkosPostForceFunctor functor(this); + Kokkos::parallel_for(nlocal,functor); + break; + } + case 1:{ + FixEnforce2DKokkosPostForceFunctor functor(this); + Kokkos::parallel_for(nlocal,functor); + break; + } + case 2:{ + FixEnforce2DKokkosPostForceFunctor functor(this); + Kokkos::parallel_for(nlocal,functor); + break; + } + case 3:{ + FixEnforce2DKokkosPostForceFunctor functor(this); + Kokkos::parallel_for(nlocal,functor); + break; + } + case 4:{ + FixEnforce2DKokkosPostForceFunctor functor(this); + Kokkos::parallel_for(nlocal,functor); + break; + } + case 5:{ + FixEnforce2DKokkosPostForceFunctor functor(this); + Kokkos::parallel_for(nlocal,functor); + break; + } + case 6:{ + FixEnforce2DKokkosPostForceFunctor functor(this); + Kokkos::parallel_for(nlocal,functor); + break; + } + case 7:{ + FixEnforce2DKokkosPostForceFunctor functor(this); + Kokkos::parallel_for(nlocal,functor); + break; + } + default: + error->all(FLERR, "flag_mask outside of what it should be"); + } + // Probably sync here again? atomKK->sync(execution_space,datamask_read); @@ -66,23 +134,33 @@ void FixEnforce2DKokkos::post_force(int vflag) for (int m = 0; m < nfixlist; m++) flist[m]->enforce2d(); - - } template +template void FixEnforce2DKokkos::post_force_item( int i ) const { - if (mask[i] & groupbit){ - v(i,2) = 0; - x(i,2) = 0; - f(i,2) = 0; + // x(i,2) = 0; // Enforce2d does not set x[2] to zero either... :/ + v(i,2) = 0.0; + f(i,2) = 0.0; - // Add for omega, angmom, torque... + if(omega_flag){ + omega(i,0) = 0.0; + omega(i,1) = 0.0; + } + + if(angmom_flag){ + angmom(i,0) = 0.0; + angmom(i,1) = 0.0; + } + + if(torque_flag){ + torque(i,0) = 0.0; + torque(i,1) = 0.0; + } } - } diff --git a/src/KOKKOS/fix_enforce2d_kokkos.h b/src/KOKKOS/fix_enforce2d_kokkos.h index 11cb213210..4130797f2c 100644 --- a/src/KOKKOS/fix_enforce2d_kokkos.h +++ b/src/KOKKOS/fix_enforce2d_kokkos.h @@ -37,8 +37,9 @@ class FixEnforce2DKokkos : public FixEnforce2D { void setup(int); void post_force(int); + template KOKKOS_INLINE_FUNCTION - void post_force_item(int) const; + void post_force_item(const int i) const; // void min_setup(int); Kokkos does not support minimization (yet) // void min_post_force(int); Kokkos does not support minimization (yet) @@ -50,20 +51,26 @@ class FixEnforce2DKokkos : public FixEnforce2D { typename ArrayTypes::t_v_array v; typename ArrayTypes::t_f_array f; + typename ArrayTypes::t_v_array omega; + typename ArrayTypes::t_v_array angmom; + typename ArrayTypes::t_f_array torque; + typename ArrayTypes::t_int_1d mask; }; -template -struct FixEnforce2DKokkosPostForceFunctor { +template +struct FixEnforce2DKokkosPostForceFunctor { typedef DeviceType device_type; FixEnforce2DKokkos c; FixEnforce2DKokkosPostForceFunctor(FixEnforce2DKokkos* c_ptr): c(*c_ptr) {c.cleanup_copy();}; + KOKKOS_INLINE_FUNCTION void operator()(const int i) const { - c.post_force_item(i); + // c.template? Really C++? + c.template post_force_item (i); } }; From 0e9691831321c8d2c4f03614b3076eaa34f48f2f Mon Sep 17 00:00:00 2001 From: Stefan Paquay Date: Fri, 1 Jun 2018 17:22:25 -0400 Subject: [PATCH 04/13] Made enforce2d_kokkos actually set data masks. --- src/KOKKOS/fix_enforce2d_kokkos.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/KOKKOS/fix_enforce2d_kokkos.cpp b/src/KOKKOS/fix_enforce2d_kokkos.cpp index 88291ead6e..e9a42e5c31 100644 --- a/src/KOKKOS/fix_enforce2d_kokkos.cpp +++ b/src/KOKKOS/fix_enforce2d_kokkos.cpp @@ -33,11 +33,11 @@ FixEnforce2DKokkos::FixEnforce2DKokkos(LAMMPS *lmp, int narg, char * atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; - datamask_read = X_MASK | V_MASK | F_MASK | OMEGA_MASK | MASK_MASK; - /* TORQUE_MASK | ANGMOM_MASK | */ // MASK_MASK; + datamask_read = X_MASK | V_MASK | F_MASK | OMEGA_MASK | MASK_MASK + | TORQUE_MASK | ANGMOM_MASK; // | */ // MASK_MASK; - datamask_modify = X_MASK | V_MASK | F_MASK | OMEGA_MASK; // | - /* TORQUE_MASK | ANGMOM_MASK */ ; + datamask_modify = X_MASK | V_MASK | F_MASK | OMEGA_MASK + | TORQUE_MASK | ANGMOM_MASK; } From 824a21a661fe679fadaf3ef7f43e954a9e35e7a6 Mon Sep 17 00:00:00 2001 From: Stefan Paquay Date: Mon, 4 Jun 2018 12:28:06 -0400 Subject: [PATCH 05/13] Removed debug printing from setup. --- src/KOKKOS/fix_enforce2d_kokkos.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/KOKKOS/fix_enforce2d_kokkos.cpp b/src/KOKKOS/fix_enforce2d_kokkos.cpp index e9a42e5c31..8ba68a0c0c 100644 --- a/src/KOKKOS/fix_enforce2d_kokkos.cpp +++ b/src/KOKKOS/fix_enforce2d_kokkos.cpp @@ -44,10 +44,6 @@ FixEnforce2DKokkos::FixEnforce2DKokkos(LAMMPS *lmp, int narg, char * template void FixEnforce2DKokkos::setup(int vflag) { - if( comm->me == 0 ){ - fprintf(screen, "omega, angmom and torque flags are %d, %d, %d\n", - atomKK->omega_flag, atomKK->angmom_flag, atomKK->torque_flag ); - } post_force(vflag); } From 4bf9a93c11c9f2baf4290dea63b6db6e7ad199cb Mon Sep 17 00:00:00 2001 From: Stefan Paquay Date: Wed, 6 Jun 2018 10:47:07 -0400 Subject: [PATCH 06/13] Removed x dependency from enforce2d_kokkos. --- src/KOKKOS/fix_enforce2d_kokkos.cpp | 9 ++++++--- src/KOKKOS/fix_enforce2d_kokkos.h | 2 -- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/KOKKOS/fix_enforce2d_kokkos.cpp b/src/KOKKOS/fix_enforce2d_kokkos.cpp index 8ba68a0c0c..da33455978 100644 --- a/src/KOKKOS/fix_enforce2d_kokkos.cpp +++ b/src/KOKKOS/fix_enforce2d_kokkos.cpp @@ -33,10 +33,10 @@ FixEnforce2DKokkos::FixEnforce2DKokkos(LAMMPS *lmp, int narg, char * atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; - datamask_read = X_MASK | V_MASK | F_MASK | OMEGA_MASK | MASK_MASK + datamask_read = V_MASK | F_MASK | OMEGA_MASK | MASK_MASK | TORQUE_MASK | ANGMOM_MASK; // | */ // MASK_MASK; - datamask_modify = X_MASK | V_MASK | F_MASK | OMEGA_MASK + datamask_modify = V_MASK | F_MASK | OMEGA_MASK | TORQUE_MASK | ANGMOM_MASK; } @@ -44,6 +44,10 @@ FixEnforce2DKokkos::FixEnforce2DKokkos(LAMMPS *lmp, int narg, char * template void FixEnforce2DKokkos::setup(int vflag) { + if( comm->me == 0 ){ + fprintf(screen, "omega, angmom and torque flags are %d, %d, %d\n", + atomKK->omega_flag, atomKK->angmom_flag, atomKK->torque_flag ); + } post_force(vflag); } @@ -54,7 +58,6 @@ void FixEnforce2DKokkos::post_force(int vflag) atomKK->sync(execution_space,datamask_read); atomKK->modified(execution_space,datamask_modify); - x = atomKK->k_x.view(); v = atomKK->k_v.view(); f = atomKK->k_f.view(); diff --git a/src/KOKKOS/fix_enforce2d_kokkos.h b/src/KOKKOS/fix_enforce2d_kokkos.h index 4130797f2c..d8a13d281f 100644 --- a/src/KOKKOS/fix_enforce2d_kokkos.h +++ b/src/KOKKOS/fix_enforce2d_kokkos.h @@ -46,8 +46,6 @@ class FixEnforce2DKokkos : public FixEnforce2D { // void post_force_respa(int, int, int); No RRESPA support yet. private: - - typename ArrayTypes::t_x_array x; typename ArrayTypes::t_v_array v; typename ArrayTypes::t_f_array f; From e08ccd0a7c62b71fa8cb8f3cd4f54b83ca2ed7de Mon Sep 17 00:00:00 2001 From: Stefan Paquay Date: Fri, 29 Jun 2018 11:58:27 -0400 Subject: [PATCH 07/13] Forgot to include change in fix_enforce2d to access fixlist in kokkos port. --- src/fix_enforce2d.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fix_enforce2d.h b/src/fix_enforce2d.h index cdead78f6a..a3f79309dc 100644 --- a/src/fix_enforce2d.h +++ b/src/fix_enforce2d.h @@ -36,7 +36,7 @@ class FixEnforce2D : public Fix { void post_force_respa(int, int, int); void min_post_force(int); - private: + protected: int nfixlist; class Fix **flist; }; From 24405217d04153ba8eaf9d204d595e0a428cb6f7 Mon Sep 17 00:00:00 2001 From: Stefan Paquay Date: Thu, 5 Jul 2018 11:20:27 -0400 Subject: [PATCH 08/13] Updated Install.sh in KOKKOS. --- src/KOKKOS/Install.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/KOKKOS/Install.sh b/src/KOKKOS/Install.sh index c6fab2a1b1..08c7468a49 100755 --- a/src/KOKKOS/Install.sh +++ b/src/KOKKOS/Install.sh @@ -93,6 +93,8 @@ action domain_kokkos.cpp action domain_kokkos.h action fix_deform_kokkos.cpp action fix_deform_kokkos.h +action fix_enforce2d_kokkos.cpp +action fix_enforce2d_kokkos.h action fix_eos_table_rx_kokkos.cpp fix_eos_table_rx.cpp action fix_eos_table_rx_kokkos.h fix_eos_table_rx.h action fix_langevin_kokkos.cpp From db75232957d5964f07df7dc6d1f774ca089fc3b8 Mon Sep 17 00:00:00 2001 From: Stefan Paquay Date: Fri, 6 Jul 2018 11:31:48 -0400 Subject: [PATCH 09/13] Removed debug print and comment. --- src/KOKKOS/fix_enforce2d_kokkos.cpp | 4 ---- src/KOKKOS/fix_enforce2d_kokkos.h | 1 - 2 files changed, 5 deletions(-) diff --git a/src/KOKKOS/fix_enforce2d_kokkos.cpp b/src/KOKKOS/fix_enforce2d_kokkos.cpp index da33455978..f2c313b2fe 100644 --- a/src/KOKKOS/fix_enforce2d_kokkos.cpp +++ b/src/KOKKOS/fix_enforce2d_kokkos.cpp @@ -44,10 +44,6 @@ FixEnforce2DKokkos::FixEnforce2DKokkos(LAMMPS *lmp, int narg, char * template void FixEnforce2DKokkos::setup(int vflag) { - if( comm->me == 0 ){ - fprintf(screen, "omega, angmom and torque flags are %d, %d, %d\n", - atomKK->omega_flag, atomKK->angmom_flag, atomKK->torque_flag ); - } post_force(vflag); } diff --git a/src/KOKKOS/fix_enforce2d_kokkos.h b/src/KOKKOS/fix_enforce2d_kokkos.h index d8a13d281f..ae8183acf1 100644 --- a/src/KOKKOS/fix_enforce2d_kokkos.h +++ b/src/KOKKOS/fix_enforce2d_kokkos.h @@ -67,7 +67,6 @@ struct FixEnforce2DKokkosPostForceFunctor { KOKKOS_INLINE_FUNCTION void operator()(const int i) const { - // c.template? Really C++? c.template post_force_item (i); } }; From 0c1dcfb617e9b0f4aeb3a38919d14b20ab09b357 Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Fri, 6 Jul 2018 17:06:37 -0600 Subject: [PATCH 10/13] Favor copymode instead of cleanup_copy --- src/KOKKOS/fix_enforce2d_kokkos.cpp | 11 ++--------- src/KOKKOS/fix_enforce2d_kokkos.h | 3 +-- src/fix_enforce2d.cpp | 2 ++ 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/KOKKOS/fix_enforce2d_kokkos.cpp b/src/KOKKOS/fix_enforce2d_kokkos.cpp index f2c313b2fe..33aa39e2f6 100644 --- a/src/KOKKOS/fix_enforce2d_kokkos.cpp +++ b/src/KOKKOS/fix_enforce2d_kokkos.cpp @@ -77,6 +77,7 @@ void FixEnforce2DKokkos::post_force(int vflag) if( atomKK->angmom_flag ) flag_mask |= 2; if( atomKK->torque_flag ) flag_mask |= 4; + copymode = 1; switch( flag_mask ){ case 0:{ FixEnforce2DKokkosPostForceFunctor functor(this); @@ -121,7 +122,7 @@ void FixEnforce2DKokkos::post_force(int vflag) default: error->all(FLERR, "flag_mask outside of what it should be"); } - + copymode = 0; // Probably sync here again? atomKK->sync(execution_space,datamask_read); @@ -159,14 +160,6 @@ void FixEnforce2DKokkos::post_force_item( int i ) const } -template -void FixEnforce2DKokkos::cleanup_copy() -{ - id = style = NULL; - vatom = NULL; -} - - namespace LAMMPS_NS { template class FixEnforce2DKokkos; #ifdef KOKKOS_HAVE_CUDA diff --git a/src/KOKKOS/fix_enforce2d_kokkos.h b/src/KOKKOS/fix_enforce2d_kokkos.h index ae8183acf1..1ed3cf3ef8 100644 --- a/src/KOKKOS/fix_enforce2d_kokkos.h +++ b/src/KOKKOS/fix_enforce2d_kokkos.h @@ -33,7 +33,6 @@ class FixEnforce2DKokkos : public FixEnforce2D { FixEnforce2DKokkos(class LAMMPS *, int, char **); // ~FixEnforce2DKokkos() {} // void init(); - void cleanup_copy(); void setup(int); void post_force(int); @@ -63,7 +62,7 @@ struct FixEnforce2DKokkosPostForceFunctor { FixEnforce2DKokkos c; FixEnforce2DKokkosPostForceFunctor(FixEnforce2DKokkos* c_ptr): - c(*c_ptr) {c.cleanup_copy();}; + c(*c_ptr) {}; KOKKOS_INLINE_FUNCTION void operator()(const int i) const { diff --git a/src/fix_enforce2d.cpp b/src/fix_enforce2d.cpp index 4ffd2ca7ac..791a52c50c 100644 --- a/src/fix_enforce2d.cpp +++ b/src/fix_enforce2d.cpp @@ -38,6 +38,8 @@ FixEnforce2D::FixEnforce2D(LAMMPS *lmp, int narg, char **arg) : FixEnforce2D::~FixEnforce2D() { + if (copymode) return; + delete [] flist; } From 5d133214258d317ec80b8599eb24e007823732bf Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Wed, 11 Jul 2018 12:15:50 -0600 Subject: [PATCH 11/13] Standardize suffix paragraph in fix_enforce2d.txt --- doc/src/fix_enforce2d.txt | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/doc/src/fix_enforce2d.txt b/doc/src/fix_enforce2d.txt index 01840254b6..4bbf41d25d 100644 --- a/doc/src/fix_enforce2d.txt +++ b/doc/src/fix_enforce2d.txt @@ -28,12 +28,13 @@ not move from their initial z coordinate. :line -Styles with a suffix are functionally the same as the corresponding -style without the suffix. They have been optimized to run faster, -depending on your available hardware, as discussed in -"Section 5"_Section_accelerate.html of the manual. The -accelerated styles take the same arguments and should produce the same -results, except for round-off and precision issues. +Styles with a {gpu}, {intel}, {kk}, {omp}, or {opt} suffix are +functionally the same as the corresponding style without the suffix. +They have been optimized to run faster, depending on your available +hardware, as discussed in "Section 5"_Section_accelerate.html +of the manual. The accelerated styles take the same arguments and +should produce the same results, except for round-off and precision +issues. These accelerated styles are part of the GPU, USER-INTEL, KOKKOS, USER-OMP and OPT packages, respectively. They are only enabled if From 71f699123374944f5620b2fb2b1b18104e7b7346 Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Wed, 11 Jul 2018 12:39:04 -0600 Subject: [PATCH 12/13] Small tweaks to fix_enforce2d_kokkos --- src/KOKKOS/fix_enforce2d_kokkos.cpp | 14 +++++++------- src/KOKKOS/fix_enforce2d_kokkos.h | 15 ++------------- 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/src/KOKKOS/fix_enforce2d_kokkos.cpp b/src/KOKKOS/fix_enforce2d_kokkos.cpp index 33aa39e2f6..26075b269c 100644 --- a/src/KOKKOS/fix_enforce2d_kokkos.cpp +++ b/src/KOKKOS/fix_enforce2d_kokkos.cpp @@ -34,7 +34,7 @@ FixEnforce2DKokkos::FixEnforce2DKokkos(LAMMPS *lmp, int narg, char * execution_space = ExecutionSpaceFromDevice::space; datamask_read = V_MASK | F_MASK | OMEGA_MASK | MASK_MASK - | TORQUE_MASK | ANGMOM_MASK; // | */ // MASK_MASK; + | TORQUE_MASK | ANGMOM_MASK; datamask_modify = V_MASK | F_MASK | OMEGA_MASK | TORQUE_MASK | ANGMOM_MASK; @@ -52,7 +52,6 @@ template void FixEnforce2DKokkos::post_force(int vflag) { atomKK->sync(execution_space,datamask_read); - atomKK->modified(execution_space,datamask_modify); v = atomKK->k_v.view(); f = atomKK->k_f.view(); @@ -120,16 +119,18 @@ void FixEnforce2DKokkos::post_force(int vflag) break; } default: - error->all(FLERR, "flag_mask outside of what it should be"); + error->all(FLERR, "Flag in fix_enforce2d_kokkos outside of what it should be"); } copymode = 0; - // Probably sync here again? - atomKK->sync(execution_space,datamask_read); atomKK->modified(execution_space,datamask_modify); - for (int m = 0; m < nfixlist; m++) + for (int m = 0; m < nfixlist; m++) { + atomKK->sync(flist[m]->execution_space,flist[m]->datamask_read); flist[m]->enforce2d(); + atomKK->modified(flist[m]->execution_space,flist[m]->datamask_modify); + } + } @@ -138,7 +139,6 @@ template void FixEnforce2DKokkos::post_force_item( int i ) const { if (mask[i] & groupbit){ - // x(i,2) = 0; // Enforce2d does not set x[2] to zero either... :/ v(i,2) = 0.0; f(i,2) = 0.0; diff --git a/src/KOKKOS/fix_enforce2d_kokkos.h b/src/KOKKOS/fix_enforce2d_kokkos.h index 1ed3cf3ef8..520a58de04 100644 --- a/src/KOKKOS/fix_enforce2d_kokkos.h +++ b/src/KOKKOS/fix_enforce2d_kokkos.h @@ -32,7 +32,6 @@ class FixEnforce2DKokkos : public FixEnforce2D { public: FixEnforce2DKokkos(class LAMMPS *, int, char **); // ~FixEnforce2DKokkos() {} - // void init(); void setup(int); void post_force(int); @@ -78,18 +77,8 @@ struct FixEnforce2DKokkosPostForceFunctor { /* ERROR/WARNING messages: -E: Illegal ... command +E: Flag in fix_enforce2d_kokkos outside of what it should be -Self-explanatory. Check the input script syntax and compare to the -documentation for the command. You can use -echo screen as a -command-line option when running LAMMPS to see the offending line. - -E: Cannot use fix enforce2d with 3d simulation - -Self-explanatory. - -E: Fix enforce2d must be defined after fix %s - -UNDOCUMENTED +LAMMPS developer-only error. */ From d4f8940ff2367f81b0ae806ec3cd057cc69c6614 Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Fri, 13 Jul 2018 07:40:06 -0600 Subject: [PATCH 13/13] Update command doc page for Kokkos enforce2d --- doc/src/Section_commands.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/Section_commands.txt b/doc/src/Section_commands.txt index 3dabdbeaa1..cc9757a88e 100644 --- a/doc/src/Section_commands.txt +++ b/doc/src/Section_commands.txt @@ -571,7 +571,7 @@ USER-INTEL, k = KOKKOS, o = USER-OMP, t = OPT. "dt/reset"_fix_dt_reset.html, "efield"_fix_efield.html, "ehex"_fix_ehex.html, -"enforce2d"_fix_enforce2d.html, +"enforce2d (k)"_fix_enforce2d.html, "evaporate"_fix_evaporate.html, "external"_fix_external.html, "freeze"_fix_freeze.html,