Commit 636778a2 authored by Giovanni La Mura's avatar Giovanni La Mura
Browse files

Implement ClusterIterationData size estimator

parent 1bbab104
Loading
Loading
Loading
Loading
+30 −0
Original line number Diff line number Diff line
@@ -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;
+1 −1
Original line number Diff line number Diff line
@@ -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.
   *
+28 −0
Original line number Diff line number Diff line
@@ -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.
+44 −0
Original line number Diff line number Diff line
@@ -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;