diff --git a/src/accelerator_omp.h b/src/accelerator_omp.h index 5f224776e2..386fa6269a 100644 --- a/src/accelerator_omp.h +++ b/src/accelerator_omp.h @@ -11,14 +11,17 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ -#ifndef LMP_ACCELERATOR_OMP_H -#define LMP_ACCELERATOR_OMP_H - -// true interface to USER-OMP, used in Neighbor class header file -// used when USER-OMP is installed +// NOTE: this file is *supposed* to be included multiple times #ifdef LMP_USER_OMP +// true interface to USER-OMP + +// this part is used inside the neighbor.h header file to +// add functions to the Neighbor class definition + +#ifdef LMP_INSIDE_NEIGHBOR_H + void half_nsq_no_newton_omp(class NeighList *); void half_nsq_no_newton_ghost_omp(class NeighList *); void half_nsq_newton_omp(class NeighList *); @@ -53,11 +56,37 @@ void respa_bin_newton_omp(class NeighList *); void respa_bin_newton_tri_omp(class NeighList *); -#else +#else /* !LMP_INSIDE_NEIGHBOR_H */ + +// provide a DomainOMP class with some overrides for Domain +#include "domain.h" + +#ifndef LMP_DOMAIN_OMP_H +#define LMP_DOMAIN_OMP_H + +namespace LAMMPS_NS { + +class DomainOMP : public Domain { + public: + DomainOMP(class LAMMPS *lmp) : Domain(lmp) {}; + virtual ~DomainOMP() {}; + + // multi-threaded versions + virtual void pbc(); + virtual void lamda2x(int); + virtual void x2lamda(int); +}; +} + +#endif /* LMP_DOMAIN_OMP_H */ +#endif /* !LMP_INSIDE_NEIGHBOR_H */ + +#else /* !LMP_USER_OMP */ -// dummy interface to USER-OMP // needed for compiling Neighbor class when USER-OMP is not installed +#ifdef LMP_INSIDE_NEIGHBOR_H + void half_nsq_no_newton_omp(class NeighList *) {} void half_nsq_no_newton_ghost_omp(class NeighList *) {} void half_nsq_newton_omp(class NeighList *) {} @@ -91,6 +120,6 @@ void respa_bin_no_newton_omp(class NeighList *) {} void respa_bin_newton_omp(class NeighList *) {} void respa_bin_newton_tri_omp(class NeighList *) {} +#endif -#endif -#endif +#endif /* !LMP_USER_OMP */ diff --git a/src/compute_temp_com.h b/src/compute_temp_com.h index 8a93cbc9f6..762f7988e7 100644 --- a/src/compute_temp_com.h +++ b/src/compute_temp_com.h @@ -43,7 +43,6 @@ class ComputeTempCOM : public Compute { double vbias[3]; // stored velocity bias for one atom void dof_compute(); - }; } diff --git a/src/lammps.cpp b/src/lammps.cpp index a08fd7b820..2ca71079ed 100644 --- a/src/lammps.cpp +++ b/src/lammps.cpp @@ -40,6 +40,7 @@ #include "group.h" #include "output.h" #include "accelerator_cuda.h" +#include "accelerator_omp.h" #include "timer.h" #include "memory.h" #include "error.h" @@ -457,7 +458,11 @@ void LAMMPS::create() else comm = new Comm(this); if (cuda) domain = new DomainCuda(this); +#ifdef LMP_USER_OMP + else domain = new DomainOMP(this); +#else else domain = new Domain(this); +#endif group = new Group(this); force = new Force(this); // must be after group, to create temperature diff --git a/src/neighbor.h b/src/neighbor.h index f32ee519b4..d480fe3217 100644 --- a/src/neighbor.h +++ b/src/neighbor.h @@ -1,4 +1,4 @@ -/* ---------------------------------------------------------------------- +/* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator http://lammps.sandia.gov, Sandia National Laboratories Steve Plimpton, sjplimp@sandia.gov @@ -217,9 +217,12 @@ class Neighbor : protected Pointers { void respa_bin_newton(class NeighList *); void respa_bin_newton_tri(class NeighList *); - // OpenMP multi-threaded neighbor list build versions + // include prototypes for multi-threaded neighbor lists + // builds or their corresponding dummy versions +#define LMP_INSIDE_NEIGHBOR_H #include "accelerator_omp.h" +#undef LMP_INSIDE_NEIGHBOR_H // pairwise stencil creation functions