Make Kokkos init/finalize calls safer

This commit is contained in:
Stan Gerald Moore
2021-06-24 13:25:35 -06:00
parent ddac9c21dc
commit 2d5e8f050a
6 changed files with 39 additions and 15 deletions

View File

@ -81,7 +81,7 @@ void Error::universe_all(const std::string &file, int line, const std::string &s
throw LAMMPSException(mesg);
#else
if (Kokkos::is_initialized()) Kokkos::finalize();
KokkosLMP::finalize();
MPI_Finalize();
exit(1);
#endif
@ -107,6 +107,7 @@ void Error::universe_one(const std::string &file, int line, const std::string &s
throw LAMMPSAbortException(mesg, universe->uworld);
#else
KokkosLMP::finalize();
MPI_Abort(universe->uworld,1);
exit(1); // to trick "smart" compilers into believing this does not return
#endif
@ -173,8 +174,8 @@ void Error::all(const std::string &file, int line, const std::string &str)
if (screen && screen != stdout) fclose(screen);
if (logfile) fclose(logfile);
KokkosLMP::finalize();
if (universe->nworlds > 1) MPI_Abort(universe->uworld,1);
if (Kokkos::is_initialized()) Kokkos::finalize();
MPI_Finalize();
exit(1);
#endif
@ -213,7 +214,7 @@ void Error::one(const std::string &file, int line, const std::string &str)
#else
if (screen) fflush(screen);
if (logfile) fflush(logfile);
if (Kokkos::is_initialized()) Kokkos::finalize();
KokkosLMP::finalize();
MPI_Abort(world,1);
exit(1); // to trick "smart" compilers into believing this does not return
#endif
@ -316,7 +317,7 @@ void Error::done(int status)
if (screen && screen != stdout) fclose(screen);
if (logfile) fclose(logfile);
if (Kokkos::is_initialized()) Kokkos::finalize();
KokkosLMP::finalize();
MPI_Finalize();
exit(status);
}