From 09c391fb2dbe670f1250d22edc3fed0169857be2 Mon Sep 17 00:00:00 2001 From: sjplimp Date: Wed, 16 Mar 2011 20:03:49 +0000 Subject: [PATCH] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@5793 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/ASPHERE/atom_vec_ellipsoid.cpp | 26 ++++---- src/ASPHERE/atom_vec_ellipsoid.h | 2 +- src/COLLOID/atom_vec_colloid.cpp | 24 +++---- src/COLLOID/atom_vec_colloid.h | 2 +- src/DIPOLE/atom_vec_dipole.cpp | 26 ++++---- src/DIPOLE/atom_vec_dipole.h | 2 +- src/GRANULAR/atom_vec_granular.cpp | 28 ++++---- src/GRANULAR/atom_vec_granular.h | 2 +- src/KSPACE/pppm.h | 1 - src/MANYBODY/fix_qeq_comb.h | 1 - src/MOLECULE/atom_vec_angle.cpp | 54 ++++++++-------- src/MOLECULE/atom_vec_angle.h | 2 +- src/MOLECULE/atom_vec_bond.cpp | 35 +++++----- src/MOLECULE/atom_vec_bond.h | 2 +- src/MOLECULE/atom_vec_full.cpp | 99 +++++++++++++++-------------- src/MOLECULE/atom_vec_full.h | 2 +- src/MOLECULE/atom_vec_molecular.cpp | 97 ++++++++++++++-------------- src/MOLECULE/atom_vec_molecular.h | 2 +- src/PERI/atom_vec_peri.cpp | 32 +++++----- src/PERI/atom_vec_peri.h | 2 +- src/REAX/fix_reax_bonds.h | 1 - src/REPLICA/fix_event_prd.h | 1 - src/REPLICA/fix_event_tad.h | 1 - src/SRD/fix_wall_srd.h | 1 - src/XTC/dump_xtc.cpp | 7 +- src/XTC/dump_xtc.h | 2 +- src/atom.cpp | 12 ++-- src/atom.h | 3 +- src/atom_vec.h | 2 +- src/atom_vec_atomic.cpp | 18 +++--- src/atom_vec_atomic.h | 2 +- src/atom_vec_charge.cpp | 20 +++--- src/atom_vec_charge.h | 2 +- src/atom_vec_hybrid.cpp | 4 +- src/atom_vec_hybrid.h | 2 +- src/comm.cpp | 22 +++---- src/comm.h | 2 +- src/compute.h | 1 - src/compute_reduce.h | 1 - src/compute_reduce_region.h | 1 - src/dump.cpp | 14 ++-- src/dump.h | 3 +- src/dump_custom.cpp | 10 +-- src/dump_custom.h | 2 +- src/dump_dcd.cpp | 6 +- src/dump_dcd.h | 2 +- src/fix.h | 1 - src/fix_ave_atom.h | 1 - src/fix_ave_correlate.h | 1 - src/fix_ave_histo.h | 1 - src/fix_ave_spatial.h | 1 - src/fix_ave_time.h | 1 - src/fix_dt_reset.h | 1 - src/fix_shake.h | 1 - src/force.cpp | 17 ++--- src/force.h | 2 +- src/group.h | 1 - src/integrate.h | 3 +- src/irregular.cpp | 7 +- src/irregular.h | 2 +- src/lammps.h | 1 - src/memory.h | 44 ++++++++++++- src/min.h | 3 +- src/modify.cpp | 11 ++-- src/modify.h | 3 +- src/neigh_list.cpp | 26 ++++---- src/neigh_list.h | 2 +- src/neighbor.cpp | 18 +++--- src/neighbor.h | 2 +- src/output.cpp | 6 +- src/output.h | 1 - src/pointers.h | 1 + src/read_restart.h | 1 - src/region.h | 1 - src/respa.cpp | 2 +- src/thermo.h | 1 - src/universe.h | 1 - src/update.cpp | 5 +- src/update.h | 3 +- src/write_restart.h | 1 - 80 files changed, 391 insertions(+), 365 deletions(-) diff --git a/src/ASPHERE/atom_vec_ellipsoid.cpp b/src/ASPHERE/atom_vec_ellipsoid.cpp index 11e90e74d0..9a0b7d735f 100755 --- a/src/ASPHERE/atom_vec_ellipsoid.cpp +++ b/src/ASPHERE/atom_vec_ellipsoid.cpp @@ -879,24 +879,24 @@ int AtomVecEllipsoid::data_vel_hybrid(int m, char **values) } /* ---------------------------------------------------------------------- - return # of bytes of allocated memory + return # of bytes of allocated memory ------------------------------------------------------------------------- */ -double AtomVecEllipsoid::memory_usage() +bigint AtomVecEllipsoid::memory_usage() { - double bytes = 0.0; + bigint bytes = 0; - if (atom->memcheck("tag")) bytes += nmax * sizeof(int); - if (atom->memcheck("type")) bytes += nmax * sizeof(int); - if (atom->memcheck("mask")) bytes += nmax * sizeof(int); - if (atom->memcheck("image")) bytes += nmax * sizeof(int); - if (atom->memcheck("x")) bytes += nmax*3 * sizeof(double); - if (atom->memcheck("v")) bytes += nmax*3 * sizeof(double); - if (atom->memcheck("f")) bytes += nmax*3 * sizeof(double); + if (atom->memcheck("tag")) bytes += memory->usage(tag,nmax); + if (atom->memcheck("type")) bytes += memory->usage(type,nmax); + if (atom->memcheck("mask")) bytes += memory->usage(mask,nmax); + if (atom->memcheck("image")) bytes += memory->usage(image,nmax); + if (atom->memcheck("x")) bytes += memory->usage(x,nmax,3); + if (atom->memcheck("v")) bytes += memory->usage(v,nmax,3); + if (atom->memcheck("f")) bytes += memory->usage(f,nmax,3); - if (atom->memcheck("quat")) bytes += nmax*4 * sizeof(double); - if (atom->memcheck("angmom")) bytes += nmax*3 * sizeof(double); - if (atom->memcheck("torque")) bytes += nmax*3 * sizeof(double); + if (atom->memcheck("quat")) bytes += memory->usage(quat,nmax,4); + if (atom->memcheck("angmom")) bytes += memory->usage(angmom,nmax,3); + if (atom->memcheck("torque")) bytes += memory->usage(torque,nmax,3); return bytes; } diff --git a/src/ASPHERE/atom_vec_ellipsoid.h b/src/ASPHERE/atom_vec_ellipsoid.h index 4f6967f4bd..830e225003 100755 --- a/src/ASPHERE/atom_vec_ellipsoid.h +++ b/src/ASPHERE/atom_vec_ellipsoid.h @@ -57,7 +57,7 @@ class AtomVecEllipsoid : public AtomVec { int data_atom_hybrid(int, char **); void data_vel(int, char **); int data_vel_hybrid(int, char **); - double memory_usage(); + bigint memory_usage(); private: int *tag,*type,*mask,*image; diff --git a/src/COLLOID/atom_vec_colloid.cpp b/src/COLLOID/atom_vec_colloid.cpp index 601692ac72..001a8c8637 100644 --- a/src/COLLOID/atom_vec_colloid.cpp +++ b/src/COLLOID/atom_vec_colloid.cpp @@ -729,23 +729,23 @@ int AtomVecColloid::data_vel_hybrid(int m, char **values) } /* ---------------------------------------------------------------------- - return # of bytes of allocated memory + return # of bytes of allocated memory ------------------------------------------------------------------------- */ -double AtomVecColloid::memory_usage() +bigint AtomVecColloid::memory_usage() { - double bytes = 0.0; + bigint bytes = 0; - if (atom->memcheck("tag")) bytes += nmax * sizeof(int); - if (atom->memcheck("type")) bytes += nmax * sizeof(int); - if (atom->memcheck("mask")) bytes += nmax * sizeof(int); - if (atom->memcheck("image")) bytes += nmax * sizeof(int); - if (atom->memcheck("x")) bytes += nmax*3 * sizeof(double); - if (atom->memcheck("v")) bytes += nmax*3 * sizeof(double); - if (atom->memcheck("f")) bytes += nmax*3 * sizeof(double); + if (atom->memcheck("tag")) bytes += memory->usage(tag,nmax); + if (atom->memcheck("type")) bytes += memory->usage(type,nmax); + if (atom->memcheck("mask")) bytes += memory->usage(mask,nmax); + if (atom->memcheck("image")) bytes += memory->usage(image,nmax); + if (atom->memcheck("x")) bytes += memory->usage(x,nmax,3); + if (atom->memcheck("v")) bytes += memory->usage(v,nmax,3); + if (atom->memcheck("f")) bytes += memory->usage(f,nmax,3); - if (atom->memcheck("omega")) bytes += nmax*3 * sizeof(double); - if (atom->memcheck("torque")) bytes += nmax*3 * sizeof(double); + if (atom->memcheck("omega")) bytes += memory->usage(omega,nmax,3); + if (atom->memcheck("torque")) bytes += memory->usage(torque,nmax,3); return bytes; } diff --git a/src/COLLOID/atom_vec_colloid.h b/src/COLLOID/atom_vec_colloid.h index fa37121ab3..121cbc82d3 100644 --- a/src/COLLOID/atom_vec_colloid.h +++ b/src/COLLOID/atom_vec_colloid.h @@ -52,7 +52,7 @@ class AtomVecColloid : public AtomVec { void data_atom(double *, int, char **); void data_vel(int, char **); int data_vel_hybrid(int, char **); - double memory_usage(); + bigint memory_usage(); private: int *tag,*type,*mask,*image; diff --git a/src/DIPOLE/atom_vec_dipole.cpp b/src/DIPOLE/atom_vec_dipole.cpp index 4facc8c3a7..18985e8bb4 100644 --- a/src/DIPOLE/atom_vec_dipole.cpp +++ b/src/DIPOLE/atom_vec_dipole.cpp @@ -869,22 +869,22 @@ int AtomVecDipole::data_vel_hybrid(int m, char **values) return # of bytes of allocated memory ------------------------------------------------------------------------- */ -double AtomVecDipole::memory_usage() +bigint AtomVecDipole::memory_usage() { - double bytes = 0.0; + bigint bytes = 0; - if (atom->memcheck("tag")) bytes += nmax * sizeof(int); - if (atom->memcheck("type")) bytes += nmax * sizeof(int); - if (atom->memcheck("mask")) bytes += nmax * sizeof(int); - if (atom->memcheck("image")) bytes += nmax * sizeof(int); - if (atom->memcheck("x")) bytes += nmax*3 * sizeof(double); - if (atom->memcheck("v")) bytes += nmax*3 * sizeof(double); - if (atom->memcheck("f")) bytes += nmax*3 * sizeof(double); + if (atom->memcheck("tag")) bytes += memory->usage(tag,nmax); + if (atom->memcheck("type")) bytes += memory->usage(type,nmax); + if (atom->memcheck("mask")) bytes += memory->usage(mask,nmax); + if (atom->memcheck("image")) bytes += memory->usage(image,nmax); + if (atom->memcheck("x")) bytes += memory->usage(x,nmax,3); + if (atom->memcheck("v")) bytes += memory->usage(v,nmax,3); + if (atom->memcheck("f")) bytes += memory->usage(f,nmax,3); - if (atom->memcheck("q")) bytes += nmax * sizeof(double); - if (atom->memcheck("mu")) bytes += nmax*3 * sizeof(double); - if (atom->memcheck("omega")) bytes += nmax*3 * sizeof(double); - if (atom->memcheck("torque")) bytes += nmax*3 * sizeof(double); + if (atom->memcheck("q")) bytes += memory->usage(q,nmax); + if (atom->memcheck("mu")) bytes += memory->usage(mu,nmax,3); + if (atom->memcheck("omega")) bytes += memory->usage(omega,nmax,3); + if (atom->memcheck("torque")) bytes += memory->usage(torque,nmax,3); return bytes; } diff --git a/src/DIPOLE/atom_vec_dipole.h b/src/DIPOLE/atom_vec_dipole.h index 5f8062fce0..010b1f5292 100644 --- a/src/DIPOLE/atom_vec_dipole.h +++ b/src/DIPOLE/atom_vec_dipole.h @@ -56,7 +56,7 @@ class AtomVecDipole : public AtomVec { int data_atom_hybrid(int, char **); void data_vel(int, char **); int data_vel_hybrid(int, char **); - double memory_usage(); + bigint memory_usage(); private: int *tag,*type,*mask,*image; diff --git a/src/GRANULAR/atom_vec_granular.cpp b/src/GRANULAR/atom_vec_granular.cpp index 960d70b078..652ea57bf7 100644 --- a/src/GRANULAR/atom_vec_granular.cpp +++ b/src/GRANULAR/atom_vec_granular.cpp @@ -1009,23 +1009,23 @@ int AtomVecGranular::data_vel_hybrid(int m, char **values) return # of bytes of allocated memory ------------------------------------------------------------------------- */ -double AtomVecGranular::memory_usage() +bigint AtomVecGranular::memory_usage() { - double bytes = 0.0; + bigint bytes = 0; - if (atom->memcheck("tag")) bytes += nmax * sizeof(int); - if (atom->memcheck("type")) bytes += nmax * sizeof(int); - if (atom->memcheck("mask")) bytes += nmax * sizeof(int); - if (atom->memcheck("image")) bytes += nmax * sizeof(int); - if (atom->memcheck("x")) bytes += nmax*3 * sizeof(double); - if (atom->memcheck("v")) bytes += nmax*3 * sizeof(double); - if (atom->memcheck("f")) bytes += nmax*3 * sizeof(double); + if (atom->memcheck("tag")) bytes += memory->usage(tag,nmax); + if (atom->memcheck("type")) bytes += memory->usage(type,nmax); + if (atom->memcheck("mask")) bytes += memory->usage(mask,nmax); + if (atom->memcheck("image")) bytes += memory->usage(image,nmax); + if (atom->memcheck("x")) bytes += memory->usage(x,nmax,3); + if (atom->memcheck("v")) bytes += memory->usage(v,nmax,3); + if (atom->memcheck("f")) bytes += memory->usage(f,nmax,3); - if (atom->memcheck("radius")) bytes += nmax * sizeof(double); - if (atom->memcheck("density")) bytes += nmax * sizeof(double); - if (atom->memcheck("rmass")) bytes += nmax * sizeof(double); - if (atom->memcheck("omega")) bytes += nmax*3 * sizeof(double); - if (atom->memcheck("torque")) bytes += nmax*3 * sizeof(double); + if (atom->memcheck("radius")) bytes += memory->usage(radius,nmax); + if (atom->memcheck("density")) bytes += memory->usage(density,nmax); + if (atom->memcheck("rmass")) bytes += memory->usage(rmass,nmax); + if (atom->memcheck("omega")) bytes += memory->usage(omega,nmax,3); + if (atom->memcheck("torque")) bytes += memory->usage(torque,nmax,3); return bytes; } diff --git a/src/GRANULAR/atom_vec_granular.h b/src/GRANULAR/atom_vec_granular.h index 1f5b20a6fe..9e18ac8038 100644 --- a/src/GRANULAR/atom_vec_granular.h +++ b/src/GRANULAR/atom_vec_granular.h @@ -58,7 +58,7 @@ class AtomVecGranular : public AtomVec { int data_atom_hybrid(int, char **); void data_vel(int, char **); int data_vel_hybrid(int, char **); - double memory_usage(); + bigint memory_usage(); private: double PI; diff --git a/src/KSPACE/pppm.h b/src/KSPACE/pppm.h index cb02853983..3577d6124c 100644 --- a/src/KSPACE/pppm.h +++ b/src/KSPACE/pppm.h @@ -20,7 +20,6 @@ KSpaceStyle(pppm,PPPM) #ifndef LMP_PPPM_H #define LMP_PPPM_H -#include "lmptype.h" #include "kspace.h" namespace LAMMPS_NS { diff --git a/src/MANYBODY/fix_qeq_comb.h b/src/MANYBODY/fix_qeq_comb.h index be3d6b227b..f8ddd0018a 100644 --- a/src/MANYBODY/fix_qeq_comb.h +++ b/src/MANYBODY/fix_qeq_comb.h @@ -20,7 +20,6 @@ FixStyle(qeq/comb,FixQEQComb) #ifndef LMP_FIX_QEQ_COMB_H #define LMP_FIX_QEQ_COMB_H -#include "lmptype.h" #include "stdio.h" #include "fix.h" diff --git a/src/MOLECULE/atom_vec_angle.cpp b/src/MOLECULE/atom_vec_angle.cpp index 766dab3a60..6b2adfbdfa 100644 --- a/src/MOLECULE/atom_vec_angle.cpp +++ b/src/MOLECULE/atom_vec_angle.cpp @@ -11,7 +11,6 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ -#include "lmptype.h" #include "stdlib.h" #include "atom_vec_angle.h" #include "atom.h" @@ -795,37 +794,38 @@ int AtomVecAngle::data_atom_hybrid(int nlocal, char **values) return # of bytes of allocated memory ------------------------------------------------------------------------- */ -double AtomVecAngle::memory_usage() +bigint AtomVecAngle::memory_usage() { - double bytes = 0.0; + bigint bytes = 0; - if (atom->memcheck("tag")) bytes += nmax * sizeof(int); - if (atom->memcheck("type")) bytes += nmax * sizeof(int); - if (atom->memcheck("mask")) bytes += nmax * sizeof(int); - if (atom->memcheck("image")) bytes += nmax * sizeof(int); - if (atom->memcheck("x")) bytes += nmax*3 * sizeof(double); - if (atom->memcheck("v")) bytes += nmax*3 * sizeof(double); - if (atom->memcheck("f")) bytes += nmax*3 * sizeof(double); + if (atom->memcheck("tag")) bytes += memory->usage(tag,nmax); + if (atom->memcheck("type")) bytes += memory->usage(type,nmax); + if (atom->memcheck("mask")) bytes += memory->usage(mask,nmax); + if (atom->memcheck("image")) bytes += memory->usage(image,nmax); + if (atom->memcheck("x")) bytes += memory->usage(x,nmax,3); + if (atom->memcheck("v")) bytes += memory->usage(v,nmax,3); + if (atom->memcheck("f")) bytes += memory->usage(f,nmax,3); - if (atom->memcheck("molecule")) bytes += nmax * sizeof(int); - if (atom->memcheck("nspecial")) bytes += nmax*3 * sizeof(int); - if (atom->memcheck("special")) bytes += nmax*atom->maxspecial * sizeof(int); + if (atom->memcheck("molecule")) bytes += memory->usage(molecule,nmax); + if (atom->memcheck("nspecial")) bytes += memory->usage(nspecial,nmax,3); + if (atom->memcheck("special")) + bytes += memory->usage(special,nmax,atom->maxspecial); - if (atom->memcheck("num_bond")) bytes += nmax * sizeof(int); - if (atom->memcheck("bond_type")) - bytes += nmax*atom->bond_per_atom * sizeof(int); - if (atom->memcheck("bond_atom")) - bytes += nmax*atom->bond_per_atom * sizeof(int); + if (atom->memcheck("num_bond")) bytes += memory->usage(num_bond,nmax); + if (atom->memcheck("bond_type")) + bytes += memory->usage(bond_type,nmax,atom->bond_per_atom); + if (atom->memcheck("bond_atom")) + bytes += memory->usage(bond_atom,nmax,atom->bond_per_atom); - if (atom->memcheck("num_angle")) bytes += nmax * sizeof(int); - if (atom->memcheck("angle_type")) - bytes += nmax*atom->angle_per_atom * sizeof(int); - if (atom->memcheck("angle_atom1")) - bytes += nmax*atom->angle_per_atom * sizeof(int); - if (atom->memcheck("angle_atom2")) - bytes += nmax*atom->angle_per_atom * sizeof(int); - if (atom->memcheck("angle_atom3")) - bytes += nmax*atom->angle_per_atom * sizeof(int); + if (atom->memcheck("num_angle")) bytes += memory->usage(num_angle,nmax); + if (atom->memcheck("angle_type")) + bytes += memory->usage(angle_type,nmax,atom->angle_per_atom); + if (atom->memcheck("angle_atom1")) + bytes += memory->usage(angle_atom1,nmax,atom->angle_per_atom); + if (atom->memcheck("angle_atom2")) + bytes += memory->usage(angle_atom2,nmax,atom->angle_per_atom); + if (atom->memcheck("angle_atom3")) + bytes += memory->usage(angle_atom3,nmax,atom->angle_per_atom); return bytes; } diff --git a/src/MOLECULE/atom_vec_angle.h b/src/MOLECULE/atom_vec_angle.h index 482c54ebc0..bd73a7ef38 100644 --- a/src/MOLECULE/atom_vec_angle.h +++ b/src/MOLECULE/atom_vec_angle.h @@ -50,7 +50,7 @@ class AtomVecAngle : public AtomVec { void create_atom(int, double *); void data_atom(double *, int, char **); int data_atom_hybrid(int, char **); - double memory_usage(); + bigint memory_usage(); private: int *tag,*type,*mask,*image; diff --git a/src/MOLECULE/atom_vec_bond.cpp b/src/MOLECULE/atom_vec_bond.cpp index 9d0ba86251..451e6ff87c 100644 --- a/src/MOLECULE/atom_vec_bond.cpp +++ b/src/MOLECULE/atom_vec_bond.cpp @@ -752,27 +752,28 @@ int AtomVecBond::data_atom_hybrid(int nlocal, char **values) return # of bytes of allocated memory ------------------------------------------------------------------------- */ -double AtomVecBond::memory_usage() +bigint AtomVecBond::memory_usage() { - double bytes = 0.0; + bigint bytes = 0; - if (atom->memcheck("tag")) bytes += nmax * sizeof(int); - if (atom->memcheck("type")) bytes += nmax * sizeof(int); - if (atom->memcheck("mask")) bytes += nmax * sizeof(int); - if (atom->memcheck("image")) bytes += nmax * sizeof(int); - if (atom->memcheck("x")) bytes += nmax*3 * sizeof(double); - if (atom->memcheck("v")) bytes += nmax*3 * sizeof(double); - if (atom->memcheck("f")) bytes += nmax*3 * sizeof(double); + if (atom->memcheck("tag")) bytes += memory->usage(tag,nmax); + if (atom->memcheck("type")) bytes += memory->usage(type,nmax); + if (atom->memcheck("mask")) bytes += memory->usage(mask,nmax); + if (atom->memcheck("image")) bytes += memory->usage(image,nmax); + if (atom->memcheck("x")) bytes += memory->usage(x,nmax,3); + if (atom->memcheck("v")) bytes += memory->usage(v,nmax,3); + if (atom->memcheck("f")) bytes += memory->usage(f,nmax,3); - if (atom->memcheck("molecule")) bytes += nmax * sizeof(int); - if (atom->memcheck("nspecial")) bytes += nmax*3 * sizeof(int); - if (atom->memcheck("special")) bytes += nmax*atom->maxspecial * sizeof(int); + if (atom->memcheck("molecule")) bytes += memory->usage(molecule,nmax); + if (atom->memcheck("nspecial")) bytes += memory->usage(nspecial,nmax,3); + if (atom->memcheck("special")) + bytes += memory->usage(special,nmax,atom->maxspecial); - if (atom->memcheck("num_bond")) bytes += nmax * sizeof(int); - if (atom->memcheck("bond_type")) - bytes += nmax*atom->bond_per_atom * sizeof(int); - if (atom->memcheck("bond_atom")) - bytes += nmax*atom->bond_per_atom * sizeof(int); + if (atom->memcheck("num_bond")) bytes += memory->usage(num_bond,nmax); + if (atom->memcheck("bond_type")) + bytes += memory->usage(bond_type,nmax,atom->bond_per_atom); + if (atom->memcheck("bond_atom")) + bytes += memory->usage(bond_atom,nmax,atom->bond_per_atom); return bytes; } diff --git a/src/MOLECULE/atom_vec_bond.h b/src/MOLECULE/atom_vec_bond.h index 8c5a8cade7..5a6648651c 100644 --- a/src/MOLECULE/atom_vec_bond.h +++ b/src/MOLECULE/atom_vec_bond.h @@ -50,7 +50,7 @@ class AtomVecBond : public AtomVec { void create_atom(int, double *); void data_atom(double *, int, char **); int data_atom_hybrid(int, char **); - double memory_usage(); + bigint memory_usage(); private: int *tag,*type,*mask,*image; diff --git a/src/MOLECULE/atom_vec_full.cpp b/src/MOLECULE/atom_vec_full.cpp index af09a8edba..26b2e99f82 100644 --- a/src/MOLECULE/atom_vec_full.cpp +++ b/src/MOLECULE/atom_vec_full.cpp @@ -963,62 +963,63 @@ int AtomVecFull::data_atom_hybrid(int nlocal, char **values) return # of bytes of allocated memory ------------------------------------------------------------------------- */ -double AtomVecFull::memory_usage() +bigint AtomVecFull::memory_usage() { - double bytes = 0.0; + bigint bytes = 0; - if (atom->memcheck("tag")) bytes += nmax * sizeof(int); - if (atom->memcheck("type")) bytes += nmax * sizeof(int); - if (atom->memcheck("mask")) bytes += nmax * sizeof(int); - if (atom->memcheck("image")) bytes += nmax * sizeof(int); - if (atom->memcheck("x")) bytes += nmax*3 * sizeof(double); - if (atom->memcheck("v")) bytes += nmax*3 * sizeof(double); - if (atom->memcheck("f")) bytes += nmax*3 * sizeof(double); + if (atom->memcheck("tag")) bytes += memory->usage(tag,nmax); + if (atom->memcheck("type")) bytes += memory->usage(type,nmax); + if (atom->memcheck("mask")) bytes += memory->usage(mask,nmax); + if (atom->memcheck("image")) bytes += memory->usage(image,nmax); + if (atom->memcheck("x")) bytes += memory->usage(x,nmax,3); + if (atom->memcheck("v")) bytes += memory->usage(v,nmax,3); + if (atom->memcheck("f")) bytes += memory->usage(f,nmax,3); - if (atom->memcheck("q")) bytes += nmax * sizeof(double); - if (atom->memcheck("molecule")) bytes += nmax * sizeof(int); - if (atom->memcheck("nspecial")) bytes += nmax*3 * sizeof(int); - if (atom->memcheck("special")) bytes += nmax*atom->maxspecial * sizeof(int); + if (atom->memcheck("q")) bytes += memory->usage(q,nmax); + if (atom->memcheck("molecule")) bytes += memory->usage(molecule,nmax); + if (atom->memcheck("nspecial")) bytes += memory->usage(nspecial,nmax,3); + if (atom->memcheck("special")) + bytes += memory->usage(special,nmax,atom->maxspecial); - if (atom->memcheck("num_bond")) bytes += nmax * sizeof(int); - if (atom->memcheck("bond_type")) - bytes += nmax*atom->bond_per_atom * sizeof(int); - if (atom->memcheck("bond_atom")) - bytes += nmax*atom->bond_per_atom * sizeof(int); + if (atom->memcheck("num_bond")) bytes += memory->usage(num_bond,nmax); + if (atom->memcheck("bond_type")) + bytes += memory->usage(bond_type,nmax,atom->bond_per_atom); + if (atom->memcheck("bond_atom")) + bytes += memory->usage(bond_atom,nmax,atom->bond_per_atom); - if (atom->memcheck("num_angle")) bytes += nmax * sizeof(int); - if (atom->memcheck("angle_type")) - bytes += nmax*atom->angle_per_atom * sizeof(int); - if (atom->memcheck("angle_atom1")) - bytes += nmax*atom->angle_per_atom * sizeof(int); - if (atom->memcheck("angle_atom2")) - bytes += nmax*atom->angle_per_atom * sizeof(int); - if (atom->memcheck("angle_atom3")) - bytes += nmax*atom->angle_per_atom * sizeof(int); + if (atom->memcheck("num_angle")) bytes += memory->usage(num_angle,nmax); + if (atom->memcheck("angle_type")) + bytes += memory->usage(angle_type,nmax,atom->angle_per_atom); + if (atom->memcheck("angle_atom1")) + bytes += memory->usage(angle_atom1,nmax,atom->angle_per_atom); + if (atom->memcheck("angle_atom2")) + bytes += memory->usage(angle_atom2,nmax,atom->angle_per_atom); + if (atom->memcheck("angle_atom3")) + bytes += memory->usage(angle_atom3,nmax,atom->angle_per_atom); - if (atom->memcheck("num_dihedral")) bytes += nmax * sizeof(int); - if (atom->memcheck("dihedral_type")) - bytes += nmax*atom->dihedral_per_atom * sizeof(int); - if (atom->memcheck("dihedral_atom1")) - bytes += nmax*atom->dihedral_per_atom * sizeof(int); - if (atom->memcheck("dihedral_atom2")) - bytes += nmax*atom->dihedral_per_atom * sizeof(int); - if (atom->memcheck("dihedral_atom3")) - bytes += nmax*atom->dihedral_per_atom * sizeof(int); - if (atom->memcheck("dihedral_atom4")) - bytes += nmax*atom->dihedral_per_atom * sizeof(int); + if (atom->memcheck("num_dihedral")) bytes += memory->usage(num_dihedral,nmax); + if (atom->memcheck("dihedral_type")) + bytes += memory->usage(dihedral_type,nmax,atom->dihedral_per_atom); + if (atom->memcheck("dihedral_atom1")) + bytes += memory->usage(dihedral_atom1,nmax,atom->dihedral_per_atom); + if (atom->memcheck("dihedral_atom2")) + bytes += memory->usage(dihedral_atom2,nmax,atom->dihedral_per_atom); + if (atom->memcheck("dihedral_atom3")) + bytes += memory->usage(dihedral_atom3,nmax,atom->dihedral_per_atom); + if (atom->memcheck("dihedral_atom4")) + bytes += memory->usage(dihedral_atom4,nmax,atom->dihedral_per_atom); - if (atom->memcheck("num_improper")) bytes += nmax * sizeof(int); - if (atom->memcheck("improper_type")) - bytes += nmax*atom->improper_per_atom * sizeof(int); - if (atom->memcheck("improper_atom1")) - bytes += nmax*atom->improper_per_atom * sizeof(int); - if (atom->memcheck("improper_atom2")) - bytes += nmax*atom->improper_per_atom * sizeof(int); - if (atom->memcheck("improper_atom3")) - bytes += nmax*atom->improper_per_atom * sizeof(int); - if (atom->memcheck("improper_atom4")) - bytes += nmax*atom->improper_per_atom * sizeof(int); + if (atom->memcheck("num_improper")) bytes += memory->usage(num_improper,nmax); + if (atom->memcheck("improper_type")) + bytes += memory->usage(improper_type,nmax,atom->improper_per_atom); + if (atom->memcheck("improper_atom1")) + bytes += memory->usage(improper_atom1,nmax,atom->improper_per_atom); + if (atom->memcheck("improper_atom2")) + bytes += memory->usage(improper_atom2,nmax,atom->improper_per_atom); + if (atom->memcheck("improper_atom3")) + bytes += memory->usage(improper_atom3,nmax,atom->improper_per_atom); + if (atom->memcheck("improper_atom4")) + bytes += memory->usage(improper_atom4,nmax,atom->improper_per_atom); return bytes; } diff --git a/src/MOLECULE/atom_vec_full.h b/src/MOLECULE/atom_vec_full.h index 27c724e4bd..4fea6a5ea5 100644 --- a/src/MOLECULE/atom_vec_full.h +++ b/src/MOLECULE/atom_vec_full.h @@ -50,7 +50,7 @@ class AtomVecFull : public AtomVec { void create_atom(int, double *); void data_atom(double *, int, char **); int data_atom_hybrid(int, char **); - double memory_usage(); + bigint memory_usage(); private: int *tag,*type,*mask,*image; diff --git a/src/MOLECULE/atom_vec_molecular.cpp b/src/MOLECULE/atom_vec_molecular.cpp index 3e809184fa..ec039b7be2 100644 --- a/src/MOLECULE/atom_vec_molecular.cpp +++ b/src/MOLECULE/atom_vec_molecular.cpp @@ -944,61 +944,62 @@ int AtomVecMolecular::data_atom_hybrid(int nlocal, char **values) return # of bytes of allocated memory ------------------------------------------------------------------------- */ -double AtomVecMolecular::memory_usage() +bigint AtomVecMolecular::memory_usage() { - double bytes = 0.0; + bigint bytes = 0; - if (atom->memcheck("tag")) bytes += nmax * sizeof(int); - if (atom->memcheck("type")) bytes += nmax * sizeof(int); - if (atom->memcheck("mask")) bytes += nmax * sizeof(int); - if (atom->memcheck("image")) bytes += nmax * sizeof(int); - if (atom->memcheck("x")) bytes += nmax*3 * sizeof(double); - if (atom->memcheck("v")) bytes += nmax*3 * sizeof(double); - if (atom->memcheck("f")) bytes += nmax*3 * sizeof(double); + if (atom->memcheck("tag")) bytes += memory->usage(tag,nmax); + if (atom->memcheck("type")) bytes += memory->usage(type,nmax); + if (atom->memcheck("mask")) bytes += memory->usage(mask,nmax); + if (atom->memcheck("image")) bytes += memory->usage(image,nmax); + if (atom->memcheck("x")) bytes += memory->usage(x,nmax,3); + if (atom->memcheck("v")) bytes += memory->usage(v,nmax,3); + if (atom->memcheck("f")) bytes += memory->usage(f,nmax,3); - if (atom->memcheck("molecule")) bytes += nmax * sizeof(int); - if (atom->memcheck("nspecial")) bytes += nmax*3 * sizeof(int); - if (atom->memcheck("special")) bytes += nmax*atom->maxspecial * sizeof(int); + if (atom->memcheck("molecule")) bytes += memory->usage(molecule,nmax); + if (atom->memcheck("nspecial")) bytes += memory->usage(nspecial,nmax,3); + if (atom->memcheck("special")) + bytes += memory->usage(special,nmax,atom->maxspecial); - if (atom->memcheck("num_bond")) bytes += nmax * sizeof(int); - if (atom->memcheck("bond_type")) - bytes += nmax*atom->bond_per_atom * sizeof(int); - if (atom->memcheck("bond_atom")) - bytes += nmax*atom->bond_per_atom * sizeof(int); + if (atom->memcheck("num_bond")) bytes += memory->usage(num_bond,nmax); + if (atom->memcheck("bond_type")) + bytes += memory->usage(bond_type,nmax,atom->bond_per_atom); + if (atom->memcheck("bond_atom")) + bytes += memory->usage(bond_atom,nmax,atom->bond_per_atom); - if (atom->memcheck("num_angle")) bytes += nmax * sizeof(int); - if (atom->memcheck("angle_type")) - bytes += nmax*atom->angle_per_atom * sizeof(int); - if (atom->memcheck("angle_atom1")) - bytes += nmax*atom->angle_per_atom * sizeof(int); - if (atom->memcheck("angle_atom2")) - bytes += nmax*atom->angle_per_atom * sizeof(int); - if (atom->memcheck("angle_atom3")) - bytes += nmax*atom->angle_per_atom * sizeof(int); + if (atom->memcheck("num_angle")) bytes += memory->usage(num_angle,nmax); + if (atom->memcheck("angle_type")) + bytes += memory->usage(angle_type,nmax,atom->angle_per_atom); + if (atom->memcheck("angle_atom1")) + bytes += memory->usage(angle_atom1,nmax,atom->angle_per_atom); + if (atom->memcheck("angle_atom2")) + bytes += memory->usage(angle_atom2,nmax,atom->angle_per_atom); + if (atom->memcheck("angle_atom3")) + bytes += memory->usage(angle_atom3,nmax,atom->angle_per_atom); - if (atom->memcheck("num_dihedral")) bytes += nmax * sizeof(int); - if (atom->memcheck("dihedral_type")) - bytes += nmax*atom->dihedral_per_atom * sizeof(int); - if (atom->memcheck("dihedral_atom1")) - bytes += nmax*atom->dihedral_per_atom * sizeof(int); - if (atom->memcheck("dihedral_atom2")) - bytes += nmax*atom->dihedral_per_atom * sizeof(int); - if (atom->memcheck("dihedral_atom3")) - bytes += nmax*atom->dihedral_per_atom * sizeof(int); - if (atom->memcheck("dihedral_atom4")) - bytes += nmax*atom->dihedral_per_atom * sizeof(int); + if (atom->memcheck("num_dihedral")) bytes += memory->usage(num_dihedral,nmax); + if (atom->memcheck("dihedral_type")) + bytes += memory->usage(dihedral_type,nmax,atom->dihedral_per_atom); + if (atom->memcheck("dihedral_atom1")) + bytes += memory->usage(dihedral_atom1,nmax,atom->dihedral_per_atom); + if (atom->memcheck("dihedral_atom2")) + bytes += memory->usage(dihedral_atom2,nmax,atom->dihedral_per_atom); + if (atom->memcheck("dihedral_atom3")) + bytes += memory->usage(dihedral_atom3,nmax,atom->dihedral_per_atom); + if (atom->memcheck("dihedral_atom4")) + bytes += memory->usage(dihedral_atom4,nmax,atom->dihedral_per_atom); - if (atom->memcheck("num_improper")) bytes += nmax * sizeof(int); - if (atom->memcheck("improper_type")) - bytes += nmax*atom->improper_per_atom * sizeof(int); - if (atom->memcheck("improper_atom1")) - bytes += nmax*atom->improper_per_atom * sizeof(int); - if (atom->memcheck("improper_atom2")) - bytes += nmax*atom->improper_per_atom * sizeof(int); - if (atom->memcheck("improper_atom3")) - bytes += nmax*atom->improper_per_atom * sizeof(int); - if (atom->memcheck("improper_atom4")) - bytes += nmax*atom->improper_per_atom * sizeof(int); + if (atom->memcheck("num_improper")) bytes += memory->usage(num_improper,nmax); + if (atom->memcheck("improper_type")) + bytes += memory->usage(improper_type,nmax,atom->improper_per_atom); + if (atom->memcheck("improper_atom1")) + bytes += memory->usage(improper_atom1,nmax,atom->improper_per_atom); + if (atom->memcheck("improper_atom2")) + bytes += memory->usage(improper_atom2,nmax,atom->improper_per_atom); + if (atom->memcheck("improper_atom3")) + bytes += memory->usage(improper_atom3,nmax,atom->improper_per_atom); + if (atom->memcheck("improper_atom4")) + bytes += memory->usage(improper_atom4,nmax,atom->improper_per_atom); return bytes; } diff --git a/src/MOLECULE/atom_vec_molecular.h b/src/MOLECULE/atom_vec_molecular.h index 7b0ab74e2d..2f1ce1006f 100644 --- a/src/MOLECULE/atom_vec_molecular.h +++ b/src/MOLECULE/atom_vec_molecular.h @@ -50,7 +50,7 @@ class AtomVecMolecular : public AtomVec { void create_atom(int, double *); void data_atom(double *, int, char **); int data_atom_hybrid(int, char **); - double memory_usage(); + bigint memory_usage(); private: int *tag,*type,*mask,*image; diff --git a/src/PERI/atom_vec_peri.cpp b/src/PERI/atom_vec_peri.cpp index 322fa56ca7..23be75893a 100644 --- a/src/PERI/atom_vec_peri.cpp +++ b/src/PERI/atom_vec_peri.cpp @@ -798,23 +798,23 @@ int AtomVecPeri::data_atom_hybrid(int nlocal, char **values) return # of bytes of allocated memory ------------------------------------------------------------------------- */ -double AtomVecPeri::memory_usage() +bigint AtomVecPeri::memory_usage() { - double bytes = 0.0; - - if (atom->memcheck("tag")) bytes += nmax * sizeof(int); - if (atom->memcheck("type")) bytes += nmax * sizeof(int); - if (atom->memcheck("mask")) bytes += nmax * sizeof(int); - if (atom->memcheck("image")) bytes += nmax * sizeof(int); - if (atom->memcheck("x")) bytes += nmax*3 * sizeof(double); - if (atom->memcheck("v")) bytes += nmax*3 * sizeof(double); - if (atom->memcheck("f")) bytes += nmax*3 * sizeof(double); - - if (atom->memcheck("vfrac")) bytes += nmax * sizeof(double); - if (atom->memcheck("density")) bytes += nmax * sizeof(double); - if (atom->memcheck("rmass")) bytes += nmax * sizeof(double); - if (atom->memcheck("s0")) bytes += nmax * sizeof(double); - if (atom->memcheck("x0")) bytes += nmax*3 * sizeof(double); + bigint bytes = 0; + + if (atom->memcheck("tag")) bytes += memory->usage(tag,nmax); + if (atom->memcheck("type")) bytes += memory->usage(type,nmax); + if (atom->memcheck("mask")) bytes += memory->usage(mask,nmax); + if (atom->memcheck("image")) bytes += memory->usage(image,nmax); + if (atom->memcheck("x")) bytes += memory->usage(x,nmax,3); + if (atom->memcheck("v")) bytes += memory->usage(v,nmax,3); + if (atom->memcheck("f")) bytes += memory->usage(f,nmax,3); + + if (atom->memcheck("vfrac")) bytes += memory->usage(vfrac,nmax); + if (atom->memcheck("density")) bytes += memory->usage(density,nmax); + if (atom->memcheck("rmass")) bytes += memory->usage(rmass,nmax); + if (atom->memcheck("s0")) bytes += memory->usage(s0,nmax); + if (atom->memcheck("x0")) bytes += memory->usage(x0,nmax,3); return bytes; } diff --git a/src/PERI/atom_vec_peri.h b/src/PERI/atom_vec_peri.h index 36a1c9ab85..333e452b5a 100755 --- a/src/PERI/atom_vec_peri.h +++ b/src/PERI/atom_vec_peri.h @@ -52,7 +52,7 @@ class AtomVecPeri : public AtomVec { void create_atom(int, double *); void data_atom(double *, int, char **); int data_atom_hybrid(int, char **); - double memory_usage(); + bigint memory_usage(); private: int *tag,*type,*mask,*image; diff --git a/src/REAX/fix_reax_bonds.h b/src/REAX/fix_reax_bonds.h index 678984f022..a4c2f7098d 100644 --- a/src/REAX/fix_reax_bonds.h +++ b/src/REAX/fix_reax_bonds.h @@ -20,7 +20,6 @@ FixStyle(reax/bonds,FixReaxBonds) #ifndef LMP_FIX_REAX_BONDS_H #define LMP_FIX_REAX_BONDS_H -#include "lmptype.h" #include "stdio.h" #include "fix.h" diff --git a/src/REPLICA/fix_event_prd.h b/src/REPLICA/fix_event_prd.h index e5aaa8ccdc..b1312d8de8 100644 --- a/src/REPLICA/fix_event_prd.h +++ b/src/REPLICA/fix_event_prd.h @@ -20,7 +20,6 @@ FixStyle(EVENT/PRD,FixEventPRD) #ifndef LMP_FIX_EVENT_PRD_H #define LMP_FIX_EVENT_PRD_H -#include "lmptype.h" #include "fix_event.h" namespace LAMMPS_NS { diff --git a/src/REPLICA/fix_event_tad.h b/src/REPLICA/fix_event_tad.h index ccd3c1cd4b..97e1ad29df 100644 --- a/src/REPLICA/fix_event_tad.h +++ b/src/REPLICA/fix_event_tad.h @@ -20,7 +20,6 @@ FixStyle(EVENT/TAD,FixEventTAD) #ifndef LMP_FIX_EVENT_TAD_H #define LMP_FIX_EVENT_TAD_H -#include "lmptype.h" #include "fix_event.h" namespace LAMMPS_NS { diff --git a/src/SRD/fix_wall_srd.h b/src/SRD/fix_wall_srd.h index 2ad5fdcdfc..172451b45f 100644 --- a/src/SRD/fix_wall_srd.h +++ b/src/SRD/fix_wall_srd.h @@ -20,7 +20,6 @@ FixStyle(wall/srd,FixWallSRD) #ifndef LMP_FIX_WALL_SRD_H #define LMP_FIX_WALL_SRD_H -#include "lmptype.h" #include "fix.h" namespace LAMMPS_NS { diff --git a/src/XTC/dump_xtc.cpp b/src/XTC/dump_xtc.cpp index 89ea2eb1c1..8ae59758c1 100644 --- a/src/XTC/dump_xtc.cpp +++ b/src/XTC/dump_xtc.cpp @@ -22,6 +22,7 @@ support for groups ------------------------------------------------------------------------- */ +#include "lmptype.h" #include "math.h" #include "stdio.h" #include "stdlib.h" @@ -304,10 +305,10 @@ int DumpXTC::modify_param(int narg, char **arg) return # of bytes of allocated memory in buf and global coords array ------------------------------------------------------------------------- */ -double DumpXTC::memory_usage() +bigint DumpXTC::memory_usage() { - double bytes = Dump::memory_usage(); - bytes += 3*natoms * sizeof(float); + bigint bytes = Dump::memory_usage(); + bytes += memory->usage(coords,natoms*3); return bytes; } diff --git a/src/XTC/dump_xtc.h b/src/XTC/dump_xtc.h index e1e2ca0254..5b43d2f46a 100644 --- a/src/XTC/dump_xtc.h +++ b/src/XTC/dump_xtc.h @@ -52,7 +52,7 @@ class DumpXTC : public Dump { int count(); void pack(int *); void write_data(int, double *); - double memory_usage(); + bigint memory_usage(); void write_frame(); }; diff --git a/src/atom.cpp b/src/atom.cpp index 7db4daccd8..3d323c3c75 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -1612,21 +1612,25 @@ void *Atom::extract(char *name) add in global to local mapping storage ------------------------------------------------------------------------- */ -double Atom::memory_usage() +bigint Atom::memory_usage() { memlength = DELTA_MEMSTR; memory->create(memstr,memlength,"atom:memstr"); memstr[0] = '\0'; + bigint bytes = avec->memory_usage(); + memory->destroy(memstr); - double bytes = avec->memory_usage(); if (map_style == 1) - bytes += map_tag_max * sizeof(int); + bytes += memory->usage(map_array,map_tag_max+1); else if (map_style == 2) { bytes += map_nbucket*sizeof(int); bytes += map_nhash*sizeof(HashElem); } + if (maxnext) { + bytes += memory->usage(next,maxnext); + bytes += memory->usage(permute,maxnext); + } - memory->destroy(memstr); return bytes; } diff --git a/src/atom.h b/src/atom.h index 8821e7c48c..9ffe4c1774 100644 --- a/src/atom.h +++ b/src/atom.h @@ -14,7 +14,6 @@ #ifndef LMP_ATOM_H #define LMP_ATOM_H -#include "lmptype.h" #include "pointers.h" namespace LAMMPS_NS { @@ -160,7 +159,7 @@ class Atom : protected Pointers { void *extract(char *); - double memory_usage(); + bigint memory_usage(); int memcheck(const char *); // functions for global to local ID mapping diff --git a/src/atom_vec.h b/src/atom_vec.h index 2f139bd2b3..9f57ebacf9 100644 --- a/src/atom_vec.h +++ b/src/atom_vec.h @@ -78,7 +78,7 @@ class AtomVec : protected Pointers { virtual void data_vel(int, char **); virtual int data_vel_hybrid(int, char **) {return 0;} - virtual double memory_usage() = 0; + virtual bigint memory_usage() = 0; protected: int nmax; // local copy of atom->nmax diff --git a/src/atom_vec_atomic.cpp b/src/atom_vec_atomic.cpp index 26bd4d0738..9a814dda82 100644 --- a/src/atom_vec_atomic.cpp +++ b/src/atom_vec_atomic.cpp @@ -619,17 +619,17 @@ void AtomVecAtomic::data_atom(double *coord, int imagetmp, char **values) return # of bytes of allocated memory ------------------------------------------------------------------------- */ -double AtomVecAtomic::memory_usage() +bigint AtomVecAtomic::memory_usage() { - double bytes = 0.0; + bigint bytes = 0; - if (atom->memcheck("tag")) bytes += nmax * sizeof(int); - if (atom->memcheck("type")) bytes += nmax * sizeof(int); - if (atom->memcheck("mask")) bytes += nmax * sizeof(int); - if (atom->memcheck("image")) bytes += nmax * sizeof(int); - if (atom->memcheck("x")) bytes += nmax*3 * sizeof(double); - if (atom->memcheck("v")) bytes += nmax*3 * sizeof(double); - if (atom->memcheck("f")) bytes += nmax*3 * sizeof(double); + if (atom->memcheck("tag")) bytes += memory->usage(tag,nmax); + if (atom->memcheck("type")) bytes += memory->usage(type,nmax); + if (atom->memcheck("mask")) bytes += memory->usage(mask,nmax); + if (atom->memcheck("image")) bytes += memory->usage(image,nmax); + if (atom->memcheck("x")) bytes += memory->usage(x,nmax,3); + if (atom->memcheck("v")) bytes += memory->usage(v,nmax,3); + if (atom->memcheck("f")) bytes += memory->usage(f,nmax,3); return bytes; } diff --git a/src/atom_vec_atomic.h b/src/atom_vec_atomic.h index af7de46d80..a0700a26d2 100644 --- a/src/atom_vec_atomic.h +++ b/src/atom_vec_atomic.h @@ -48,7 +48,7 @@ class AtomVecAtomic : public AtomVec { int unpack_restart(double *); void create_atom(int, double *); void data_atom(double *, int, char **); - double memory_usage(); + bigint memory_usage(); private: int *tag,*type,*mask,*image; diff --git a/src/atom_vec_charge.cpp b/src/atom_vec_charge.cpp index 4f92be8aed..85ff93d2b0 100644 --- a/src/atom_vec_charge.cpp +++ b/src/atom_vec_charge.cpp @@ -673,19 +673,19 @@ int AtomVecCharge::data_atom_hybrid(int nlocal, char **values) return # of bytes of allocated memory ------------------------------------------------------------------------- */ -double AtomVecCharge::memory_usage() +bigint AtomVecCharge::memory_usage() { - double bytes = 0.0; + bigint bytes = 0; - if (atom->memcheck("tag")) bytes += nmax * sizeof(int); - if (atom->memcheck("type")) bytes += nmax * sizeof(int); - if (atom->memcheck("mask")) bytes += nmax * sizeof(int); - if (atom->memcheck("image")) bytes += nmax * sizeof(int); - if (atom->memcheck("x")) bytes += nmax*3 * sizeof(double); - if (atom->memcheck("v")) bytes += nmax*3 * sizeof(double); - if (atom->memcheck("f")) bytes += nmax*3 * sizeof(double); + if (atom->memcheck("tag")) bytes += memory->usage(tag,nmax); + if (atom->memcheck("type")) bytes += memory->usage(type,nmax); + if (atom->memcheck("mask")) bytes += memory->usage(mask,nmax); + if (atom->memcheck("image")) bytes += memory->usage(image,nmax); + if (atom->memcheck("x")) bytes += memory->usage(x,nmax,3); + if (atom->memcheck("v")) bytes += memory->usage(v,nmax,3); + if (atom->memcheck("f")) bytes += memory->usage(f,nmax,3); - if (atom->memcheck("q")) bytes += nmax * sizeof(double); + if (atom->memcheck("q")) bytes += memory->usage(q,nmax); return bytes; } diff --git a/src/atom_vec_charge.h b/src/atom_vec_charge.h index 20a1cd221c..80786edc48 100644 --- a/src/atom_vec_charge.h +++ b/src/atom_vec_charge.h @@ -50,7 +50,7 @@ class AtomVecCharge : public AtomVec { void create_atom(int, double *); void data_atom(double *, int, char **); int data_atom_hybrid(int, char **); - double memory_usage(); + bigint memory_usage(); private: int *tag,*type,*mask,*image; diff --git a/src/atom_vec_hybrid.cpp b/src/atom_vec_hybrid.cpp index ef5808adb3..3e2cdac656 100644 --- a/src/atom_vec_hybrid.cpp +++ b/src/atom_vec_hybrid.cpp @@ -842,9 +842,9 @@ void AtomVecHybrid::data_vel(int m, char **values) return # of bytes of allocated memory ------------------------------------------------------------------------- */ -double AtomVecHybrid::memory_usage() +bigint AtomVecHybrid::memory_usage() { - double bytes = 0.0; + bigint bytes = 0; for (int k = 0; k < nstyles; k++) bytes += styles[k]->memory_usage(); return bytes; } diff --git a/src/atom_vec_hybrid.h b/src/atom_vec_hybrid.h index 20114856eb..08f03c3612 100644 --- a/src/atom_vec_hybrid.h +++ b/src/atom_vec_hybrid.h @@ -55,7 +55,7 @@ class AtomVecHybrid : public AtomVec { void data_atom(double *, int, char **); int data_atom_hybrid(int, char **) {return 0;} void data_vel(int, char **); - double memory_usage(); + bigint memory_usage(); private: int *tag,*type,*mask,*image; diff --git a/src/comm.cpp b/src/comm.cpp index 10f81b6042..975799f373 100644 --- a/src/comm.cpp +++ b/src/comm.cpp @@ -15,6 +15,7 @@ Contributing author (triclinic) : Pieter in 't Veld (SNL) ------------------------------------------------------------------------- */ +#include "lmptype.h" #include "mpi.h" #include "math.h" #include "string.h" @@ -75,11 +76,11 @@ Comm::Comm(LAMMPS *lmp) : Pointers(lmp) maxswap = 6; allocate_swap(maxswap); - sendlist = (int **) memory->smalloc(maxswap*sizeof(int *),"sendlist"); - memory->create(maxsendlist,maxswap,"maxsendlist"); + sendlist = (int **) memory->smalloc(maxswap*sizeof(int *),"comm:sendlist"); + maxsendlist = new int[maxswap]; for (int i = 0; i < maxswap; i++) { maxsendlist[i] = BUFMIN; - memory->create(sendlist[i],BUFMIN,"sendlist[i]"); + memory->create(sendlist[i],BUFMIN,"comm:sendlist[i]"); } maxforward_fix = maxreverse_fix = 0; @@ -98,9 +99,9 @@ Comm::~Comm() memory->destroy(cutghostmulti); } - memory->destroy(maxsendlist); if (sendlist) for (int i = 0; i < maxswap; i++) memory->destroy(sendlist[i]); memory->sfree(sendlist); + delete [] maxsendlist; memory->destroy(buf_send); memory->destroy(buf_recv); @@ -1280,13 +1281,12 @@ void Comm::set(int narg, char **arg) return # of bytes of allocated memory ------------------------------------------------------------------------- */ -double Comm::memory_usage() +bigint Comm::memory_usage() { - double bytes = 0.0; - - for (int i = 0; i < nswap; i++) bytes += maxsendlist[i] * sizeof(int); - bytes += maxsend * sizeof(double); - bytes += maxrecv * sizeof(double); - + bigint bytes = 0; + for (int i = 0; i < nswap; i++) + bytes += memory->usage(sendlist[i],maxsendlist[i]); + bytes += memory->usage(buf_send,maxsend+BUFEXTRA); + bytes += memory->usage(buf_recv,maxrecv); return bytes; } diff --git a/src/comm.h b/src/comm.h index 1a5ad647f0..11b7e28b8a 100644 --- a/src/comm.h +++ b/src/comm.h @@ -53,7 +53,7 @@ class Comm : protected Pointers { void reverse_comm_compute(class Compute *); // reverse comm from a Compute void set(int, char **); // set communication style - double memory_usage(); + bigint memory_usage(); private: int style; // single vs multi-type comm diff --git a/src/compute.h b/src/compute.h index f7ece5d38a..ceacee82ac 100644 --- a/src/compute.h +++ b/src/compute.h @@ -14,7 +14,6 @@ #ifndef LMP_COMPUTE_H #define LMP_COMPUTE_H -#include "lmptype.h" #include "pointers.h" namespace LAMMPS_NS { diff --git a/src/compute_reduce.h b/src/compute_reduce.h index 04ffd40c63..4cf8ee513b 100644 --- a/src/compute_reduce.h +++ b/src/compute_reduce.h @@ -20,7 +20,6 @@ ComputeStyle(reduce,ComputeReduce) #ifndef LMP_COMPUTE_REDUCE_H #define LMP_COMPUTE_REDUCE_H -#include "lmptype.h" #include "compute.h" namespace LAMMPS_NS { diff --git a/src/compute_reduce_region.h b/src/compute_reduce_region.h index a1b9ee1695..37abb3ea92 100644 --- a/src/compute_reduce_region.h +++ b/src/compute_reduce_region.h @@ -20,7 +20,6 @@ ComputeStyle(reduce/region,ComputeReduceRegion) #ifndef LMP_COMPUTE_REDUCE_REGION_H #define LMP_COMPUTE_REDUCE_REGION_H -#include "lmptype.h" #include "compute_reduce.h" namespace LAMMPS_NS { diff --git a/src/dump.cpp b/src/dump.cpp index 14a9e4288f..ed97abf1f1 100644 --- a/src/dump.cpp +++ b/src/dump.cpp @@ -710,15 +710,15 @@ void Dump::modify_params(int narg, char **arg) return # of bytes of allocated memory ------------------------------------------------------------------------- */ -double Dump::memory_usage() +bigint Dump::memory_usage() { - double bytes = maxbuf*size_one * sizeof(double); // buf + bigint bytes = memory->usage(buf,size_one*maxbuf); if (sort_flag) { - if (sortcol == 0) bytes += maxids * sizeof(int); // ids - bytes += maxsort*size_one * sizeof(double); // bufsort - if (sortcol == 0) bytes += maxsort * sizeof(int); // idsort - bytes += maxsort * sizeof(int); // index - bytes += maxproc * sizeof(int); // proclist + if (sortcol == 0) bytes += memory->usage(ids,maxids); + bytes += memory->usage(bufsort,size_one*maxsort); + if (sortcol == 0) bytes += memory->usage(idsort,maxsort); + bytes += memory->usage(index,maxsort); + bytes += memory->usage(proclist,maxproc); if (irregular) bytes += irregular->memory_usage(); } return bytes; diff --git a/src/dump.h b/src/dump.h index 1dd7a6e5a9..83001d79f9 100644 --- a/src/dump.h +++ b/src/dump.h @@ -14,7 +14,6 @@ #ifndef LMP_DUMP_H #define LMP_DUMP_H -#include "lmptype.h" #include "stdio.h" #include "pointers.h" @@ -38,7 +37,7 @@ class Dump : protected Pointers { void init(); virtual void write(); void modify_params(int, char **); - virtual double memory_usage(); + virtual bigint memory_usage(); protected: int me,nprocs; // proc info diff --git a/src/dump_custom.cpp b/src/dump_custom.cpp index 3e0b2c192f..665bdbcbfa 100644 --- a/src/dump_custom.cpp +++ b/src/dump_custom.cpp @@ -1456,12 +1456,12 @@ int DumpCustom::modify_param(int narg, char **arg) return # of bytes of allocated memory in buf, choose, variable arrays ------------------------------------------------------------------------- */ -double DumpCustom::memory_usage() +bigint DumpCustom::memory_usage() { - double bytes = Dump::memory_usage(); - bytes += maxlocal * sizeof(int); - bytes += maxlocal * sizeof(double); - bytes += maxlocal * nvariable * sizeof(double); + bigint bytes = Dump::memory_usage(); + bytes += memory->usage(choose,maxlocal); + bytes += memory->usage(dchoose,maxlocal); + bytes += memory->usage(vbuf,nvariable,maxlocal); return bytes; } diff --git a/src/dump_custom.h b/src/dump_custom.h index 0f7913272f..175629560d 100644 --- a/src/dump_custom.h +++ b/src/dump_custom.h @@ -74,7 +74,7 @@ class DumpCustom : public Dump { int count(); void pack(int *); virtual void write_data(int, double *); - double memory_usage(); + bigint memory_usage(); void parse_fields(int, char **); int add_compute(char *); diff --git a/src/dump_dcd.cpp b/src/dump_dcd.cpp index ebf9e72e91..9fc73a45bd 100644 --- a/src/dump_dcd.cpp +++ b/src/dump_dcd.cpp @@ -279,10 +279,10 @@ int DumpDCD::modify_param(int narg, char **arg) return # of bytes of allocated memory in buf and global coords array ------------------------------------------------------------------------- */ -double DumpDCD::memory_usage() +bigint DumpDCD::memory_usage() { - double bytes = Dump::memory_usage(); - bytes += 3*natoms * sizeof(float); + bigint bytes = Dump::memory_usage(); + bytes += memory->usage(coords,natoms*3); return bytes; } diff --git a/src/dump_dcd.h b/src/dump_dcd.h index c71f154acb..80598bd1dd 100644 --- a/src/dump_dcd.h +++ b/src/dump_dcd.h @@ -45,7 +45,7 @@ class DumpDCD : public Dump { void pack(int *); void write_data(int, double *); int modify_param(int, char **); - double memory_usage(); + bigint memory_usage(); void write_frame(); void write_dcd_header(const char *); diff --git a/src/fix.h b/src/fix.h index 4cd938e05b..1d5910969c 100644 --- a/src/fix.h +++ b/src/fix.h @@ -14,7 +14,6 @@ #ifndef LMP_FIX_H #define LMP_FIX_H -#include "lmptype.h" #include "pointers.h" namespace LAMMPS_NS { diff --git a/src/fix_ave_atom.h b/src/fix_ave_atom.h index 790b6252fd..1995134f6a 100644 --- a/src/fix_ave_atom.h +++ b/src/fix_ave_atom.h @@ -20,7 +20,6 @@ FixStyle(ave/atom,FixAveAtom) #ifndef LMP_FIX_AVE_ATOM_H #define LMP_FIX_AVE_ATOM_H -#include "lmptype.h" #include "stdio.h" #include "fix.h" diff --git a/src/fix_ave_correlate.h b/src/fix_ave_correlate.h index ea8a5cb4ef..91f2491a08 100644 --- a/src/fix_ave_correlate.h +++ b/src/fix_ave_correlate.h @@ -20,7 +20,6 @@ FixStyle(ave/correlate,FixAveCorrelate) #ifndef LMP_FIX_AVE_CORRELATE_H #define LMP_FIX_AVE_CORRELATE_H -#include "lmptype.h" #include "stdio.h" #include "fix.h" diff --git a/src/fix_ave_histo.h b/src/fix_ave_histo.h index c2c8702233..f365423109 100644 --- a/src/fix_ave_histo.h +++ b/src/fix_ave_histo.h @@ -20,7 +20,6 @@ FixStyle(ave/histo,FixAveHisto) #ifndef LMP_FIX_AVE_HISTO_H #define LMP_FIX_AVE_HISTO_H -#include "lmptype.h" #include "stdio.h" #include "fix.h" diff --git a/src/fix_ave_spatial.h b/src/fix_ave_spatial.h index 80dcee0049..fcf1bf0224 100644 --- a/src/fix_ave_spatial.h +++ b/src/fix_ave_spatial.h @@ -20,7 +20,6 @@ FixStyle(ave/spatial,FixAveSpatial) #ifndef LMP_FIX_AVE_SPATIAL_H #define LMP_FIX_AVE_SPATIAL_H -#include "lmptype.h" #include "stdio.h" #include "fix.h" diff --git a/src/fix_ave_time.h b/src/fix_ave_time.h index fafd21e509..b59c2c3124 100644 --- a/src/fix_ave_time.h +++ b/src/fix_ave_time.h @@ -20,7 +20,6 @@ FixStyle(ave/time,FixAveTime) #ifndef LMP_FIX_AVE_TIME_H #define LMP_FIX_AVE_TIME_H -#include "lmptype.h" #include "stdio.h" #include "fix.h" diff --git a/src/fix_dt_reset.h b/src/fix_dt_reset.h index 095f8c9cac..956d35d1b4 100644 --- a/src/fix_dt_reset.h +++ b/src/fix_dt_reset.h @@ -20,7 +20,6 @@ FixStyle(dt/reset,FixDtReset) #ifndef LMP_FIX_DT_RESET_H #define LMP_FIX_DT_RESET_H -#include "lmptype.h" #include "fix.h" namespace LAMMPS_NS { diff --git a/src/fix_shake.h b/src/fix_shake.h index ef061dc9df..eaf39837cb 100644 --- a/src/fix_shake.h +++ b/src/fix_shake.h @@ -20,7 +20,6 @@ FixStyle(shake,FixShake) #ifndef LMP_FIX_SHAKE_H #define LMP_FIX_SHAKE_H -#include "lmptype.h" #include "fix.h" namespace LAMMPS_NS { diff --git a/src/force.cpp b/src/force.cpp index f70d67413e..a53ac9e25e 100644 --- a/src/force.cpp +++ b/src/force.cpp @@ -11,6 +11,7 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ +#include "lmptype.h" #include "stdlib.h" #include "string.h" #include "ctype.h" @@ -523,14 +524,14 @@ int Force::inumeric(char *str) memory usage of force classes ------------------------------------------------------------------------- */ -double Force::memory_usage() +bigint Force::memory_usage() { - double bytes = 0.0; - if (pair) bytes += pair->memory_usage(); - if (bond) bytes += bond->memory_usage(); - if (angle) bytes += angle->memory_usage(); - if (dihedral) bytes += dihedral->memory_usage(); - if (improper) bytes += improper->memory_usage(); - if (kspace) bytes += kspace->memory_usage(); + bigint bytes = 0; + if (pair) bytes += static_cast (pair->memory_usage()); + if (bond) bytes += static_cast (bond->memory_usage()); + if (angle) bytes += static_cast (angle->memory_usage()); + if (dihedral) bytes += static_cast (dihedral->memory_usage()); + if (improper) bytes += static_cast (improper->memory_usage()); + if (kspace) bytes += static_cast (kspace->memory_usage()); return bytes; } diff --git a/src/force.h b/src/force.h index ef874845f6..ee6343db98 100644 --- a/src/force.h +++ b/src/force.h @@ -87,7 +87,7 @@ class Force : protected Pointers { void bounds(char *, int, int &, int &); double numeric(char *); int inumeric(char *); - double memory_usage(); + bigint memory_usage(); }; } diff --git a/src/group.h b/src/group.h index 9621aa850f..da9e2e0c4f 100644 --- a/src/group.h +++ b/src/group.h @@ -14,7 +14,6 @@ #ifndef LMP_GROUP_H #define LMP_GROUP_H -#include "lmptype.h" #include "stdio.h" #include "pointers.h" diff --git a/src/integrate.h b/src/integrate.h index d869ceac23..8f8942c80c 100644 --- a/src/integrate.h +++ b/src/integrate.h @@ -14,7 +14,6 @@ #ifndef LMP_INTEGRATE_H #define LMP_INTEGRATE_H -#include "lmptype.h" #include "pointers.h" namespace LAMMPS_NS { @@ -29,7 +28,7 @@ class Integrate : protected Pointers { virtual void run(int) = 0; virtual void cleanup() {} virtual void reset_dt() {} - virtual double memory_usage() {return 0.0;} + virtual bigint memory_usage() {return 0;} protected: int eflag,vflag; // flags for energy/virial computation diff --git a/src/irregular.cpp b/src/irregular.cpp index 37af76759c..86258026ea 100644 --- a/src/irregular.cpp +++ b/src/irregular.cpp @@ -11,6 +11,7 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ +#include "lmptype.h" #include "mpi.h" #include "stdlib.h" #include "string.h" @@ -673,9 +674,9 @@ void Irregular::grow_recv(int n) return # of bytes of allocated memory ------------------------------------------------------------------------- */ -double Irregular::memory_usage() +bigint Irregular::memory_usage() { - double bytes = maxsend * sizeof(double); - bytes += maxrecv * sizeof(double); + bigint bytes = memory->usage(buf_send,maxsend); + bytes += memory->usage(buf_recv,maxrecv); return bytes; } diff --git a/src/irregular.h b/src/irregular.h index f535e10527..ccd317f2e8 100644 --- a/src/irregular.h +++ b/src/irregular.h @@ -26,7 +26,7 @@ class Irregular : protected Pointers { int create_data(int, int *); void exchange_data(char *, int, char *); void destroy_data(); - double memory_usage(); + bigint memory_usage(); private: int me,nprocs; diff --git a/src/lammps.h b/src/lammps.h index 862d587778..1c3f81600e 100644 --- a/src/lammps.h +++ b/src/lammps.h @@ -14,7 +14,6 @@ #ifndef LMP_LAMMPS_H #define LMP_LAMMPS_H -#include "mpi.h" #include "stdio.h" namespace LAMMPS_NS { diff --git a/src/memory.h b/src/memory.h index 3a2a90775c..bf8bd642b3 100644 --- a/src/memory.h +++ b/src/memory.h @@ -14,7 +14,6 @@ #ifndef LMP_MEMORY_H #define LMP_MEMORY_H -#include "lmptype.h" #include "pointers.h" namespace LAMMPS_NS { @@ -68,8 +67,9 @@ class Memory : protected Pointers { /* ---------------------------------------------------------------------- - NOTE: to avoid code bloat, only use these for int,double,float,char - otherwise, just use smalloc,srealloc,sfree + to avoid code bloat, only use these for int,double,float,char + not for int* or double** or arbitrary structs + in those cases, just use smalloc,srealloc,sfree directly ------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- @@ -397,6 +397,44 @@ class Memory : protected Pointers { sfree_new(array[0]); sfree_new(array); } + +/* ---------------------------------------------------------------------- + memory usage of arrays, including pointers +------------------------------------------------------------------------- */ + + template + bigint usage(TYPE *array, int n) + { + bigint bytes = sizeof(TYPE) * n; + return bytes; + } + + template + bigint usage(TYPE **array, int n1, int n2) + { + bigint bytes = sizeof(TYPE) * n1*n2; + bytes += sizeof(TYPE *) * n1; + return bytes; + } + + template + bigint usage(TYPE ***array, int n1, int n2, int n3) + { + bigint bytes = sizeof(TYPE) * n1*n2*n3; + bytes += sizeof(TYPE *) * n1*n2; + bytes += sizeof(TYPE **) * n1; + return bytes; + } + + template + bigint usage(TYPE ****array, int n1, int n2, int n3, int n4) + { + bigint bytes = sizeof(TYPE) * n1*n2*n3*n4; + bytes += sizeof(TYPE *) * n1*n2*n3; + bytes += sizeof(TYPE **) * n1*n2; + bytes += sizeof(TYPE ***) * n1; + return bytes; + } }; } diff --git a/src/min.h b/src/min.h index de0d596c37..db9590b1b2 100644 --- a/src/min.h +++ b/src/min.h @@ -14,7 +14,6 @@ #ifndef LMP_MIN_H #define LMP_MIN_H -#include "lmptype.h" #include "pointers.h" namespace LAMMPS_NS { @@ -37,7 +36,7 @@ class Min : protected Pointers { void run(int); void cleanup(); int request(class Pair *, int, double); - double memory_usage() {return 0.0;} + virtual bigint memory_usage() {return 0;} void modify_params(int, char **); double fnorm_sqr(); double fnorm_inf(); diff --git a/src/modify.cpp b/src/modify.cpp index 99cb49cf17..d4e9cb3999 100644 --- a/src/modify.cpp +++ b/src/modify.cpp @@ -11,6 +11,7 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ +#include "lmptype.h" #include "stdio.h" #include "string.h" #include "modify.h" @@ -1102,10 +1103,12 @@ void Modify::list_init_compute() return # of bytes of allocated memory from all fixes ------------------------------------------------------------------------- */ -double Modify::memory_usage() +bigint Modify::memory_usage() { - double bytes = 0.0; - for (int i = 0; i < nfix; i++) bytes += fix[i]->memory_usage(); - for (int i = 0; i < ncompute; i++) bytes += compute[i]->memory_usage(); + bigint bytes = 0; + for (int i = 0; i < nfix; i++) + bytes += static_cast (fix[i]->memory_usage()); + for (int i = 0; i < ncompute; i++) + bytes += static_cast (compute[i]->memory_usage()); return bytes; } diff --git a/src/modify.h b/src/modify.h index 56d94d63b9..01a32431ce 100644 --- a/src/modify.h +++ b/src/modify.h @@ -14,7 +14,6 @@ #ifndef LMP_MODIFY_H #define LMP_MODIFY_H -#include "lmptype.h" #include "stdio.h" #include "pointers.h" @@ -96,7 +95,7 @@ class Modify : protected Pointers { int read_restart(FILE *); void restart_deallocate(); - double memory_usage(); + bigint memory_usage(); private: diff --git a/src/neigh_list.cpp b/src/neigh_list.cpp index c5bd04b3f7..6eda7d474e 100644 --- a/src/neigh_list.cpp +++ b/src/neigh_list.cpp @@ -11,6 +11,7 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ +#include "lmptype.h" #include "neigh_list.h" #include "atom.h" #include "comm.h" @@ -136,7 +137,7 @@ void NeighList::stencil_allocate(int smax, int style) if (smax > maxstencil) { maxstencil = smax; memory->destroy(stencil); - memory->create(stencil,smax,"neighlist:stencil"); + memory->create(stencil,maxstencil,"neighlist:stencil"); } } else { @@ -156,8 +157,10 @@ void NeighList::stencil_allocate(int smax, int style) for (i = 1; i <= n; i++) { memory->destroy(stencil_multi[i]); memory->destroy(distsq_multi[i]); - memory->create(stencil_multi[i],smax,"neighlist:stencil_multi"); - memory->create(distsq_multi[i],smax,"neighlist:distsq_multi"); + memory->create(stencil_multi[i],maxstencil_multi, + "neighlist:stencil_multi"); + memory->create(distsq_multi[i],maxstencil_multi, + "neighlist:distsq_multi"); } } } @@ -247,22 +250,23 @@ void NeighList::print_attributes() if stencilflag = 0, maxstencil * maxstencil_multi will also be 0 ------------------------------------------------------------------------- */ -double NeighList::memory_usage() +bigint NeighList::memory_usage() { - double bytes = 0.0; - bytes += 2 * maxlocal * sizeof(int); + bigint bytes = 0; + bytes += memory->usage(ilist,maxlocal); + bytes += memory->usage(numneigh,maxlocal); bytes += maxlocal * sizeof(int *); - bytes += maxpage*pgsize * sizeof(int); + bytes += memory->usage(pages,maxpage,pgsize); if (dnum) { bytes += maxlocal * sizeof(double *); - bytes += dnum * maxpage*pgsize * sizeof(double); + bytes += memory->usage(dpages,maxpage,dnum*pgsize); } - if (maxstencil) bytes += maxstencil * sizeof(int); + if (maxstencil) bytes += memory->usage(stencil,maxstencil); if (maxstencil_multi) { - bytes += atom->ntypes * maxstencil_multi * sizeof(int); - bytes += atom->ntypes * maxstencil_multi * sizeof(double); + bytes += memory->usage(stencil_multi,atom->ntypes,maxstencil_multi); + bytes += memory->usage(distsq_multi,atom->ntypes,maxstencil_multi); } return bytes; diff --git a/src/neigh_list.h b/src/neigh_list.h index 67ef125dc7..4f14f9c020 100644 --- a/src/neigh_list.h +++ b/src/neigh_list.h @@ -77,7 +77,7 @@ class NeighList : protected Pointers { int **add_pages(); // add pages to neigh list void copy_skip_info(int *, int **); // copy skip info from a neigh request void print_attributes(); // debug routine - double memory_usage(); + bigint memory_usage(); private: int maxlocal; // size of allocated atom arrays diff --git a/src/neighbor.cpp b/src/neighbor.cpp index 76ec425b72..cf5dad179c 100644 --- a/src/neighbor.cpp +++ b/src/neighbor.cpp @@ -1645,22 +1645,22 @@ int Neighbor::exclusion(int i, int j, int itype, int jtype, return # of bytes of allocated memory ------------------------------------------------------------------------- */ -double Neighbor::memory_usage() +bigint Neighbor::memory_usage() { - double bytes = 0.0; - bytes += maxhold*3 * sizeof(double); + bigint bytes = 0; + bytes += memory->usage(xhold,maxhold,3); if (style != NSQ) { - bytes += maxbin * sizeof(int); - bytes += maxhead * sizeof(int); + bytes += memory->usage(bins,maxbin); + bytes += memory->usage(binhead,maxhead); } for (int i = 0; i < nlist; i++) bytes += lists[i]->memory_usage(); - bytes += maxbond*3 * sizeof(int); - bytes += maxangle*4 * sizeof(int); - bytes += maxdihedral*5 * sizeof(int); - bytes += maximproper*5 * sizeof(int); + bytes += memory->usage(bondlist,maxbond,3); + bytes += memory->usage(anglelist,maxangle,4); + bytes += memory->usage(dihedrallist,maxdihedral,5); + bytes += memory->usage(improperlist,maximproper,5); return bytes; } diff --git a/src/neighbor.h b/src/neighbor.h index 2e45476f92..71995d30a2 100644 --- a/src/neighbor.h +++ b/src/neighbor.h @@ -71,7 +71,7 @@ class Neighbor : protected Pointers { void build_one(int); // create a single neighbor list void set(int, char **); // set neighbor style and skin distance void modify_params(int, char**); // modify parameters that control builds - double memory_usage(); + bigint memory_usage(); private: int me,nprocs; diff --git a/src/output.cpp b/src/output.cpp index 97de70438a..0d5a280ac3 100644 --- a/src/output.cpp +++ b/src/output.cpp @@ -517,19 +517,19 @@ void Output::create_restart(int narg, char **arg) /* ---------------------------------------------------------------------- sum and print memory usage - is only memory on proc 0, not averaged across procs + result is only memory on proc 0, not averaged across procs ------------------------------------------------------------------------- */ void Output::memory_usage() { - double bytes = 0.0; + bigint bytes = 0; bytes += atom->memory_usage(); bytes += neighbor->memory_usage(); bytes += comm->memory_usage(); bytes += update->memory_usage(); bytes += force->memory_usage(); bytes += modify->memory_usage(); - for (int i = 0; i < ndump; i++) bytes += dump[i]->memory_usage(); + for (int i = 0; i < ndump; i++) dump[i]->memory_usage(); double mbytes = bytes/1024.0/1024.0; diff --git a/src/output.h b/src/output.h index d8ce61e529..735cd28f30 100644 --- a/src/output.h +++ b/src/output.h @@ -14,7 +14,6 @@ #ifndef LMP_OUTPUT_H #define LMP_OUTPUT_H -#include "lmptype.h" #include "pointers.h" namespace LAMMPS_NS { diff --git a/src/pointers.h b/src/pointers.h index 1824a3f0b9..59afc88139 100644 --- a/src/pointers.h +++ b/src/pointers.h @@ -21,6 +21,7 @@ #ifndef LMP_POINTERS_H #define LMP_POINTERS_H +#include "lmptype.h" #include "mpi.h" #include "lammps.h" diff --git a/src/read_restart.h b/src/read_restart.h index 16d2e675d5..162fb085fe 100644 --- a/src/read_restart.h +++ b/src/read_restart.h @@ -20,7 +20,6 @@ CommandStyle(read_restart,ReadRestart) #ifndef LMP_READ_RESTART_H #define LMP_READ_RESTART_H -#include "lmptype.h" #include "stdio.h" #include "pointers.h" diff --git a/src/region.h b/src/region.h index e32d7ff1c7..c0b55daa1c 100644 --- a/src/region.h +++ b/src/region.h @@ -14,7 +14,6 @@ #ifndef LMP_REGION_H #define LMP_REGION_H -#include "lmptype.h" #include "pointers.h" namespace LAMMPS_NS { diff --git a/src/respa.cpp b/src/respa.cpp index cb3425b135..806c7bea44 100644 --- a/src/respa.cpp +++ b/src/respa.cpp @@ -35,8 +35,8 @@ #include "modify.h" #include "compute.h" #include "fix_respa.h" -#include "memory.h" #include "timer.h" +#include "memory.h" #include "error.h" using namespace LAMMPS_NS; diff --git a/src/thermo.h b/src/thermo.h index 0d000b0e12..9b9133c6a6 100644 --- a/src/thermo.h +++ b/src/thermo.h @@ -14,7 +14,6 @@ #ifndef LMP_THERMO_H #define LMP_THERMO_H -#include "lmptype.h" #include "pointers.h" namespace LAMMPS_NS { diff --git a/src/universe.h b/src/universe.h index ab508af37c..e90984f511 100644 --- a/src/universe.h +++ b/src/universe.h @@ -14,7 +14,6 @@ #ifndef LMP_UNIVERSE_H #define LMP_UNIVERSE_H -#include "mpi.h" #include "stdio.h" #include "pointers.h" diff --git a/src/update.cpp b/src/update.cpp index 9a2214474c..c6b135eec6 100644 --- a/src/update.cpp +++ b/src/update.cpp @@ -11,6 +11,7 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ +#include "lmptype.h" #include "string.h" #include "stdlib.h" #include "update.h" @@ -287,9 +288,9 @@ void Update::reset_timestep(int narg, char **arg) memory usage of update and integrate/minimize ------------------------------------------------------------------------- */ -double Update::memory_usage() +bigint Update::memory_usage() { - double bytes = 0.0; + bigint bytes = 0; if (whichflag == 1) bytes += integrate->memory_usage(); else if (whichflag == 2) bytes += minimize->memory_usage(); return bytes; diff --git a/src/update.h b/src/update.h index b713c4c113..bde3512457 100644 --- a/src/update.h +++ b/src/update.h @@ -14,7 +14,6 @@ #ifndef LMP_UPDATE_H #define LMP_UPDATE_H -#include "lmptype.h" #include "pointers.h" namespace LAMMPS_NS { @@ -52,7 +51,7 @@ class Update : protected Pointers { void create_integrate(int, char **); void create_minimize(int, char **); void reset_timestep(int, char **); - double memory_usage(); + bigint memory_usage(); }; } diff --git a/src/write_restart.h b/src/write_restart.h index 8a849e8256..33bb164bfb 100644 --- a/src/write_restart.h +++ b/src/write_restart.h @@ -20,7 +20,6 @@ CommandStyle(write_restart,WriteRestart) #ifndef LMP_WRITE_RESTART_H #define LMP_WRITE_RESTART_H -#include "lmptype.h" #include "stdio.h" #include "pointers.h"