From 683023d8203f2c34bf7ec8d685bd7ab0f017b4f8 Mon Sep 17 00:00:00 2001 From: Stan Moore <stamoor@sandia.gov> Date: Wed, 8 Mar 2017 12:36:23 -0700 Subject: [PATCH] Adding alloc flag to ev_setup --- src/angle.cpp | 18 +++++++++++------- src/angle.h | 2 +- src/bond.cpp | 18 +++++++++++------- src/bond.h | 2 +- src/dihedral.cpp | 18 +++++++++++------- src/dihedral.h | 2 +- src/improper.cpp | 18 +++++++++++------- src/improper.h | 2 +- src/kspace.cpp | 18 +++++++++++------- src/kspace.h | 2 +- src/pair.cpp | 18 +++++++++++------- src/pair.h | 2 +- 12 files changed, 72 insertions(+), 48 deletions(-) diff --git a/src/angle.cpp b/src/angle.cpp index 14433fc44d..1366c48865 100644 --- a/src/angle.cpp +++ b/src/angle.cpp @@ -76,7 +76,7 @@ void Angle::init() see integrate::ev_set() for values of eflag (0-3) and vflag (0-6) ------------------------------------------------------------------------- */ -void Angle::ev_setup(int eflag, int vflag) +void Angle::ev_setup(int eflag, int vflag, int alloc) { int i,n; @@ -94,25 +94,29 @@ void Angle::ev_setup(int eflag, int vflag) if (eflag_atom && atom->nmax > maxeatom) { maxeatom = atom->nmax; - memory->destroy(eatom); - memory->create(eatom,comm->nthreads*maxeatom,"angle:eatom"); + if (alloc) { + memory->destroy(eatom); + memory->create(eatom,comm->nthreads*maxeatom,"angle:eatom"); + } } if (vflag_atom && atom->nmax > maxvatom) { maxvatom = atom->nmax; - memory->destroy(vatom); - memory->create(vatom,comm->nthreads*maxvatom,6,"angle:vatom"); + if (alloc) { + memory->destroy(vatom); + memory->create(vatom,comm->nthreads*maxvatom,6,"angle:vatom"); + } } // zero accumulators if (eflag_global) energy = 0.0; if (vflag_global) for (i = 0; i < 6; i++) virial[i] = 0.0; - if (eflag_atom) { + if (eflag_atom && alloc) { n = atom->nlocal; if (force->newton_bond) n += atom->nghost; for (i = 0; i < n; i++) eatom[i] = 0.0; } - if (vflag_atom) { + if (vflag_atom && alloc) { n = atom->nlocal; if (force->newton_bond) n += atom->nghost; for (i = 0; i < n; i++) { diff --git a/src/angle.h b/src/angle.h index 8c8129bbbb..000c3fe916 100644 --- a/src/angle.h +++ b/src/angle.h @@ -58,7 +58,7 @@ class Angle : protected Pointers { int vflag_either,vflag_global,vflag_atom; int maxeatom,maxvatom; - void ev_setup(int, int); + void ev_setup(int, int, int alloc = 1); void ev_tally(int, int, int, int, int, double, double *, double *, double, double, double, double, double, double); }; diff --git a/src/bond.cpp b/src/bond.cpp index 8074d97677..5a33f107cf 100644 --- a/src/bond.cpp +++ b/src/bond.cpp @@ -79,7 +79,7 @@ void Bond::init() see integrate::ev_set() for values of eflag (0-3) and vflag (0-6) ------------------------------------------------------------------------- */ -void Bond::ev_setup(int eflag, int vflag) +void Bond::ev_setup(int eflag, int vflag, int alloc) { int i,n; @@ -97,25 +97,29 @@ void Bond::ev_setup(int eflag, int vflag) if (eflag_atom && atom->nmax > maxeatom) { maxeatom = atom->nmax; - memory->destroy(eatom); - memory->create(eatom,comm->nthreads*maxeatom,"bond:eatom"); + if (alloc) { + memory->destroy(eatom); + memory->create(eatom,comm->nthreads*maxeatom,"bond:eatom"); + } } if (vflag_atom && atom->nmax > maxvatom) { maxvatom = atom->nmax; - memory->destroy(vatom); - memory->create(vatom,comm->nthreads*maxvatom,6,"bond:vatom"); + if (alloc) { + memory->destroy(vatom); + memory->create(vatom,comm->nthreads*maxvatom,6,"bond:vatom"); + } } // zero accumulators if (eflag_global) energy = 0.0; if (vflag_global) for (i = 0; i < 6; i++) virial[i] = 0.0; - if (eflag_atom) { + if (eflag_atom && alloc) { n = atom->nlocal; if (force->newton_bond) n += atom->nghost; for (i = 0; i < n; i++) eatom[i] = 0.0; } - if (vflag_atom) { + if (vflag_atom && alloc) { n = atom->nlocal; if (force->newton_bond) n += atom->nghost; for (i = 0; i < n; i++) { diff --git a/src/bond.h b/src/bond.h index ffa1f5fb05..41604387a3 100644 --- a/src/bond.h +++ b/src/bond.h @@ -60,7 +60,7 @@ class Bond : protected Pointers { int vflag_either,vflag_global,vflag_atom; int maxeatom,maxvatom; - void ev_setup(int, int); + void ev_setup(int, int, int alloc = 1); void ev_tally(int, int, int, int, double, double, double, double, double); }; diff --git a/src/dihedral.cpp b/src/dihedral.cpp index 4c941d7225..f5c1c6c44c 100644 --- a/src/dihedral.cpp +++ b/src/dihedral.cpp @@ -76,7 +76,7 @@ void Dihedral::init() see integrate::ev_set() for values of eflag (0-3) and vflag (0-6) ------------------------------------------------------------------------- */ -void Dihedral::ev_setup(int eflag, int vflag) +void Dihedral::ev_setup(int eflag, int vflag, int alloc) { int i,n; @@ -94,25 +94,29 @@ void Dihedral::ev_setup(int eflag, int vflag) if (eflag_atom && atom->nmax > maxeatom) { maxeatom = atom->nmax; - memory->destroy(eatom); - memory->create(eatom,comm->nthreads*maxeatom,"dihedral:eatom"); + if (alloc) { + memory->destroy(eatom); + memory->create(eatom,comm->nthreads*maxeatom,"dihedral:eatom"); + } } if (vflag_atom && atom->nmax > maxvatom) { maxvatom = atom->nmax; - memory->destroy(vatom); - memory->create(vatom,comm->nthreads*maxvatom,6,"dihedral:vatom"); + if (alloc) { + memory->destroy(vatom); + memory->create(vatom,comm->nthreads*maxvatom,6,"dihedral:vatom"); + } } // zero accumulators if (eflag_global) energy = 0.0; if (vflag_global) for (i = 0; i < 6; i++) virial[i] = 0.0; - if (eflag_atom) { + if (eflag_atom && alloc) { n = atom->nlocal; if (force->newton_bond) n += atom->nghost; for (i = 0; i < n; i++) eatom[i] = 0.0; } - if (vflag_atom) { + if (vflag_atom && alloc) { n = atom->nlocal; if (force->newton_bond) n += atom->nghost; for (i = 0; i < n; i++) { diff --git a/src/dihedral.h b/src/dihedral.h index 5f3909244f..d27810c4d6 100644 --- a/src/dihedral.h +++ b/src/dihedral.h @@ -56,7 +56,7 @@ class Dihedral : protected Pointers { int vflag_either,vflag_global,vflag_atom; int maxeatom,maxvatom; - void ev_setup(int, int); + void ev_setup(int, int, int alloc = 1); void ev_tally(int, int, int, int, int, int, double, double *, double *, double *, double, double, double, double, double, double, double, double, double); diff --git a/src/improper.cpp b/src/improper.cpp index e20d0d2666..089fc43aad 100644 --- a/src/improper.cpp +++ b/src/improper.cpp @@ -74,7 +74,7 @@ void Improper::init() see integrate::ev_set() for values of eflag (0-3) and vflag (0-6) ------------------------------------------------------------------------- */ -void Improper::ev_setup(int eflag, int vflag) +void Improper::ev_setup(int eflag, int vflag, int alloc) { int i,n; @@ -92,25 +92,29 @@ void Improper::ev_setup(int eflag, int vflag) if (eflag_atom && atom->nmax > maxeatom) { maxeatom = atom->nmax; - memory->destroy(eatom); - memory->create(eatom,comm->nthreads*maxeatom,"improper:eatom"); + if (alloc) { + memory->destroy(eatom); + memory->create(eatom,comm->nthreads*maxeatom,"improper:eatom"); + } } if (vflag_atom && atom->nmax > maxvatom) { maxvatom = atom->nmax; - memory->destroy(vatom); - memory->create(vatom,comm->nthreads*maxvatom,6,"improper:vatom"); + if (alloc) { + memory->destroy(vatom); + memory->create(vatom,comm->nthreads*maxvatom,6,"improper:vatom"); + } } // zero accumulators if (eflag_global) energy = 0.0; if (vflag_global) for (i = 0; i < 6; i++) virial[i] = 0.0; - if (eflag_atom) { + if (eflag_atom && alloc) { n = atom->nlocal; if (force->newton_bond) n += atom->nghost; for (i = 0; i < n; i++) eatom[i] = 0.0; } - if (vflag_atom) { + if (vflag_atom && alloc) { n = atom->nlocal; if (force->newton_bond) n += atom->nghost; for (i = 0; i < n; i++) { diff --git a/src/improper.h b/src/improper.h index be78b6acf9..df3c966cdc 100644 --- a/src/improper.h +++ b/src/improper.h @@ -56,7 +56,7 @@ class Improper : protected Pointers { int vflag_either,vflag_global,vflag_atom; int maxeatom,maxvatom; - void ev_setup(int, int); + void ev_setup(int, int, int alloc = 1); void ev_tally(int, int, int, int, int, int, double, double *, double *, double *, double, double, double, double, double, double, double, double, double); diff --git a/src/kspace.cpp b/src/kspace.cpp index 48626346b1..c2113cdf76 100644 --- a/src/kspace.cpp +++ b/src/kspace.cpp @@ -206,7 +206,7 @@ void KSpace::pair_check() see integrate::ev_set() for values of eflag (0-3) and vflag (0-6) ------------------------------------------------------------------------- */ -void KSpace::ev_setup(int eflag, int vflag) +void KSpace::ev_setup(int eflag, int vflag, int alloc) { int i,n; @@ -227,25 +227,29 @@ void KSpace::ev_setup(int eflag, int vflag) if (eflag_atom && atom->nmax > maxeatom) { maxeatom = atom->nmax; - memory->destroy(eatom); - memory->create(eatom,maxeatom,"kspace:eatom"); + if (alloc) { + memory->destroy(eatom); + memory->create(eatom,maxeatom,"kspace:eatom"); + } } if (vflag_atom && atom->nmax > maxvatom) { maxvatom = atom->nmax; - memory->destroy(vatom); - memory->create(vatom,maxvatom,6,"kspace:vatom"); + if (alloc) { + memory->destroy(vatom); + memory->create(vatom,maxvatom,6,"kspace:vatom"); + } } // zero accumulators if (eflag_global) energy = 0.0; if (vflag_global) for (i = 0; i < 6; i++) virial[i] = 0.0; - if (eflag_atom) { + if (eflag_atom && alloc) { n = atom->nlocal; if (tip4pflag) n += atom->nghost; for (i = 0; i < n; i++) eatom[i] = 0.0; } - if (vflag_atom) { + if (vflag_atom && alloc) { n = atom->nlocal; if (tip4pflag) n += atom->nghost; for (i = 0; i < n; i++) { diff --git a/src/kspace.h b/src/kspace.h index c81854e90a..ad29c21472 100644 --- a/src/kspace.h +++ b/src/kspace.h @@ -197,7 +197,7 @@ class KSpace : protected Pointers { int kx_ewald,ky_ewald,kz_ewald; // kspace settings for Ewald sum void pair_check(); - void ev_setup(int, int); + void ev_setup(int, int, int alloc = 1); double estimate_table_accuracy(double, double); }; diff --git a/src/pair.cpp b/src/pair.cpp index 685280cfce..d90ed8bb43 100644 --- a/src/pair.cpp +++ b/src/pair.cpp @@ -749,7 +749,7 @@ void Pair::del_tally_callback(Compute *ptr) see integrate::ev_set() for values of eflag (0-3) and vflag (0-6) ------------------------------------------------------------------------- */ -void Pair::ev_setup(int eflag, int vflag) +void Pair::ev_setup(int eflag, int vflag, int alloc) { int i,n; @@ -767,13 +767,17 @@ void Pair::ev_setup(int eflag, int vflag) if (eflag_atom && atom->nmax > maxeatom) { maxeatom = atom->nmax; - memory->destroy(eatom); - memory->create(eatom,comm->nthreads*maxeatom,"pair:eatom"); + if (alloc) { + memory->destroy(eatom); + memory->create(eatom,comm->nthreads*maxeatom,"pair:eatom"); + } } if (vflag_atom && atom->nmax > maxvatom) { maxvatom = atom->nmax; - memory->destroy(vatom); - memory->create(vatom,comm->nthreads*maxvatom,6,"pair:vatom"); + if (alloc) { + memory->destroy(vatom); + memory->create(vatom,comm->nthreads*maxvatom,6,"pair:vatom"); + } } // zero accumulators @@ -782,12 +786,12 @@ void Pair::ev_setup(int eflag, int vflag) if (eflag_global) eng_vdwl = eng_coul = 0.0; if (vflag_global) for (i = 0; i < 6; i++) virial[i] = 0.0; - if (eflag_atom) { + if (eflag_atom && alloc) { n = atom->nlocal; if (force->newton) n += atom->nghost; for (i = 0; i < n; i++) eatom[i] = 0.0; } - if (vflag_atom) { + if (vflag_atom && alloc) { n = atom->nlocal; if (force->newton) n += atom->nghost; for (i = 0; i < n; i++) { diff --git a/src/pair.h b/src/pair.h index 16746a29a8..3f66c6095a 100644 --- a/src/pair.h +++ b/src/pair.h @@ -221,7 +221,7 @@ class Pair : protected Pointers { int copymode; // if set, do not deallocate during destruction // required when classes are used as functors by Kokkos - virtual void ev_setup(int, int); + virtual void ev_setup(int, int, int alloc = 1); void ev_unset(); void ev_tally_full(int, double, double, double, double, double, double); void ev_tally_xyz_full(int, double, double, -- GitLab