diff --git a/doc/src/pg_lib_properties.rst b/doc/src/pg_lib_properties.rst index 65ce9cf940..256ed1cf82 100644 --- a/doc/src/pg_lib_properties.rst +++ b/doc/src/pg_lib_properties.rst @@ -49,6 +49,11 @@ event as atoms are migrating between sub-domains. ----------------------- +.. doxygenfunction:: lammps_memory_usage + :project: progguide + +----------------------- + .. doxygenfunction:: lammps_get_mpi_comm :project: progguide diff --git a/src/KOKKOS/atom_vec_angle_kokkos.cpp b/src/KOKKOS/atom_vec_angle_kokkos.cpp index 662f09fe5a..ccb23064ed 100644 --- a/src/KOKKOS/atom_vec_angle_kokkos.cpp +++ b/src/KOKKOS/atom_vec_angle_kokkos.cpp @@ -1724,9 +1724,9 @@ int AtomVecAngleKokkos::write_data_hybrid(FILE *fp, double *buf) return # of bytes of allocated memory ------------------------------------------------------------------------- */ -bigint AtomVecAngleKokkos::memory_usage() +double AtomVecAngleKokkos::memory_usage() { - bigint bytes = 0; + double bytes = 0; if (atom->memcheck("tag")) bytes += memory->usage(tag,nmax); if (atom->memcheck("type")) bytes += memory->usage(type,nmax); diff --git a/src/KOKKOS/atom_vec_angle_kokkos.h b/src/KOKKOS/atom_vec_angle_kokkos.h index 4fc71725b0..29b5ce8fc5 100644 --- a/src/KOKKOS/atom_vec_angle_kokkos.h +++ b/src/KOKKOS/atom_vec_angle_kokkos.h @@ -56,7 +56,7 @@ class AtomVecAngleKokkos : public AtomVecKokkos { int pack_data_hybrid(int, double *); void write_data(FILE *, int, double **); int write_data_hybrid(FILE *, double *); - bigint memory_usage(); + double memory_usage(); void grow_pointers(); int pack_comm_kokkos(const int &n, const DAT::tdual_int_2d &k_sendlist, diff --git a/src/KOKKOS/atom_vec_atomic_kokkos.cpp b/src/KOKKOS/atom_vec_atomic_kokkos.cpp index 995985b29d..e4a5f62c2c 100644 --- a/src/KOKKOS/atom_vec_atomic_kokkos.cpp +++ b/src/KOKKOS/atom_vec_atomic_kokkos.cpp @@ -879,9 +879,9 @@ void AtomVecAtomicKokkos::write_data(FILE *fp, int n, double **buf) return # of bytes of allocated memory ------------------------------------------------------------------------- */ -bigint AtomVecAtomicKokkos::memory_usage() +double AtomVecAtomicKokkos::memory_usage() { - bigint bytes = 0; + double bytes = 0; if (atom->memcheck("tag")) bytes += memory->usage(tag,nmax); if (atom->memcheck("type")) bytes += memory->usage(type,nmax); diff --git a/src/KOKKOS/atom_vec_atomic_kokkos.h b/src/KOKKOS/atom_vec_atomic_kokkos.h index 212132ef60..2c682d4989 100644 --- a/src/KOKKOS/atom_vec_atomic_kokkos.h +++ b/src/KOKKOS/atom_vec_atomic_kokkos.h @@ -46,7 +46,7 @@ class AtomVecAtomicKokkos : public AtomVecKokkos { void data_atom(double *, tagint, char **); void pack_data(double **); void write_data(FILE *, int, double **); - bigint memory_usage(); + double memory_usage(); void grow_pointers(); int pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, diff --git a/src/KOKKOS/atom_vec_bond_kokkos.cpp b/src/KOKKOS/atom_vec_bond_kokkos.cpp index db56d58dff..b5a69f6fcb 100644 --- a/src/KOKKOS/atom_vec_bond_kokkos.cpp +++ b/src/KOKKOS/atom_vec_bond_kokkos.cpp @@ -1148,9 +1148,9 @@ int AtomVecBondKokkos::write_data_hybrid(FILE *fp, double *buf) return # of bytes of allocated memory ------------------------------------------------------------------------- */ -bigint AtomVecBondKokkos::memory_usage() +double AtomVecBondKokkos::memory_usage() { - bigint bytes = 0; + double bytes = 0; if (atom->memcheck("tag")) bytes += memory->usage(tag,nmax); if (atom->memcheck("type")) bytes += memory->usage(type,nmax); diff --git a/src/KOKKOS/atom_vec_bond_kokkos.h b/src/KOKKOS/atom_vec_bond_kokkos.h index f38ade8f64..7f4d04c037 100644 --- a/src/KOKKOS/atom_vec_bond_kokkos.h +++ b/src/KOKKOS/atom_vec_bond_kokkos.h @@ -50,7 +50,7 @@ class AtomVecBondKokkos : public AtomVecKokkos { int pack_data_hybrid(int, double *); void write_data(FILE *, int, double **); int write_data_hybrid(FILE *, double *); - bigint memory_usage(); + double memory_usage(); void grow_pointers(); int pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, diff --git a/src/KOKKOS/atom_vec_charge_kokkos.cpp b/src/KOKKOS/atom_vec_charge_kokkos.cpp index 9846d2f4f8..ce0751cb4f 100644 --- a/src/KOKKOS/atom_vec_charge_kokkos.cpp +++ b/src/KOKKOS/atom_vec_charge_kokkos.cpp @@ -1048,9 +1048,9 @@ int AtomVecChargeKokkos::write_data_hybrid(FILE *fp, double *buf) return # of bytes of allocated memory ------------------------------------------------------------------------- */ -bigint AtomVecChargeKokkos::memory_usage() +double AtomVecChargeKokkos::memory_usage() { - bigint bytes = 0; + double bytes = 0; if (atom->memcheck("tag")) bytes += memory->usage(tag,nmax); if (atom->memcheck("type")) bytes += memory->usage(type,nmax); diff --git a/src/KOKKOS/atom_vec_charge_kokkos.h b/src/KOKKOS/atom_vec_charge_kokkos.h index 39d641b844..4d61b2a69c 100644 --- a/src/KOKKOS/atom_vec_charge_kokkos.h +++ b/src/KOKKOS/atom_vec_charge_kokkos.h @@ -51,7 +51,7 @@ class AtomVecChargeKokkos : public AtomVecKokkos { int pack_data_hybrid(int, double *); void write_data(FILE *, int, double **); int write_data_hybrid(FILE *, double *); - bigint memory_usage(); + double memory_usage(); void grow_pointers(); int pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, diff --git a/src/KOKKOS/atom_vec_dpd_kokkos.cpp b/src/KOKKOS/atom_vec_dpd_kokkos.cpp index b112605859..70bd9e5827 100644 --- a/src/KOKKOS/atom_vec_dpd_kokkos.cpp +++ b/src/KOKKOS/atom_vec_dpd_kokkos.cpp @@ -1830,9 +1830,9 @@ int AtomVecDPDKokkos::write_data_hybrid(FILE *fp, double *buf) return # of bytes of allocated memory ------------------------------------------------------------------------- */ -bigint AtomVecDPDKokkos::memory_usage() +double AtomVecDPDKokkos::memory_usage() { - bigint bytes = 0; + double bytes = 0; if (atom->memcheck("tag")) bytes += memory->usage(tag,nmax); if (atom->memcheck("type")) bytes += memory->usage(type,nmax); diff --git a/src/KOKKOS/atom_vec_dpd_kokkos.h b/src/KOKKOS/atom_vec_dpd_kokkos.h index e969a28cb8..71b0c85590 100644 --- a/src/KOKKOS/atom_vec_dpd_kokkos.h +++ b/src/KOKKOS/atom_vec_dpd_kokkos.h @@ -59,7 +59,7 @@ class AtomVecDPDKokkos : public AtomVecKokkos { int pack_data_hybrid(int, double *); void write_data(FILE *, int, double **); int write_data_hybrid(FILE *, double *); - bigint memory_usage(); + double memory_usage(); void grow_pointers(); int pack_comm_kokkos(const int &n, const DAT::tdual_int_2d &k_sendlist, diff --git a/src/KOKKOS/atom_vec_full_kokkos.cpp b/src/KOKKOS/atom_vec_full_kokkos.cpp index 89275c7067..e6f36d9994 100644 --- a/src/KOKKOS/atom_vec_full_kokkos.cpp +++ b/src/KOKKOS/atom_vec_full_kokkos.cpp @@ -1588,9 +1588,9 @@ int AtomVecFullKokkos::write_data_hybrid(FILE *fp, double *buf) return # of bytes of allocated memory ------------------------------------------------------------------------- */ -bigint AtomVecFullKokkos::memory_usage() +double AtomVecFullKokkos::memory_usage() { - bigint bytes = 0; + double bytes = 0; if (atom->memcheck("tag")) bytes += memory->usage(tag,nmax); if (atom->memcheck("type")) bytes += memory->usage(type,nmax); diff --git a/src/KOKKOS/atom_vec_full_kokkos.h b/src/KOKKOS/atom_vec_full_kokkos.h index a2d4fa9cf4..4a5a61e913 100644 --- a/src/KOKKOS/atom_vec_full_kokkos.h +++ b/src/KOKKOS/atom_vec_full_kokkos.h @@ -50,7 +50,7 @@ class AtomVecFullKokkos : public AtomVecKokkos { int pack_data_hybrid(int, double *); void write_data(FILE *, int, double **); int write_data_hybrid(FILE *, double *); - bigint memory_usage(); + double memory_usage(); void grow_pointers(); int pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, diff --git a/src/KOKKOS/atom_vec_hybrid_kokkos.cpp b/src/KOKKOS/atom_vec_hybrid_kokkos.cpp index 7c7f3c9826..baa7777907 100644 --- a/src/KOKKOS/atom_vec_hybrid_kokkos.cpp +++ b/src/KOKKOS/atom_vec_hybrid_kokkos.cpp @@ -1198,9 +1198,9 @@ int AtomVecHybridKokkos::known_style(char *str) return # of bytes of allocated memory ------------------------------------------------------------------------- */ -bigint AtomVecHybridKokkos::memory_usage() +double AtomVecHybridKokkos::memory_usage() { - bigint bytes = 0; + double bytes = 0; for (int k = 0; k < nstyles; k++) bytes += styles[k]->memory_usage(); return bytes; } diff --git a/src/KOKKOS/atom_vec_hybrid_kokkos.h b/src/KOKKOS/atom_vec_hybrid_kokkos.h index 02f9044d73..3354735bf7 100644 --- a/src/KOKKOS/atom_vec_hybrid_kokkos.h +++ b/src/KOKKOS/atom_vec_hybrid_kokkos.h @@ -65,7 +65,7 @@ class AtomVecHybridKokkos : public AtomVecKokkos { void write_vel(FILE *, int, double **); int property_atom(char *); void pack_property_atom(int, double *, int, int); - bigint memory_usage(); + double memory_usage(); int pack_comm_kokkos(const int &n, const DAT::tdual_int_2d &k_sendlist, const int & iswap, diff --git a/src/KOKKOS/atom_vec_molecular_kokkos.cpp b/src/KOKKOS/atom_vec_molecular_kokkos.cpp index 7e3cdbf5e3..ab29024438 100644 --- a/src/KOKKOS/atom_vec_molecular_kokkos.cpp +++ b/src/KOKKOS/atom_vec_molecular_kokkos.cpp @@ -1987,9 +1987,9 @@ int AtomVecMolecularKokkos::write_data_hybrid(FILE *fp, double *buf) return # of bytes of allocated memory ------------------------------------------------------------------------- */ -bigint AtomVecMolecularKokkos::memory_usage() +double AtomVecMolecularKokkos::memory_usage() { - bigint bytes = 0; + double bytes = 0; if (atom->memcheck("tag")) bytes += memory->usage(tag,nmax); if (atom->memcheck("type")) bytes += memory->usage(type,nmax); diff --git a/src/KOKKOS/atom_vec_molecular_kokkos.h b/src/KOKKOS/atom_vec_molecular_kokkos.h index cede4f42a8..a356c6821c 100644 --- a/src/KOKKOS/atom_vec_molecular_kokkos.h +++ b/src/KOKKOS/atom_vec_molecular_kokkos.h @@ -56,7 +56,7 @@ class AtomVecMolecularKokkos : public AtomVecKokkos { int pack_data_hybrid(int, double *); void write_data(FILE *, int, double **); int write_data_hybrid(FILE *, double *); - bigint memory_usage(); + double memory_usage(); void grow_pointers(); int pack_comm_kokkos(const int &n, const DAT::tdual_int_2d &k_sendlist, diff --git a/src/KOKKOS/atom_vec_sphere_kokkos.cpp b/src/KOKKOS/atom_vec_sphere_kokkos.cpp index 6b62014e4a..dfae7fa547 100644 --- a/src/KOKKOS/atom_vec_sphere_kokkos.cpp +++ b/src/KOKKOS/atom_vec_sphere_kokkos.cpp @@ -2765,9 +2765,9 @@ int AtomVecSphereKokkos::write_vel_hybrid(FILE *fp, double *buf) return # of bytes of allocated memory ------------------------------------------------------------------------- */ -bigint AtomVecSphereKokkos::memory_usage() +double AtomVecSphereKokkos::memory_usage() { - bigint bytes = 0; + double bytes = 0; if (atom->memcheck("tag")) bytes += memory->usage(tag,nmax); if (atom->memcheck("type")) bytes += memory->usage(type,nmax); diff --git a/src/KOKKOS/atom_vec_sphere_kokkos.h b/src/KOKKOS/atom_vec_sphere_kokkos.h index 3f6d34e8b2..676df431d1 100644 --- a/src/KOKKOS/atom_vec_sphere_kokkos.h +++ b/src/KOKKOS/atom_vec_sphere_kokkos.h @@ -69,7 +69,7 @@ class AtomVecSphereKokkos : public AtomVecKokkos { int pack_vel_hybrid(int, double *); void write_vel(FILE *, int, double **); int write_vel_hybrid(FILE *, double *); - bigint memory_usage(); + double memory_usage(); int pack_comm_kokkos(const int &n, const DAT::tdual_int_2d &k_sendlist, const int & iswap, diff --git a/src/MISC/dump_xtc.cpp b/src/MISC/dump_xtc.cpp index 9f2bbfe424..ba90f83310 100644 --- a/src/MISC/dump_xtc.cpp +++ b/src/MISC/dump_xtc.cpp @@ -310,9 +310,9 @@ int DumpXTC::modify_param(int narg, char **arg) return # of bytes of allocated memory in buf and global coords array ------------------------------------------------------------------------- */ -bigint DumpXTC::memory_usage() +double DumpXTC::memory_usage() { - bigint bytes = Dump::memory_usage(); + double bytes = Dump::memory_usage(); bytes += memory->usage(coords,natoms*3); return bytes; } diff --git a/src/MISC/dump_xtc.h b/src/MISC/dump_xtc.h index 3fcc89f4ba..e242e7eef0 100644 --- a/src/MISC/dump_xtc.h +++ b/src/MISC/dump_xtc.h @@ -45,7 +45,7 @@ class DumpXTC : public Dump { void write_header(bigint); void pack(tagint *); void write_data(int, double *); - bigint memory_usage(); + double memory_usage(); void write_frame(); }; diff --git a/src/REPLICA/verlet_split.cpp b/src/REPLICA/verlet_split.cpp index a5ed1a671d..389bd109e5 100644 --- a/src/REPLICA/verlet_split.cpp +++ b/src/REPLICA/verlet_split.cpp @@ -580,8 +580,8 @@ void VerletSplit::k2r_comm() memory usage of Kspace force array on master procs ------------------------------------------------------------------------- */ -bigint VerletSplit::memory_usage() +double VerletSplit::memory_usage() { - bigint bytes = maxatom*3 * sizeof(double); + double bytes = maxatom*3 * sizeof(double); return bytes; } diff --git a/src/REPLICA/verlet_split.h b/src/REPLICA/verlet_split.h index b3ee87e580..f31ebdfa17 100644 --- a/src/REPLICA/verlet_split.h +++ b/src/REPLICA/verlet_split.h @@ -32,7 +32,7 @@ class VerletSplit : public Verlet { void setup(int); void setup_minimal(int); void run(int); - bigint memory_usage(); + double memory_usage(); private: int master; // 1 if an Rspace proc, 0 if Kspace diff --git a/src/USER-DPD/nbin_ssa.cpp b/src/USER-DPD/nbin_ssa.cpp index e3fa71aedf..21d630e789 100644 --- a/src/USER-DPD/nbin_ssa.cpp +++ b/src/USER-DPD/nbin_ssa.cpp @@ -120,9 +120,9 @@ void NBinSSA::bin_atoms_setup(int nall) /* ---------------------------------------------------------------------- */ -bigint NBinSSA::memory_usage() +double NBinSSA::memory_usage() { - bigint bytes = NBinStandard::memory_usage(); // Count the parent's usage too + double bytes = NBinStandard::memory_usage(); // Count the parent's usage too return bytes; } diff --git a/src/USER-DPD/nbin_ssa.h b/src/USER-DPD/nbin_ssa.h index c738391d67..eb4b2db24c 100644 --- a/src/USER-DPD/nbin_ssa.h +++ b/src/USER-DPD/nbin_ssa.h @@ -47,7 +47,7 @@ class NBinSSA : public NBinStandard { void bin_atoms_setup(int); void bin_atoms(); - bigint memory_usage(); + double memory_usage(); inline int coord2bin(const double & x,const double & y,const double & z, int &ixo, int &iyo, int &izo) const diff --git a/src/USER-INTEL/nbin_intel.cpp b/src/USER-INTEL/nbin_intel.cpp index 4a046bc845..3a2af740d8 100644 --- a/src/USER-INTEL/nbin_intel.cpp +++ b/src/USER-INTEL/nbin_intel.cpp @@ -241,7 +241,7 @@ void NBinIntel::bin_atoms(IntelBuffers * buffers) { /* ---------------------------------------------------------------------- */ -bigint NBinIntel::memory_usage() +double NBinIntel::memory_usage() { return NBinStandard::memory_usage() + maxatom*2*sizeof(int); } diff --git a/src/USER-INTEL/nbin_intel.h b/src/USER-INTEL/nbin_intel.h index d96f31885e..a7a28010ba 100644 --- a/src/USER-INTEL/nbin_intel.h +++ b/src/USER-INTEL/nbin_intel.h @@ -40,7 +40,7 @@ class NBinIntel : public NBinStandard { FixIntel *_fix; int *_atombin, *_binpacked; int _precision_mode; - bigint memory_usage(); + double memory_usage(); template void bin_atoms(IntelBuffers *); diff --git a/src/USER-MOLFILE/dump_molfile.cpp b/src/USER-MOLFILE/dump_molfile.cpp index e0e92f9339..f83477833e 100644 --- a/src/USER-MOLFILE/dump_molfile.cpp +++ b/src/USER-MOLFILE/dump_molfile.cpp @@ -452,9 +452,9 @@ int DumpMolfile::modify_param(int narg, char **arg) return # of bytes of allocated memory in buf and global coords array ------------------------------------------------------------------------- */ -bigint DumpMolfile::memory_usage() +double DumpMolfile::memory_usage() { - bigint bytes = Dump::memory_usage(); + double bytes = Dump::memory_usage(); bytes += memory->usage(coords,natoms*3); bytes += sizeof(MFI); return bytes; diff --git a/src/USER-MOLFILE/dump_molfile.h b/src/USER-MOLFILE/dump_molfile.h index c99d1cc5ea..f07416cffa 100644 --- a/src/USER-MOLFILE/dump_molfile.h +++ b/src/USER-MOLFILE/dump_molfile.h @@ -51,7 +51,7 @@ class DumpMolfile : public Dump { virtual void write_header(bigint) {}; virtual void pack(tagint *); virtual void write_data(int, double *); - virtual bigint memory_usage(); + virtual double memory_usage(); virtual void openfile(); }; diff --git a/src/USER-VTK/dump_vtk.cpp b/src/USER-VTK/dump_vtk.cpp index 59dba0d90d..794947f1b9 100644 --- a/src/USER-VTK/dump_vtk.cpp +++ b/src/USER-VTK/dump_vtk.cpp @@ -2309,9 +2309,9 @@ int DumpVTK::modify_param(int narg, char **arg) return # of bytes of allocated memory in buf, choose, variable arrays ------------------------------------------------------------------------- */ -bigint DumpVTK::memory_usage() +double DumpVTK::memory_usage() { - bigint bytes = Dump::memory_usage(); + double bytes = Dump::memory_usage(); bytes += memory->usage(choose,maxlocal); bytes += memory->usage(dchoose,maxlocal); bytes += memory->usage(clist,maxlocal); diff --git a/src/USER-VTK/dump_vtk.h b/src/USER-VTK/dump_vtk.h index b9db1f88cb..28fcca78d6 100644 --- a/src/USER-VTK/dump_vtk.h +++ b/src/USER-VTK/dump_vtk.h @@ -77,7 +77,7 @@ class DumpVTK : public DumpCustom { int count(); void pack(tagint *); virtual void write_data(int, double *); - bigint memory_usage(); + double memory_usage(); int parse_fields(int, char **); void identify_vectors(); diff --git a/src/atom.cpp b/src/atom.cpp index f28237cf74..831f7ac0b6 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -2586,9 +2586,9 @@ void *Atom::extract(const char *name) add in global to local mapping storage ------------------------------------------------------------------------- */ -bigint Atom::memory_usage() +double Atom::memory_usage() { - bigint bytes = avec->memory_usage(); + double bytes = avec->memory_usage(); bytes += max_same*sizeof(int); if (map_style == 1) diff --git a/src/atom.h b/src/atom.h index 728d420596..bcb26b8a6f 100644 --- a/src/atom.h +++ b/src/atom.h @@ -341,7 +341,7 @@ class Atom : protected Pointers { // NOTE: placeholder method until KOKKOS/AtomVec is refactored int memcheck(const char *) {return 1;} - bigint memory_usage(); + double memory_usage(); // functions for global to local ID mapping // map lookup function inlined for efficiency diff --git a/src/atom_vec.cpp b/src/atom_vec.cpp index 4a00e5852b..6e46406d1b 100644 --- a/src/atom_vec.cpp +++ b/src/atom_vec.cpp @@ -2306,12 +2306,12 @@ void AtomVec::write_improper(FILE *fp, int n, tagint **buf, int index) return # of bytes of allocated memory ------------------------------------------------------------------------- */ -bigint AtomVec::memory_usage() +double AtomVec::memory_usage() { int datatype,cols,maxcols; void *pdata; - bigint bytes = 0; + double bytes = 0; bytes += memory->usage(tag,nmax); bytes += memory->usage(type,nmax); diff --git a/src/atom_vec.h b/src/atom_vec.h index 07dec63506..5064a1cee7 100644 --- a/src/atom_vec.h +++ b/src/atom_vec.h @@ -151,8 +151,8 @@ class AtomVec : protected Pointers { virtual int property_atom(char *) {return -1;} virtual void pack_property_atom(int, double *, int, int) {} - virtual bigint memory_usage(); - virtual bigint memory_usage_bonus() {return 0;} + virtual double memory_usage(); + virtual double memory_usage_bonus() {return 0;} // old hybrid functions, needed by Kokkos package diff --git a/src/atom_vec_body.cpp b/src/atom_vec_body.cpp index e9044519c9..78bde4a2e1 100644 --- a/src/atom_vec_body.cpp +++ b/src/atom_vec_body.cpp @@ -551,9 +551,9 @@ void AtomVecBody::data_body(int m, int ninteger, int ndouble, return # of bytes of allocated memory ------------------------------------------------------------------------- */ -bigint AtomVecBody::memory_usage_bonus() +double AtomVecBody::memory_usage_bonus() { - bigint bytes = 0; + double bytes = 0; bytes += nmax_bonus*sizeof(Bonus); bytes += icp->size() + dcp->size(); diff --git a/src/atom_vec_body.h b/src/atom_vec_body.h index 809d90c25f..4a4c0d0e60 100644 --- a/src/atom_vec_body.h +++ b/src/atom_vec_body.h @@ -56,7 +56,7 @@ class AtomVecBody : public AtomVec { int pack_restart_bonus(int, double *); int unpack_restart_bonus(int, double *); void data_body(int, int, int, int *, double *); - bigint memory_usage_bonus(); + double memory_usage_bonus(); void create_atom_post(int); void data_atom_post(int); diff --git a/src/atom_vec_ellipsoid.cpp b/src/atom_vec_ellipsoid.cpp index c22111f48c..59f6cb9b0d 100644 --- a/src/atom_vec_ellipsoid.cpp +++ b/src/atom_vec_ellipsoid.cpp @@ -414,9 +414,9 @@ void AtomVecEllipsoid::data_atom_bonus(int m, char **values) return # of bytes of allocated bonus memory ------------------------------------------------------------------------- */ -bigint AtomVecEllipsoid::memory_usage_bonus() +double AtomVecEllipsoid::memory_usage_bonus() { - bigint bytes = 0; + double bytes = 0; bytes += nmax_bonus*sizeof(Bonus); return bytes; } diff --git a/src/atom_vec_ellipsoid.h b/src/atom_vec_ellipsoid.h index 041a20affd..57646522ec 100644 --- a/src/atom_vec_ellipsoid.h +++ b/src/atom_vec_ellipsoid.h @@ -49,7 +49,7 @@ class AtomVecEllipsoid : public AtomVec { int pack_restart_bonus(int, double *); int unpack_restart_bonus(int, double *); void data_atom_bonus(int, char **); - bigint memory_usage_bonus(); + double memory_usage_bonus(); void create_atom_post(int); void data_atom_post(int); diff --git a/src/atom_vec_hybrid.cpp b/src/atom_vec_hybrid.cpp index 7a8c73570d..bc0f804860 100644 --- a/src/atom_vec_hybrid.cpp +++ b/src/atom_vec_hybrid.cpp @@ -379,9 +379,9 @@ int AtomVecHybrid::unpack_restart_bonus(int ilocal, double *buf) /* ---------------------------------------------------------------------- */ -bigint AtomVecHybrid::memory_usage_bonus() +double AtomVecHybrid::memory_usage_bonus() { - bigint bytes = 0; + double bytes = 0; for (int k = 0; k < nstyles_bonus; k++) bytes += styles_bonus[k]->memory_usage_bonus(); return bytes; diff --git a/src/atom_vec_hybrid.h b/src/atom_vec_hybrid.h index 00be1b0418..2d8d5dec29 100644 --- a/src/atom_vec_hybrid.h +++ b/src/atom_vec_hybrid.h @@ -48,7 +48,7 @@ class AtomVecHybrid : public AtomVec { int size_restart_bonus(); int pack_restart_bonus(int, double *); int unpack_restart_bonus(int, double *); - bigint memory_usage_bonus(); + double memory_usage_bonus(); void pack_restart_pre(int); void pack_restart_post(int); diff --git a/src/atom_vec_line.cpp b/src/atom_vec_line.cpp index 88dcb8c2fa..c5beaaee82 100644 --- a/src/atom_vec_line.cpp +++ b/src/atom_vec_line.cpp @@ -380,9 +380,9 @@ void AtomVecLine::data_atom_bonus(int m, char **values) return # of bytes of allocated bonus memory ------------------------------------------------------------------------- */ -bigint AtomVecLine::memory_usage_bonus() +double AtomVecLine::memory_usage_bonus() { - bigint bytes = 0; + double bytes = 0; bytes += nmax_bonus*sizeof(Bonus); return bytes; } diff --git a/src/atom_vec_line.h b/src/atom_vec_line.h index 55a4b8bc02..449d8a1c04 100644 --- a/src/atom_vec_line.h +++ b/src/atom_vec_line.h @@ -49,7 +49,7 @@ class AtomVecLine : public AtomVec { int pack_restart_bonus(int, double *); int unpack_restart_bonus(int, double *); void data_atom_bonus(int, char **); - bigint memory_usage_bonus(); + double memory_usage_bonus(); void create_atom_post(int); void data_atom_post(int); diff --git a/src/atom_vec_tri.cpp b/src/atom_vec_tri.cpp index e391a73215..0394a6c35a 100644 --- a/src/atom_vec_tri.cpp +++ b/src/atom_vec_tri.cpp @@ -601,9 +601,9 @@ void AtomVecTri::data_atom_bonus(int m, char **values) return # of bytes of allocated bonus memory ------------------------------------------------------------------------- */ -bigint AtomVecTri::memory_usage_bonus() +double AtomVecTri::memory_usage_bonus() { - bigint bytes = 0; + double bytes = 0; bytes += nmax_bonus*sizeof(Bonus); return bytes; } diff --git a/src/atom_vec_tri.h b/src/atom_vec_tri.h index 9becf315f6..06898f20f5 100644 --- a/src/atom_vec_tri.h +++ b/src/atom_vec_tri.h @@ -51,7 +51,7 @@ class AtomVecTri : public AtomVec { int pack_restart_bonus(int, double *); int unpack_restart_bonus(int, double *); void data_atom_bonus(int, char **); - bigint memory_usage_bonus(); + double memory_usage_bonus(); void create_atom_post(int); void data_atom_post(int); diff --git a/src/comm.h b/src/comm.h index 1743436e22..6672891a42 100644 --- a/src/comm.h +++ b/src/comm.h @@ -104,7 +104,7 @@ class Comm : protected Pointers { // memory usage - virtual bigint memory_usage() = 0; + virtual double memory_usage() = 0; // non-virtual functions common to all Comm styles diff --git a/src/comm_brick.cpp b/src/comm_brick.cpp index 37a4f0ae3d..769ff8ad93 100644 --- a/src/comm_brick.cpp +++ b/src/comm_brick.cpp @@ -1499,9 +1499,9 @@ void *CommBrick::extract(const char *str, int &dim) return # of bytes of allocated memory ------------------------------------------------------------------------- */ -bigint CommBrick::memory_usage() +double CommBrick::memory_usage() { - bigint bytes = 0; + double bytes = 0; bytes += nprocs * sizeof(int); // grid2proc for (int i = 0; i < nswap; i++) bytes += memory->usage(sendlist[i],maxsendlist[i]); diff --git a/src/comm_brick.h b/src/comm_brick.h index 05268da63e..6165f54de5 100644 --- a/src/comm_brick.h +++ b/src/comm_brick.h @@ -47,7 +47,7 @@ class CommBrick : public Comm { void forward_comm_array(int, double **); // forward comm of array int exchange_variable(int, double *, double *&); // exchange on neigh stencil void *extract(const char *,int &); - virtual bigint memory_usage(); + virtual double memory_usage(); protected: int nswap; // # of swaps to perform = sum of maxneed diff --git a/src/comm_tiled.cpp b/src/comm_tiled.cpp index 48c9680d2f..a78727663f 100644 --- a/src/comm_tiled.cpp +++ b/src/comm_tiled.cpp @@ -2249,8 +2249,8 @@ void CommTiled::deallocate_swap(int n) return # of bytes of allocated memory ------------------------------------------------------------------------- */ -bigint CommTiled::memory_usage() +double CommTiled::memory_usage() { - bigint bytes = 0; + double bytes = 0; return bytes; } diff --git a/src/comm_tiled.h b/src/comm_tiled.h index aa8867b2c3..fa2c76e6e9 100644 --- a/src/comm_tiled.h +++ b/src/comm_tiled.h @@ -50,7 +50,7 @@ class CommTiled : public Comm { void coord2proc_setup(); int coord2proc(double *, int &, int &, int &); - bigint memory_usage(); + double memory_usage(); private: int nswap; // # of swaps to perform = 2*dim diff --git a/src/dump.cpp b/src/dump.cpp index febc3d0821..b4584ffd64 100644 --- a/src/dump.cpp +++ b/src/dump.cpp @@ -1172,9 +1172,9 @@ void Dump::pbc_allocate() return # of bytes of allocated memory ------------------------------------------------------------------------- */ -bigint Dump::memory_usage() +double Dump::memory_usage() { - bigint bytes = memory->usage(buf,size_one*maxbuf); + double bytes = memory->usage(buf,size_one*maxbuf); bytes += memory->usage(sbuf,maxsbuf); if (sort_flag) { if (sortcol == 0) bytes += memory->usage(ids,maxids); diff --git a/src/dump.h b/src/dump.h index 17e9434faa..fb6627a2b3 100644 --- a/src/dump.h +++ b/src/dump.h @@ -47,7 +47,7 @@ class Dump : protected Pointers { virtual void unpack_reverse_comm(int, int *, double *) {} void modify_params(int, char **); - virtual bigint memory_usage(); + virtual double memory_usage(); protected: int me,nprocs; // proc info diff --git a/src/dump_custom.cpp b/src/dump_custom.cpp index 167d88789c..66d9d52170 100644 --- a/src/dump_custom.cpp +++ b/src/dump_custom.cpp @@ -2091,9 +2091,9 @@ int DumpCustom::modify_param(int narg, char **arg) return # of bytes of allocated memory in buf, choose, variable arrays ------------------------------------------------------------------------- */ -bigint DumpCustom::memory_usage() +double DumpCustom::memory_usage() { - bigint bytes = Dump::memory_usage(); + double bytes = Dump::memory_usage(); bytes += memory->usage(choose,maxlocal); bytes += memory->usage(dchoose,maxlocal); bytes += memory->usage(clist,maxlocal); diff --git a/src/dump_custom.h b/src/dump_custom.h index 0f63eac8de..654a87fc6a 100644 --- a/src/dump_custom.h +++ b/src/dump_custom.h @@ -102,7 +102,7 @@ class DumpCustom : public Dump { void pack(tagint *); virtual int convert_string(int, double *); virtual void write_data(int, double *); - bigint memory_usage(); + double memory_usage(); int parse_fields(int, char **); int add_compute(char *); diff --git a/src/dump_dcd.cpp b/src/dump_dcd.cpp index 254b371e22..bb73d8975b 100644 --- a/src/dump_dcd.cpp +++ b/src/dump_dcd.cpp @@ -263,9 +263,9 @@ int DumpDCD::modify_param(int narg, char **arg) return # of bytes of allocated memory in buf and global coords array ------------------------------------------------------------------------- */ -bigint DumpDCD::memory_usage() +double DumpDCD::memory_usage() { - bigint bytes = Dump::memory_usage(); + double 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 15f6faf4be..3f59490b11 100644 --- a/src/dump_dcd.h +++ b/src/dump_dcd.h @@ -42,7 +42,7 @@ class DumpDCD : public Dump { void pack(tagint *); void write_data(int, double *); int modify_param(int, char **); - bigint memory_usage(); + double memory_usage(); void write_frame(); void write_dcd_header(const char *); diff --git a/src/fix_numdiff.cpp b/src/fix_numdiff.cpp index 145d60e8df..085b9215dd 100644 --- a/src/fix_numdiff.cpp +++ b/src/fix_numdiff.cpp @@ -338,7 +338,7 @@ void FixNumDiff::reallocate() double FixNumDiff::memory_usage() { - bigint bytes = 0.0; + double bytes = 0.0; bytes += 3 * maxatom*3 * sizeof(double); return bytes; } diff --git a/src/force.cpp b/src/force.cpp index 701113d7ef..11c21df752 100644 --- a/src/force.cpp +++ b/src/force.cpp @@ -836,9 +836,9 @@ void Force::set_special(int narg, char **arg) memory usage of force classes ------------------------------------------------------------------------- */ -bigint Force::memory_usage() +double Force::memory_usage() { - bigint bytes = 0; + double 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()); diff --git a/src/force.h b/src/force.h index 1302e20f12..a2cc37f0b8 100644 --- a/src/force.h +++ b/src/force.h @@ -135,7 +135,7 @@ class Force : protected Pointers { void store_style(char *&, const std::string &, int); void set_special(int, char **); - bigint memory_usage(); + double memory_usage(); private: void create_factories(); diff --git a/src/info.cpp b/src/info.cpp index 87161e9ca5..ccf6eb4145 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -315,41 +315,23 @@ void Info::command(int narg, char **arg) } if (flags & MEMORY) { + double meminfo[3]; + + get_memory_info(meminfo); fputs("\nMemory allocation information (MPI rank 0):\n\n",out); - - 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 < output->ndump; i++) - bytes += output->dump[i]->memory_usage(); - double mbytes = bytes/1024.0/1024.0; - fmt::print(out,"Total dynamically allocated memory: {:.4} Mbyte\n",mbytes); + fmt::print(out,"Total dynamically allocated memory: {:.4} Mbyte\n", + meminfo[0]); #if defined(_WIN32) - HANDLE phandle = GetCurrentProcess(); - PROCESS_MEMORY_COUNTERS_EX pmc; - GetProcessMemoryInfo(phandle,(PROCESS_MEMORY_COUNTERS *)&pmc,sizeof(pmc)); - fmt::print(out,"Non-shared memory use: {:.4} Mbyte\n", - (double)pmc.PrivateUsage/1048576.0); - fmt::print(out,"Maximum working set size: {:.4} Mbyte\n", - (double)pmc.PeakWorkingSetSize/1048576.0); + fmt::print(out,"Non-shared memory use: {:.4} Mbyte\n",meminfo[1]); + fmt::print(out,"Maximum working set size: {:.4} Mbyte\n",meminfo[2]); #else #if defined(__linux__) - struct mallinfo mi; - mi = mallinfo(); fmt::print(out,"Current reserved memory pool size: {:.4} Mbyte\n", - (double)mi.uordblks/1048576.0+(double)mi.hblkhd/1048576.0); + meminfo[1]); #endif - struct rusage ru; - if (getrusage(RUSAGE_SELF, &ru) == 0) { - fmt::print(out,"Maximum resident set size: {:.4} Mbyte\n", - (double)ru.ru_maxrss/1024.0); - } + fmt::print(out,"Maximum resident set size: {:.4} Mbyte\n",meminfo[2]); #endif } @@ -1300,6 +1282,41 @@ std::string Info::get_cxx_info() /* ---------------------------------------------------------------------- */ +void Info::get_memory_info(double *meminfo) +{ + double 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 < output->ndump; i++) + bytes += output->dump[i]->memory_usage(); + meminfo[0] = bytes/1024.0/1024.0; + meminfo[1] = 0; + meminfo[2] = 0; + +#if defined(_WIN32) + HANDLE phandle = GetCurrentProcess(); + PROCESS_MEMORY_COUNTERS_EX pmc; + GetProcessMemoryInfo(phandle,(PROCESS_MEMORY_COUNTERS *)&pmc,sizeof(pmc)); + meminfo[1] = (double)pmc.PrivateUsage/1048576.0; + meminfo[2] = (double)pmc.PeakWorkingSetSize/1048576.0; +#else +#if defined(__linux__) + struct mallinfo mi; + mi = mallinfo(); + meminfo[1] = (double)mi.uordblks/1048576.0+(double)mi.hblkhd/1048576.0; +#endif + struct rusage ru; + if (getrusage(RUSAGE_SELF, &ru) == 0) + meminfo[2] = (double)ru.ru_maxrss/1024.0; +#endif +} + +/* ---------------------------------------------------------------------- */ + char **Info::get_variable_names(int &num) { num = input->variable->nvar; return input->variable->names; diff --git a/src/info.h b/src/info.h index 65690ab28e..ae61600b68 100644 --- a/src/info.h +++ b/src/info.h @@ -52,6 +52,7 @@ class Info : protected Pointers { static std::string get_mpi_info(int &, int &); static std::string get_cxx_info(); + void get_memory_info(double *); char **get_variable_names(int &num); private: diff --git a/src/integrate.h b/src/integrate.h index f07faacbfa..c9aa92e097 100644 --- a/src/integrate.h +++ b/src/integrate.h @@ -28,7 +28,7 @@ class Integrate : protected Pointers { virtual void run(int) = 0; virtual void cleanup() {} virtual void reset_dt() {} - virtual bigint memory_usage() {return 0;} + virtual double memory_usage() {return 0;} protected: int eflag,vflag; // flags for energy/virial computation diff --git a/src/irregular.cpp b/src/irregular.cpp index fbb572fd88..47ee864abc 100644 --- a/src/irregular.cpp +++ b/src/irregular.cpp @@ -1051,9 +1051,9 @@ void Irregular::grow_recv(int n) return # of bytes of allocated memory ------------------------------------------------------------------------- */ -bigint Irregular::memory_usage() +double Irregular::memory_usage() { - bigint bytes = 0; + double bytes = 0; bytes += maxsend*sizeof(double); // buf_send bytes += maxrecv*sizeof(double); // buf_recv bytes += maxdbuf*sizeof(double); // dbuf diff --git a/src/irregular.h b/src/irregular.h index 01fe40c46b..9af6e52557 100644 --- a/src/irregular.h +++ b/src/irregular.h @@ -36,7 +36,7 @@ class Irregular : protected Pointers { int create_data_grouped(int, int *, int sortflag = 0); void exchange_data(char *, int, char *); void destroy_data(); - bigint memory_usage(); + double memory_usage(); private: int me,nprocs; diff --git a/src/library.cpp b/src/library.cpp index 7abc0df38a..6ebda8e616 100644 --- a/src/library.cpp +++ b/src/library.cpp @@ -532,6 +532,38 @@ int lammps_version(void *handle) return atoi(lmp->universe->num_ver); } +/* ---------------------------------------------------------------------- */ + +/** Get memory usage information + * +\verbatim embed:rst + +This function will retrieve memory usage information for the current +LAMMPS instance or process. The *meminfo* buffer will be filled with +3 different numbers (if supported by the operating system). The first +is the tally (in MBytes) of all large memory allocations made by LAMMPS. +This is a lower boundary of how much memory is requested and does not +account for memory allocated on the stack or allocations via ``new``. +The second number is the current memory allocation of the current process +as returned by a memory allocation reporting in the system library. The +third number is the maximum amount of RAM (not swap) used by the process +so far. If any of the two latter parameters is not supported by the operating +system it will be set to zero. + +.. versionadded:: 15Sep2020 + +\endverbatim + * + * \param handle pointer to a previously created LAMMPS instance + * \param meminfo buffer with space for at least 3 double to store + * data in. */ + +void lammps_memory_usage(void *handle, double *meminfo) +{ + LAMMPS *lmp = (LAMMPS *) handle; + Info info(lmp); + info.get_memory_info(meminfo); +} /* ---------------------------------------------------------------------- */ diff --git a/src/library.h b/src/library.h index 0c6ca184e5..4cf2dd6d19 100644 --- a/src/library.h +++ b/src/library.h @@ -98,7 +98,8 @@ void lammps_commands_string(void *handle, const char *str); * ----------------------------------------------------------------------- */ int lammps_version(void *handle); -int lammps_get_mpi_comm(void* handle); +void lammps_memory_usage(void *handle, double *meminfo); +int lammps_get_mpi_comm(void *handle); double lammps_get_natoms(void *handle); double lammps_get_thermo(void *handle, const char *keyword); diff --git a/src/memory.h b/src/memory.h index 42c9bf6aba..ef55dc2c87 100644 --- a/src/memory.h +++ b/src/memory.h @@ -617,40 +617,40 @@ class Memory : protected Pointers { ------------------------------------------------------------------------- */ template - bigint usage(TYPE *array, int n) + double usage(TYPE *array, int n) { (void) array; - bigint bytes = ((bigint) sizeof(TYPE)) * n; + double bytes = ((double) sizeof(TYPE)) * n; return bytes; } template - bigint usage(TYPE **array, int n1, int n2) + double usage(TYPE **array, int n1, int n2) { (void) array; - bigint bytes = ((bigint) sizeof(TYPE)) * n1*n2; - bytes += ((bigint) sizeof(TYPE *)) * n1; + double bytes = ((double) sizeof(TYPE)) * n1*n2; + bytes += ((double) sizeof(TYPE *)) * n1; return bytes; } template - bigint usage(TYPE ***array, int n1, int n2, int n3) + double usage(TYPE ***array, int n1, int n2, int n3) { (void) array; - bigint bytes = ((bigint) sizeof(TYPE)) * n1*n2*n3; - bytes += ((bigint) sizeof(TYPE *)) * n1*n2; - bytes += ((bigint) sizeof(TYPE **)) * n1; + double bytes = ((double) sizeof(TYPE)) * n1*n2*n3; + bytes += ((double) sizeof(TYPE *)) * n1*n2; + bytes += ((double) sizeof(TYPE **)) * n1; return bytes; } template - bigint usage(TYPE ****array, int n1, int n2, int n3, int n4) + double usage(TYPE ****array, int n1, int n2, int n3, int n4) { (void) array; - bigint bytes = ((bigint) sizeof(TYPE)) * n1*n2*n3*n4; - bytes += ((bigint) sizeof(TYPE *)) * n1*n2*n3; - bytes += ((bigint) sizeof(TYPE **)) * n1*n2; - bytes += ((bigint) sizeof(TYPE ***)) * n1; + double bytes = ((double) sizeof(TYPE)) * n1*n2*n3*n4; + bytes += ((double) sizeof(TYPE *)) * n1*n2*n3; + bytes += ((double) sizeof(TYPE **)) * n1*n2; + bytes += ((double) sizeof(TYPE ***)) * n1; return bytes; } }; diff --git a/src/min.h b/src/min.h index 1db196a55e..438a775d16 100644 --- a/src/min.h +++ b/src/min.h @@ -36,7 +36,7 @@ class Min : protected Pointers { virtual void run(int); void cleanup(); int request(class Pair *, int, double); - virtual bigint memory_usage() {return 0;} + virtual double memory_usage() {return 0;} void modify_params(int, char **); virtual int modify_param(int, char **) {return 0;} virtual double fnorm_sqr(); diff --git a/src/modify.cpp b/src/modify.cpp index c88d52b623..9d0511ca6f 100644 --- a/src/modify.cpp +++ b/src/modify.cpp @@ -1676,9 +1676,9 @@ void Modify::list_init_compute() return # of bytes of allocated memory from all fixes ------------------------------------------------------------------------- */ -bigint Modify::memory_usage() +double Modify::memory_usage() { - bigint bytes = 0; + double bytes = 0; for (int i = 0; i < nfix; i++) bytes += static_cast (fix[i]->memory_usage()); for (int i = 0; i < ncompute; i++) diff --git a/src/modify.h b/src/modify.h index 4c3db0a1b9..ee14baf638 100644 --- a/src/modify.h +++ b/src/modify.h @@ -125,7 +125,7 @@ class Modify : protected Pointers { int read_restart(FILE *); void restart_deallocate(int); - bigint memory_usage(); + double memory_usage(); protected: diff --git a/src/nbin.cpp b/src/nbin.cpp index 1092311f6a..66c5bd4159 100644 --- a/src/nbin.cpp +++ b/src/nbin.cpp @@ -153,9 +153,9 @@ int NBin::coord2bin(double *x) /* ---------------------------------------------------------------------- */ -bigint NBin::memory_usage() +double NBin::memory_usage() { - bigint bytes = 0; + double bytes = 0; bytes += maxbin*sizeof(int); bytes += 2*maxatom*sizeof(int); return bytes; diff --git a/src/nbin.h b/src/nbin.h index 54b8da171d..4bfe579514 100644 --- a/src/nbin.h +++ b/src/nbin.h @@ -42,7 +42,7 @@ class NBin : protected Pointers { void post_constructor(class NeighRequest *); virtual void copy_neighbor_info(); virtual void bin_atoms_setup(int); - bigint memory_usage(); + double memory_usage(); virtual void setup_bins(int) = 0; virtual void bin_atoms() = 0; diff --git a/src/neigh_list.cpp b/src/neigh_list.cpp index c01f8ca595..8798ec8f99 100644 --- a/src/neigh_list.cpp +++ b/src/neigh_list.cpp @@ -294,9 +294,9 @@ void NeighList::print_attributes() if stencilflag = 0, maxstencil * maxstencil_multi will also be 0 ------------------------------------------------------------------------- */ -bigint NeighList::memory_usage() +double NeighList::memory_usage() { - bigint bytes = 0; + double bytes = 0; bytes += memory->usage(ilist,maxatom); bytes += memory->usage(numneigh,maxatom); bytes += maxatom * sizeof(int *); diff --git a/src/neigh_list.h b/src/neigh_list.h index c26b008136..d69b844dc8 100644 --- a/src/neigh_list.h +++ b/src/neigh_list.h @@ -107,7 +107,7 @@ class NeighList : protected Pointers { void grow(int,int); // grow all data structs void print_attributes(); // debug routine int get_maxlocal() {return maxatom;} - bigint memory_usage(); + double memory_usage(); }; } diff --git a/src/neighbor.cpp b/src/neighbor.cpp index 66ab92496a..4fc54aafc2 100644 --- a/src/neighbor.cpp +++ b/src/neighbor.cpp @@ -2390,9 +2390,9 @@ int Neighbor::exclude_setting() return # of bytes of allocated memory ------------------------------------------------------------------------- */ -bigint Neighbor::memory_usage() +double Neighbor::memory_usage() { - bigint bytes = 0; + double bytes = 0; bytes += memory->usage(xhold,maxhold,3); for (int i = 0; i < nlist; i++) diff --git a/src/neighbor.h b/src/neighbor.h index 8fe423c60c..9ee2af9c75 100644 --- a/src/neighbor.h +++ b/src/neighbor.h @@ -123,7 +123,7 @@ class Neighbor : protected Pointers { int exclude_setting(); // return exclude value to accelerator pkg class NeighRequest *find_request(void *); // find a neighbor request - bigint memory_usage(); + double memory_usage(); bigint last_setup_bins; // step of last neighbor::setup_bins() call diff --git a/src/nstencil.cpp b/src/nstencil.cpp index 431906e898..9eb1818b83 100644 --- a/src/nstencil.cpp +++ b/src/nstencil.cpp @@ -222,9 +222,9 @@ double NStencil::bin_distance(int i, int j, int k) /* ---------------------------------------------------------------------- */ -bigint NStencil::memory_usage() +double NStencil::memory_usage() { - bigint bytes = 0; + double bytes = 0; if (neighstyle == Neighbor::BIN) { bytes += memory->usage(stencil,maxstencil); bytes += memory->usage(stencilxyz,maxstencil,3); diff --git a/src/nstencil.h b/src/nstencil.h index a4c6a4af66..75e678b483 100644 --- a/src/nstencil.h +++ b/src/nstencil.h @@ -39,7 +39,7 @@ class NStencil : protected Pointers { void post_constructor(class NeighRequest *); void copy_neighbor_info(); virtual void create_setup(); - bigint memory_usage(); + double memory_usage(); virtual void create() = 0; diff --git a/src/ntopo.cpp b/src/ntopo.cpp index d4ddcc7fc0..a53d88505b 100644 --- a/src/ntopo.cpp +++ b/src/ntopo.cpp @@ -206,9 +206,9 @@ void NTopo::dihedral_check(int nlist, int **list) /* ---------------------------------------------------------------------- */ -bigint NTopo::memory_usage() +double NTopo::memory_usage() { - bigint bytes = 0; + double bytes = 0; bytes += 3*maxbond * sizeof(int); bytes += 4*maxangle * sizeof(int); bytes += 5*maxdihedral * sizeof(int); diff --git a/src/ntopo.h b/src/ntopo.h index b115b32965..3e4204cead 100644 --- a/src/ntopo.h +++ b/src/ntopo.h @@ -28,7 +28,7 @@ class NTopo : protected Pointers { virtual void build() = 0; - bigint memory_usage(); + double memory_usage(); protected: int me,nprocs; diff --git a/src/output.cpp b/src/output.cpp index 6c90198de4..d4fd5ae75e 100644 --- a/src/output.cpp +++ b/src/output.cpp @@ -21,6 +21,7 @@ #include "error.h" #include "force.h" #include "group.h" +#include "info.h" #include "input.h" #include "memory.h" #include "modify.h" @@ -817,28 +818,19 @@ void Output::create_restart(int narg, char **arg) void Output::memory_usage() { - 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(); + double meminfo[3]; + Info info(lmp); - double mbytes = bytes/1024.0/1024.0; - double mbavg,mbmin,mbmax; + info.get_memory_info(meminfo); + double mbytes = meminfo[0]; + double mbmin,mbavg,mbmax; MPI_Reduce(&mbytes,&mbavg,1,MPI_DOUBLE,MPI_SUM,0,world); MPI_Reduce(&mbytes,&mbmin,1,MPI_DOUBLE,MPI_MIN,0,world); MPI_Reduce(&mbytes,&mbmax,1,MPI_DOUBLE,MPI_MAX,0,world); + mbavg /= comm->nprocs; - if (comm->me == 0) { - mbavg /= comm->nprocs; - if (screen) - fprintf(screen,"Per MPI rank memory allocation (min/avg/max) = " - "%.4g | %.4g | %.4g Mbytes\n",mbmin,mbavg,mbmax); - if (logfile) - fprintf(logfile,"Per MPI rank memory allocation (min/avg/max) = " - "%.4g | %.4g | %.4g Mbytes\n",mbmin,mbavg,mbmax); - } + if (comm->me == 0) + utils::logmesg(lmp,fmt::format("Per MPI rank memory allocation (min/avg/" + "max) = {:.4} | {:.4} | {:.4} Mbytes\n", + mbmin,mbavg,mbmax)); } diff --git a/src/rcb.cpp b/src/rcb.cpp index 03c99560b3..9cb4248ab0 100644 --- a/src/rcb.cpp +++ b/src/rcb.cpp @@ -1261,9 +1261,9 @@ void RCB::invert(int sortflag) memory use of Irregular ------------------------------------------------------------------------- */ -bigint RCB::memory_usage() +double RCB::memory_usage() { - bigint bytes = 0; + double bytes = 0; if (irregular) bytes += irregular->memory_usage(); return bytes; } diff --git a/src/rcb.h b/src/rcb.h index 555c4142b5..a3dc37bb9b 100644 --- a/src/rcb.h +++ b/src/rcb.h @@ -43,7 +43,7 @@ class RCB : protected Pointers { void compute(int, int, double **, double *, double *, double *); void compute_old(int, int, double **, double *, double *, double *); void invert(int sortflag = 0); - bigint memory_usage(); + double memory_usage(); // DEBUG methods //void check(); diff --git a/src/update.cpp b/src/update.cpp index d591e05131..f6ed47dcd2 100644 --- a/src/update.cpp +++ b/src/update.cpp @@ -537,9 +537,9 @@ void Update::update_time() memory usage of update and integrate/minimize ------------------------------------------------------------------------- */ -bigint Update::memory_usage() +double Update::memory_usage() { - bigint bytes = 0; + double 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 1d1e04b8bd..f2a28619fb 100644 --- a/src/update.h +++ b/src/update.h @@ -68,7 +68,7 @@ class Update : protected Pointers { void reset_timestep(int, char **); void reset_timestep(bigint); void update_time(); - bigint memory_usage(); + double memory_usage(); private: void new_integrate(char *, int, char **, int, int &); diff --git a/unittest/c-library/test_library_properties.cpp b/unittest/c-library/test_library_properties.cpp index 3b1393e5c6..5db779521b 100644 --- a/unittest/c-library/test_library_properties.cpp +++ b/unittest/c-library/test_library_properties.cpp @@ -54,6 +54,17 @@ TEST_F(LibraryProperties, version) EXPECT_GE(20200824, lammps_version(lmp)); }; +TEST_F(LibraryProperties, memory_usage) +{ + double meminfo[3]; + lammps_memory_usage(lmp,meminfo); + EXPECT_GT(meminfo[0], 0.0); +#if defined(__linux__) || defined(_WIN32) + EXPECT_GT(meminfo[1], 0.0); +#endif + EXPECT_GT(meminfo[2], 0.0); +}; + TEST_F(LibraryProperties, get_mpi_comm) { int f_comm = lammps_get_mpi_comm(lmp);