Fix issue with Kokkos::finalize and library interface
This commit is contained in:
@ -291,9 +291,7 @@ KokkosLMP::KokkosLMP(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp)
|
||||
|
||||
KokkosLMP::~KokkosLMP()
|
||||
{
|
||||
// finalize Kokkos
|
||||
|
||||
Kokkos::finalize();
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
|
||||
@ -123,5 +123,10 @@ class DAT {
|
||||
|
||||
}
|
||||
|
||||
namespace Kokkos {
|
||||
static int is_initialized() {return false;}
|
||||
static void finalize() {}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -75,7 +75,7 @@ void Error::universe_all(const std::string &file, int line, const std::string &s
|
||||
|
||||
throw LAMMPSException(mesg);
|
||||
#else
|
||||
if (lmp->kokkos) Kokkos::finalize();
|
||||
if (Kokkos::is_initialized()) Kokkos::finalize();
|
||||
MPI_Finalize();
|
||||
exit(1);
|
||||
#endif
|
||||
@ -161,7 +161,7 @@ void Error::all(const std::string &file, int line, const std::string &str)
|
||||
if (logfile) fclose(logfile);
|
||||
|
||||
if (universe->nworlds > 1) MPI_Abort(universe->uworld,1);
|
||||
if (lmp->kokkos) Kokkos::finalize();
|
||||
if (Kokkos::is_initialized()) Kokkos::finalize();
|
||||
MPI_Finalize();
|
||||
exit(1);
|
||||
#endif
|
||||
@ -200,6 +200,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();
|
||||
MPI_Abort(world,1);
|
||||
exit(1); // to trick "smart" compilers into believing this does not return
|
||||
#endif
|
||||
@ -246,7 +247,7 @@ void Error::done(int status)
|
||||
if (screen && screen != stdout) fclose(screen);
|
||||
if (logfile) fclose(logfile);
|
||||
|
||||
if (lmp->kokkos) Kokkos::finalize();
|
||||
if (Kokkos::is_initialized()) Kokkos::finalize();
|
||||
MPI_Finalize();
|
||||
exit(status);
|
||||
}
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
#include "library.h"
|
||||
#include <mpi.h>
|
||||
|
||||
#include "accelerator_kokkos.h"
|
||||
#include "atom.h"
|
||||
#include "atom_vec.h"
|
||||
#include "comm.h"
|
||||
@ -348,6 +349,11 @@ void lammps_mpi_finalize()
|
||||
}
|
||||
}
|
||||
|
||||
void lammps_kokkos_finalize()
|
||||
{
|
||||
if (Kokkos::is_initialized()) Kokkos::finalize();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Library functions to process commands
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
@ -96,6 +96,7 @@ void lammps_close(void *handle);
|
||||
|
||||
void lammps_mpi_init();
|
||||
void lammps_mpi_finalize();
|
||||
void lammps_kokkos_finalize();
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
* Library functions to process commands
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
|
||||
#include "lammps.h"
|
||||
#include "input.h"
|
||||
#include "accelerator_kokkos.h"
|
||||
|
||||
#include <mpi.h>
|
||||
#include <cstdlib>
|
||||
@ -53,8 +54,10 @@ int main(int argc, char **argv)
|
||||
lammps->input->file();
|
||||
delete lammps;
|
||||
} catch(LAMMPSAbortException &ae) {
|
||||
if (Kokkos::is_initialized()) Kokkos::finalize();
|
||||
MPI_Abort(ae.universe, 1);
|
||||
} catch(LAMMPSException &e) {
|
||||
if (Kokkos::is_initialized()) Kokkos::finalize();
|
||||
MPI_Barrier(MPI_COMM_WORLD);
|
||||
MPI_Finalize();
|
||||
exit(1);
|
||||
@ -64,6 +67,7 @@ int main(int argc, char **argv)
|
||||
lammps->input->file();
|
||||
delete lammps;
|
||||
#endif
|
||||
if (Kokkos::is_initialized()) Kokkos::finalize();
|
||||
MPI_Barrier(MPI_COMM_WORLD);
|
||||
MPI_Finalize();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user