From 704207f3c8dcac356301368de9d9c469d48b6d2f Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Thu, 27 Feb 2020 08:51:02 -0700 Subject: [PATCH] Finalize Kokkos on error exit --- src/accelerator_kokkos.h | 5 +++++ src/error.cpp | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/src/accelerator_kokkos.h b/src/accelerator_kokkos.h index a3fff2fe16..9fb9cf3690 100644 --- a/src/accelerator_kokkos.h +++ b/src/accelerator_kokkos.h @@ -61,6 +61,11 @@ class KokkosLMP { int neigh_count(int) {return 0;} }; +class Kokkos { + public: + static void finalize() {} +}; + class AtomKokkos : public Atom { public: tagint **k_special; diff --git a/src/error.cpp b/src/error.cpp index e5e9179fda..0883387f4d 100644 --- a/src/error.cpp +++ b/src/error.cpp @@ -18,6 +18,7 @@ #include "universe.h" #include "output.h" #include "input.h" +#include "accelerator_kokkos.h" #if defined(LAMMPS_EXCEPTIONS) #include "update.h" @@ -83,6 +84,7 @@ void Error::universe_all(const char *file, int line, const char *str) snprintf(msg, 100, "ERROR: %s (%s:%d)\n", str, truncpath(file), line); throw LAMMPSException(msg); #else + if (lmp->kokkos) Kokkos::finalize(); MPI_Finalize(); exit(1); #endif @@ -173,6 +175,7 @@ void Error::all(const char *file, int line, const char *str) if (logfile) fclose(logfile); if (universe->nworlds > 1) MPI_Abort(universe->uworld,1); + if (lmp->kokkos) Kokkos::finalize(); MPI_Finalize(); exit(1); #endif @@ -259,6 +262,7 @@ void Error::done(int status) if (screen && screen != stdout) fclose(screen); if (logfile) fclose(logfile); + if (lmp->kokkos) Kokkos::finalize(); MPI_Finalize(); exit(status); }