From a223338b47d2495e81fa4ec187faf80d6f703f48 Mon Sep 17 00:00:00 2001
From: Stan Moore <stamoor@sandia.gov>
Date: Thu, 11 Oct 2018 16:32:00 -0600
Subject: [PATCH] Fix hang with Kokkos and USER-DPD examples

---
 src/KOKKOS/atom_vec_dpd_kokkos.cpp    | 4 +++-
 src/KOKKOS/atom_vec_hybrid_kokkos.cpp | 5 ++++-
 src/KOKKOS/atom_vec_kokkos.cpp        | 3 +++
 src/KOKKOS/atom_vec_kokkos.h          | 2 ++
 src/KOKKOS/atom_vec_sphere_kokkos.cpp | 2 ++
 src/KOKKOS/comm_kokkos.cpp            | 6 +++++-
 6 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/src/KOKKOS/atom_vec_dpd_kokkos.cpp b/src/KOKKOS/atom_vec_dpd_kokkos.cpp
index 24b23c6ccf..217929b332 100644
--- a/src/KOKKOS/atom_vec_dpd_kokkos.cpp
+++ b/src/KOKKOS/atom_vec_dpd_kokkos.cpp
@@ -37,7 +37,7 @@ AtomVecDPDKokkos::AtomVecDPDKokkos(LAMMPS *lmp) : AtomVecKokkos(lmp)
   size_forward = 7;
   size_reverse = 3;
   size_border = 12;
-  size_velocity = 3;
+  size_velocity = 10;
   size_data_atom = 6;
   size_data_vel = 4;
   xcol_data = 4;
@@ -48,6 +48,8 @@ AtomVecDPDKokkos::AtomVecDPDKokkos(LAMMPS *lmp) : AtomVecKokkos(lmp)
   k_count = DAT::tdual_int_1d("atom::k_count",1);
   atomKK = (AtomKokkos *) atom;
   commKK = (CommKokkos *) comm;
+
+  no_comm_vel_flag = 1;
 }
 
 /* ----------------------------------------------------------------------
diff --git a/src/KOKKOS/atom_vec_hybrid_kokkos.cpp b/src/KOKKOS/atom_vec_hybrid_kokkos.cpp
index 7e1cc200d3..ce36f59053 100644
--- a/src/KOKKOS/atom_vec_hybrid_kokkos.cpp
+++ b/src/KOKKOS/atom_vec_hybrid_kokkos.cpp
@@ -26,7 +26,10 @@ using namespace LAMMPS_NS;
 
 /* ---------------------------------------------------------------------- */
 
-AtomVecHybridKokkos::AtomVecHybridKokkos(LAMMPS *lmp) : AtomVecKokkos(lmp) {}
+AtomVecHybridKokkos::AtomVecHybridKokkos(LAMMPS *lmp) : AtomVecKokkos(lmp) {
+  no_comm_vel_flag = 1;
+  no_border_vel_flag = 1;
+}
 
 /* ---------------------------------------------------------------------- */
 
diff --git a/src/KOKKOS/atom_vec_kokkos.cpp b/src/KOKKOS/atom_vec_kokkos.cpp
index 555bb2e747..83af437eba 100644
--- a/src/KOKKOS/atom_vec_kokkos.cpp
+++ b/src/KOKKOS/atom_vec_kokkos.cpp
@@ -26,6 +26,9 @@ AtomVecKokkos::AtomVecKokkos(LAMMPS *lmp) : AtomVec(lmp)
   kokkosable = 1;
   buffer = NULL;
   buffer_size = 0;
+
+  no_comm_vel_flag = 0;
+  no_border_vel_flag = 1;
 }
 
 /* ---------------------------------------------------------------------- */
diff --git a/src/KOKKOS/atom_vec_kokkos.h b/src/KOKKOS/atom_vec_kokkos.h
index e1d626ac1b..efe55c47ad 100644
--- a/src/KOKKOS/atom_vec_kokkos.h
+++ b/src/KOKKOS/atom_vec_kokkos.h
@@ -113,6 +113,8 @@ class AtomVecKokkos : public AtomVec {
                            ExecutionSpace space) = 0;
 
 
+  int no_comm_vel_flag,no_border_vel_flag;
+
  protected:
 
   HAT::t_x_array h_x;
diff --git a/src/KOKKOS/atom_vec_sphere_kokkos.cpp b/src/KOKKOS/atom_vec_sphere_kokkos.cpp
index 476091ff41..3dfbc5efdc 100644
--- a/src/KOKKOS/atom_vec_sphere_kokkos.cpp
+++ b/src/KOKKOS/atom_vec_sphere_kokkos.cpp
@@ -57,6 +57,8 @@ AtomVecSphereKokkos::AtomVecSphereKokkos(LAMMPS *lmp) : AtomVecKokkos(lmp)
   k_count = DAT::tdual_int_1d("atom::k_count",1);
   atomKK = (AtomKokkos *) atom;
   commKK = (CommKokkos *) comm;
+
+  no_border_vel_flag = 0;
 }
 
 /* ---------------------------------------------------------------------- */
diff --git a/src/KOKKOS/comm_kokkos.cpp b/src/KOKKOS/comm_kokkos.cpp
index a9a26c0a3c..f40156aabc 100644
--- a/src/KOKKOS/comm_kokkos.cpp
+++ b/src/KOKKOS/comm_kokkos.cpp
@@ -136,6 +136,9 @@ void CommKokkos::init()
 
   if (!comm_f_only) // not all Kokkos atom_vec styles have reverse pack/unpack routines yet
     reverse_comm_classic = true;
+
+  if (ghost_velocity && ((AtomVecKokkos*)atom->avec)->no_comm_vel_flag) // not all Kokkos atom_vec styles have comm vel pack/unpack routines yet
+    forward_comm_classic = true;
 }
 
 /* ----------------------------------------------------------------------
@@ -725,7 +728,8 @@ void CommKokkos::borders()
   if (!exchange_comm_classic) {
     static int print = 1;
 
-    if (mode != Comm::SINGLE || bordergroup) {
+    if (mode != Comm::SINGLE || bordergroup ||
+         (ghost_velocity && ((AtomVecKokkos*)atom->avec)->no_border_vel_flag)) {
       if (print && comm->me==0) {
         error->warning(FLERR,"Required border comm not yet implemented in Kokkos communication, "
                       "switching to classic communication");
-- 
GitLab