git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@14025 f3b2605a-c512-4ea7-a41b-209d697bcdaa

This commit is contained in:
sjplimp
2015-09-11 14:49:37 +00:00
parent b1090f8689
commit 9effcca0df
8 changed files with 49 additions and 24 deletions

View File

@ -35,6 +35,7 @@ PairDPDOMP::PairDPDOMP(LAMMPS *lmp) :
suffix_flag |= Suffix::OMP;
respa_enable = 0;
random_thr = NULL;
nthreads = 0;
}
/* ---------------------------------------------------------------------- */
@ -42,7 +43,7 @@ PairDPDOMP::PairDPDOMP(LAMMPS *lmp) :
PairDPDOMP::~PairDPDOMP()
{
if (random_thr) {
for (int i=1; i < comm->nthreads; ++i)
for (int i=1; i < nthreads; ++i)
delete random_thr[i];
delete[] random_thr;
@ -59,16 +60,26 @@ void PairDPDOMP::compute(int eflag, int vflag)
} else evflag = vflag_fdotr = 0;
const int nall = atom->nlocal + atom->nghost;
const int nthreads = comm->nthreads;
const int inum = list->inum;
if (!random_thr)
// number of threads has changed. reallocate pool of pRNGs
if (nthreads != comm->nthreads) {
if (random_thr) {
for (int i=1; i < nthreads; ++i)
delete random_thr[i];
delete[] random_thr;
}
nthreads = comm->nthreads;
random_thr = new RanMars*[nthreads];
for (int i=1; i < nthreads; ++i)
random_thr[i] = NULL;
// to ensure full compatibility with the serial DPD style
// we use is random number generator instance for thread 0
random_thr[0] = random;
// to ensure full compatibility with the serial DPD style
// we use the serial random number generator instance for thread 0
random_thr[0] = random;
}
#if defined(_OPENMP)
#pragma omp parallel default(none) shared(eflag,vflag)
#endif
@ -82,7 +93,7 @@ void PairDPDOMP::compute(int eflag, int vflag)
// generate a random number generator instance for
// all threads != 0. make sure we use unique seeds.
if (random_thr && tid > 0)
if (random_thr && (tid > 0) && (random_thr[tid] == NULL))
random_thr[tid] = new RanMars(Pair::lmp, seed + comm->me
+ comm->nprocs*tid);

View File

@ -40,6 +40,7 @@ class PairDPDOMP : public PairDPD, public ThrOMP {
protected:
class RanMars **random_thr;
int nthreads;
private:
template <int EVFLAG, int EFLAG, int NEWTON_PAIR>

View File

@ -35,6 +35,7 @@ PairDPDTstatOMP::PairDPDTstatOMP(LAMMPS *lmp) :
suffix_flag |= Suffix::OMP;
respa_enable = 0;
random_thr = NULL;
nthreads = 0;
}
/* ---------------------------------------------------------------------- */
@ -42,7 +43,7 @@ PairDPDTstatOMP::PairDPDTstatOMP(LAMMPS *lmp) :
PairDPDTstatOMP::~PairDPDTstatOMP()
{
if (random_thr) {
for (int i=1; i < comm->nthreads; ++i)
for (int i=1; i < nthreads; ++i)
delete random_thr[i];
delete[] random_thr;
@ -59,16 +60,26 @@ void PairDPDTstatOMP::compute(int eflag, int vflag)
} else evflag = vflag_fdotr = 0;
const int nall = atom->nlocal + atom->nghost;
const int nthreads = comm->nthreads;
const int inum = list->inum;
if (!random_thr)
// number of threads has changed. reallocate pool of pRNGs
if (nthreads != comm->nthreads) {
if (random_thr) {
for (int i=1; i < nthreads; ++i)
delete random_thr[i];
delete[] random_thr;
}
nthreads = comm->nthreads;
random_thr = new RanMars*[nthreads];
for (int i=1; i < nthreads; ++i)
random_thr[i] = NULL;
// to ensure full compatibility with the serial DPD style
// we use is random number generator instance for thread 0
random_thr[0] = random;
// to ensure full compatibility with the serial DPD style
// we use the serial random number generator instance for thread 0
random_thr[0] = random;
}
#if defined(_OPENMP)
#pragma omp parallel default(none) shared(eflag,vflag)
#endif
@ -82,7 +93,7 @@ void PairDPDTstatOMP::compute(int eflag, int vflag)
// generate a random number generator instance for
// all threads != 0. make sure we use unique seeds.
if (random_thr && tid > 0)
if (random_thr && (tid > 0) && (random_thr[tid] == NULL))
random_thr[tid] = new RanMars(Pair::lmp, seed + comm->me
+ comm->nprocs*tid);

View File

@ -40,6 +40,7 @@ class PairDPDTstatOMP : public PairDPDTstat, public ThrOMP {
protected:
class RanMars **random_thr;
int nthreads;
private:
template <int EVFLAG, int EFLAG, int NEWTON_PAIR>

View File

@ -154,7 +154,7 @@ void Error::message(const char *file, int line, const char *str, int logflag)
no abort, so insure all procs in world call, else will hang
------------------------------------------------------------------------- */
void Error::done()
void Error::done(int status)
{
MPI_Barrier(world);
@ -163,5 +163,5 @@ void Error::done()
if (logfile) fclose(logfile);
MPI_Finalize();
exit(1);
exit(status);
}

View File

@ -30,7 +30,7 @@ class Error : protected Pointers {
void one(const char *, int, const char *);
void warning(const char *, int, const char *, int = 1);
void message(const char *, int, const char *, int = 1);
void done();
void done(int = 0); // 1 would be fully backwards compatible
};
}

View File

@ -1079,8 +1079,9 @@ void Input::python()
void Input::quit()
{
if (narg) error->all(FLERR,"Illegal quit command");
error->done();
if (narg == 0) error->done(0); // 1 would be fully backwards compatible
if (narg == 1) error->done(force->inumeric(FLERR,arg[0]));
error->all(FLERR,"Illegal quit command");
}
/* ---------------------------------------------------------------------- */

View File

@ -507,11 +507,11 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator)
memory->destroy(pfirst);
memory->destroy(plast);
// if helpflag set, print help and quit
// if helpflag set, print help and quit with "success" status
if (helpflag) {
if (universe->me == 0 && screen) help();
error->done();
error->done(0);
}
// if restartflag set, invoke 2 commands and quit
@ -528,7 +528,7 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator)
sprintf(&cmd[strlen(cmd)]," %s",arg[iarg]);
strcat(cmd," noinit\n");
input->one(cmd);
error->done();
error->done(0);
}
}