From c5c293d16f4d4001fccd8d688d1d6423a2f2eba5 Mon Sep 17 00:00:00 2001 From: stamoor <stamoor@f3b2605a-c512-4ea7-a41b-209d697bcdaa> Date: Mon, 2 May 2016 23:01:37 +0000 Subject: [PATCH] Adding signal handler to Kokkos package git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@14920 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/KOKKOS/Install.sh | 4 +++ src/KOKKOS/kokkos.cpp | 12 ++++++++ src/KOKKOS/kokkos.h | 2 ++ src/KOKKOS/kokkos_type.h | 60 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 78 insertions(+) diff --git a/src/KOKKOS/Install.sh b/src/KOKKOS/Install.sh index af77bcd206..69620daa94 100644 --- a/src/KOKKOS/Install.sh +++ b/src/KOKKOS/Install.sh @@ -77,6 +77,8 @@ action fix_nve_kokkos.cpp action fix_nve_kokkos.h action fix_nvt_kokkos.cpp action fix_nvt_kokkos.h +action fix_qeq_reax_kokkos.cpp fix_qeq_reax.cpp +action fix_qeq_reax_kokkos.h fix_qeq_reax.h action fix_setforce_kokkos.cpp action fix_setforce_kokkos.h action fix_wall_reflect_kokkos.cpp @@ -149,6 +151,8 @@ action pair_lj_gromacs_kokkos.cpp action pair_lj_gromacs_kokkos.h action pair_lj_sdk_kokkos.cpp pair_lj_sdk.cpp action pair_lj_sdk_kokkos.h pair_lj_sdk.h +action pair_reax_kokkos.cpp pair_reax.cpp +action pair_reax_kokkos.h pair_reax.h action pair_sw_kokkos.cpp pair_sw.cpp action pair_sw_kokkos.h pair_sw.h action pair_table_kokkos.cpp diff --git a/src/KOKKOS/kokkos.cpp b/src/KOKKOS/kokkos.cpp index 27400cd84a..7b27ba3523 100644 --- a/src/KOKKOS/kokkos.cpp +++ b/src/KOKKOS/kokkos.cpp @@ -15,6 +15,8 @@ #include <string.h> #include <stdlib.h> #include <ctype.h> +#include <signal.h> +#include <unistd.h> #include "kokkos.h" #include "lammps.h" #include "force.h" @@ -119,6 +121,10 @@ KokkosLMP::KokkosLMP(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp) forward_comm_classic = 0; exchange_comm_on_host = 0; forward_comm_on_host = 0; + +#ifdef KILL_KOKKOS_ON_SIGSEGV + signal(SIGSEGV, my_signal_handler); +#endif } /* ---------------------------------------------------------------------- */ @@ -275,3 +281,9 @@ int KokkosLMP::neigh_count(int m) return nneigh; } +void KokkosLMP::my_signal_handler(int sig) +{ + if (sig == SIGSEGV) { + kill(getpid(),SIGABRT); + } +} \ No newline at end of file diff --git a/src/KOKKOS/kokkos.h b/src/KOKKOS/kokkos.h index c03d2ff43f..f6d3404283 100644 --- a/src/KOKKOS/kokkos.h +++ b/src/KOKKOS/kokkos.h @@ -35,6 +35,8 @@ class KokkosLMP : protected Pointers { void accelerator(int, char **); int neigh_list_kokkos(int); int neigh_count(int); + private: + static void my_signal_handler(int); }; } diff --git a/src/KOKKOS/kokkos_type.h b/src/KOKKOS/kokkos_type.h index 6d8e822634..dc52096d5a 100644 --- a/src/KOKKOS/kokkos_type.h +++ b/src/KOKKOS/kokkos_type.h @@ -209,6 +209,66 @@ struct s_EV_FLOAT { }; typedef struct s_EV_FLOAT EV_FLOAT; +struct s_EV_FLOAT_REAX { + E_FLOAT evdwl; + E_FLOAT ecoul; + E_FLOAT v[6]; + E_FLOAT ereax[10]; + KOKKOS_INLINE_FUNCTION + s_EV_FLOAT_REAX() { + evdwl = 0; + ecoul = 0; + v[0] = 0; v[1] = 0; v[2] = 0; + v[3] = 0; v[4] = 0; v[5] = 0; + ereax[0] = 0; ereax[1] = 0; ereax[2] = 0; + ereax[3] = 0; ereax[4] = 0; ereax[5] = 0; + ereax[6] = 0; ereax[7] = 0; ereax[8] = 0; + } + + KOKKOS_INLINE_FUNCTION + void operator+=(const s_EV_FLOAT_REAX &rhs) { + evdwl += rhs.evdwl; + ecoul += rhs.ecoul; + v[0] += rhs.v[0]; + v[1] += rhs.v[1]; + v[2] += rhs.v[2]; + v[3] += rhs.v[3]; + v[4] += rhs.v[4]; + v[5] += rhs.v[5]; + ereax[0] += rhs.ereax[0]; + ereax[1] += rhs.ereax[1]; + ereax[2] += rhs.ereax[2]; + ereax[3] += rhs.ereax[3]; + ereax[4] += rhs.ereax[4]; + ereax[5] += rhs.ereax[5]; + ereax[6] += rhs.ereax[6]; + ereax[7] += rhs.ereax[7]; + ereax[8] += rhs.ereax[8]; + } + + KOKKOS_INLINE_FUNCTION + void operator+=(const volatile s_EV_FLOAT_REAX &rhs) volatile { + evdwl += rhs.evdwl; + ecoul += rhs.ecoul; + v[0] += rhs.v[0]; + v[1] += rhs.v[1]; + v[2] += rhs.v[2]; + v[3] += rhs.v[3]; + v[4] += rhs.v[4]; + v[5] += rhs.v[5]; + ereax[0] += rhs.ereax[0]; + ereax[1] += rhs.ereax[1]; + ereax[2] += rhs.ereax[2]; + ereax[3] += rhs.ereax[3]; + ereax[4] += rhs.ereax[4]; + ereax[5] += rhs.ereax[5]; + ereax[6] += rhs.ereax[6]; + ereax[7] += rhs.ereax[7]; + ereax[8] += rhs.ereax[8]; + } +}; +typedef struct s_EV_FLOAT_REAX EV_FLOAT_REAX; + #ifndef PREC_POS #define PREC_POS PRECISION #endif -- GitLab