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