diff --git a/src/cluster/cluster.cpp b/src/cluster/cluster.cpp index 8231bb9f1b2790fa49febc7e3b9e717b5391cda9..1277a236714d951e789405b2092c35fa5dfe49d5 100644 --- a/src/cluster/cluster.cpp +++ b/src/cluster/cluster.cpp @@ -233,6 +233,10 @@ void cluster(const string& config_file, const string& data_file, const string& o sprintf(virtual_line, "%.5g.\n", sconf->get_particle_radius(gconf)); message = "INFO: particle radius is " + (string)virtual_line; logger->log(message); + double cid_size_gb = ClusterIterationData::get_size(gconf, sconf) / 1024.0 / 1024.0 / 1024.0; + sprintf(virtual_line, "INFO: iteration data size is %.5g Gb.\n", cid_size_gb); + message = string(virtual_line); + logger->log(message); ScatteringAngles *p_scattering_angles = new ScatteringAngles(gconf); double wp = sconf->wp; // ClusterOutputInfo : Thread 0 of MPI process 0 allocates the memory to @@ -2144,6 +2148,32 @@ ClusterIterationData::~ClusterIterationData() { delete[] cmul; } +long ClusterIterationData::get_size( + GeometryConfiguration *gconf, ScattererConfiguration *sconf, int li, int le +) { + int in_order = (li == -1)? gconf->li : li; + int out_order = (le == -1)? gconf->le : le; + int max_order = (in_order > out_order)? in_order : out_order; + int ndit = 2 * gconf->number_of_spheres * in_order * (in_order + 2); + long result = ParticleDescriptorCluster::get_size(gconf, sconf, li, le); + result += 37 * sizeof(long); // all pointers + result += 10 * sizeof(double); + result += 1 * sizeof(dcomplex); + result += 7 * sizeof(int); + result += sizeof(bool); + result += (gconf->number_of_spheres + 6) * sizeof(double); + result += 44 * sizeof(long); + result += gconf->number_of_spheres * 4 * sizeof(double); + result += gconf->number_of_spheres * 4 * sizeof(dcomplex); + result += 126 * sizeof(double); + result += 24 * sizeof(dcomplex); + result += (max_order * 12) * sizeof(long); + result += (max_order * 24) * sizeof(double); + result += (ndit * ndit) * sizeof(dcomplex); + result += ndit * sizeof(long); + return result; +} + int ClusterIterationData::update_orders(double **rcf, int inner_order, int outer_order) { int result = 0; int old_lm = c1->lm; diff --git a/src/include/Commons.h b/src/include/Commons.h index bc3775c0d7331e30dacf6e3913a6b7637786f3de..f13b1436aca25303dab8cd102e1ece371c42e13b 100644 --- a/src/include/Commons.h +++ b/src/include/Commons.h @@ -462,7 +462,7 @@ public: */ static long get_size( GeometryConfiguration *gconf, ScattererConfiguration *sconf, int li=-1, int le=-1 - ) { return 0; } + ); /*! \brief Update the field expansion orders. * diff --git a/src/include/IterationData.h b/src/include/IterationData.h index effb94faf480d503675babebbf27c7f489507380..dfd79e353cf3df5fd07380492ad62068005b38e8 100644 --- a/src/include/IterationData.h +++ b/src/include/IterationData.h @@ -181,6 +181,18 @@ public: */ ~ClusterIterationData(); + /*! \brief Estimate the size of an instance in memory in bytes. + * + * \param gconf: `GeometryConfiguration *` Pointer to a GeometryConfiguration instance. + * \param gconf: `ScattererConfiguration *` Pointer to a ScattererConfiguration instance. + * \param li: `int` Maximum expansion order for internal fields (optional, default from `gconf`). + * \param le: `int` Maximum expansion order for external fields (optional, default from `gconf`). + * \return size: `long` Estimate of the size in memory in bytes. + */ + static long get_size( + GeometryConfiguration *gconf, ScattererConfiguration *sconf, int li=-1, int le=-1 + ); + /*! \brief Update field expansion orders. * * \param rcf: `double **` Matrix of sphere fractional radii. @@ -359,6 +371,14 @@ public: */ ~InclusionIterationData(); + /*! \brief Estimate the size of an instance in memory in bytes. + * + * \param gconf: `GeometryConfiguration *` Pointer to a GeometryConfiguration instance. + * \param gconf: `ScattererConfiguration *` Pointer to a ScattererConfiguration instance. + * \return size: `long` Estimate of the size in memory in bytes. + */ + static long get_size(GeometryConfiguration *gconf, ScattererConfiguration *sconf); + /*! \brief Update field expansion orders. * * \param rcf: `double **` Matrix of sphere fractional radii. @@ -528,6 +548,14 @@ public: */ ~SphereIterationData(); + /*! \brief Estimate the size of an instance in memory in bytes. + * + * \param gconf: `GeometryConfiguration *` Pointer to a GeometryConfiguration instance. + * \param gconf: `ScattererConfiguration *` Pointer to a ScattererConfiguration instance. + * \return size: `long` Estimate of the size in memory in bytes. + */ + static long get_size(GeometryConfiguration *gconf, ScattererConfiguration *sconf); + /*! \brief Update field expansion order. * * \param order: `int` The new expansion order to be set. diff --git a/src/libnptm/Commons.cpp b/src/libnptm/Commons.cpp index 03dd266352cf63495d425be6e25905d87cced0f9..3de0685dab87fbc9376bae76727afe92c9537975 100644 --- a/src/libnptm/Commons.cpp +++ b/src/libnptm/Commons.cpp @@ -982,6 +982,50 @@ ParticleDescriptorCluster::ParticleDescriptorCluster(const mixMPI *mpidata) : Pa } #endif // MPI_VERSION +long ParticleDescriptorCluster::get_size( + GeometryConfiguration *gconf, ScattererConfiguration *sconf, int li, int le +) { + int in_order = (li == -1)? gconf->li : li; + int out_order = (le == -1)? gconf->le : le; + int max_order = (in_order > out_order)? in_order : out_order; + int nlemt = 2 * gconf->number_of_spheres * out_order * (out_order + 2); + int nlimt = 2 * gconf->number_of_spheres * in_order * (in_order + 2); + int nllt = (nlemt == 0) ? nlimt : nlemt; + int num_configurations = sconf->configurations; + int num_layers = 0; + int max_layers = 1; + int npnt = gconf->npnt; + int npntts = gconf->npntts; + int max_n = (npnt > npntts) ? npnt : npntts; + int nhspo = 2 * max_n - 1; + for (int nli = 0; nli < num_configurations; nli++) { + int nl = sconf->get_nshl(nli); + num_layers += nl; + if (nl > max_layers) max_layers = nl; + } + long size = 2 * sizeof(short); + size += 2 * 23 * sizeof(int); + size += 76 * sizeof(long); + size += 4 * sizeof(double); + size += 2 * sizeof(dcomplex); + size += 2 * in_order * gconf->number_of_spheres * sizeof(dcomplex); + size += 2 * in_order * sizeof(long); + size += 4 * nllt * sizeof(dcomplex); + size += nllt * sizeof(long); + size += num_layers * sizeof(double); + size += num_configurations * sizeof(long); + size += 16 * sizeof(dcomplex); + size += 3 * gconf->number_of_spheres * sizeof(double); + size += gconf->number_of_spheres * sizeof(int); + size += num_configurations * sizeof(double); + size += num_configurations * sizeof(int); + size += 2 * nhspo * sizeof(dcomplex); + size += gconf->number_of_spheres * sizeof(dcomplex); + size += (max_layers + 1) * sizeof(dcomplex); + size += gconf->number_of_spheres * sizeof(double); + return size; +} + int ParticleDescriptorCluster::update_orders(int inner_order, int outer_order) { int result = 0; bool changed_li = false;