Commit a6369f92 authored by Giovanni La Mura's avatar Giovanni La Mura
Browse files

Enable optional runtime scanning of GPU and host RAM resources

parent 72312c1e
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -113,6 +113,10 @@ protected:
  short _refine_flag;
  //! \brief Flag for dynamic order management.
  short _dyn_order_flag;
  //! \brief Host RAM in GB
  double _host_ram_gb;
  //! \brief GPU RAM in GB
  double _gpu_ram_gb;

public:
  //! \brief Read-only view on number of spherical components.
@@ -165,6 +169,10 @@ public:
  const short& refine_flag = _refine_flag;
  //! \brief Read-only view on flag for dynamic order management.
  const short& dyn_order_flag = _dyn_order_flag;
  //! \brief Read-only view on host RAM in GB
  const double& host_ram_gb = _host_ram_gb;
  //! \brief Read-only view on GPU RAM in GB
  const double& gpu_ram_gb = _gpu_ram_gb;
  
  /*! \brief Build a scattering geometry configuration structure.
   *
+22 −2
Original line number Diff line number Diff line
@@ -99,6 +99,8 @@ GeometryConfiguration::GeometryConfiguration(
  _sph_z = z;
  _refine_flag = 0;
  _dyn_order_flag = 1;
  _host_ram_gb = 0.0;
  _gpu_ram_gb = 0.0;
}

GeometryConfiguration::GeometryConfiguration(const GeometryConfiguration& rhs)
@@ -136,6 +138,8 @@ GeometryConfiguration::GeometryConfiguration(const GeometryConfiguration& rhs)
  }
  _refine_flag = rhs._refine_flag;
  _dyn_order_flag = rhs._dyn_order_flag;
  _host_ram_gb = rhs._host_ram_gb;
  _gpu_ram_gb = rhs._gpu_ram_gb;
}

#ifdef MPI_VERSION
@@ -173,6 +177,8 @@ GeometryConfiguration::GeometryConfiguration(const mixMPI *mpidata) {
  MPI_Bcast(_sph_z, _number_of_spheres, MPI_DOUBLE, 0, MPI_COMM_WORLD);
  MPI_Bcast(&_refine_flag, 1, MPI_SHORT, 0, MPI_COMM_WORLD);
  MPI_Bcast(&_dyn_order_flag, 1, MPI_SHORT, 0, MPI_COMM_WORLD);
  MPI_Bcast(&_host_ram_gb, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD);
  MPI_Bcast(&_gpu_ram_gb, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD);
}

void GeometryConfiguration::mpibcast(const mixMPI *mpidata) {
@@ -206,6 +212,8 @@ void GeometryConfiguration::mpibcast(const mixMPI *mpidata) {
  MPI_Bcast(_sph_z, _number_of_spheres, MPI_DOUBLE, 0, MPI_COMM_WORLD);
  MPI_Bcast(&_refine_flag, 1, MPI_SHORT, 0, MPI_COMM_WORLD);
  MPI_Bcast(&_dyn_order_flag, 1, MPI_SHORT, 0, MPI_COMM_WORLD);
  MPI_Bcast(&_host_ram_gb, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD);
  MPI_Bcast(&_gpu_ram_gb, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD);
}
#endif

@@ -342,18 +350,30 @@ GeometryConfiguration* GeometryConfiguration::from_legacy(const std::string& fil
    str_target = file_lines[last_read_line++];
    if (str_target.size() > 15) {
      if (str_target.substr(0, 15).compare("USE_REFINEMENT=") == 0) {
	re = regex("[0-9]+");
	regex_search(str_target, m, re);
	short refine_flag = (short)stoi(m.str());
	conf->_refine_flag = refine_flag;
      }
    }
    if (str_target.size() > 15) {
      if (str_target.substr(0, 15).compare("USE_DYN_ORDERS=") == 0) {
	re = regex("[0-9]+");
	regex_search(str_target, m, re);
	short dyn_order_flag = (short)stoi(m.str());
	conf->_dyn_order_flag = dyn_order_flag;
      }
    }
    if (str_target.size() > 12) {
      if (str_target.substr(0, 12).compare("HOST_RAM_GB=") == 0) {
	double ram_gb = (double)stod(str_target.substr(12, str_target.length()));
	conf->_host_ram_gb = ram_gb;
      }
    }
    if (str_target.size() > 11) {
      if (str_target.substr(0, 11).compare("GPU_RAM_GB=") == 0) {
	double ram_gb = (double)stod(str_target.substr(11, str_target.length()));
	conf->_gpu_ram_gb = ram_gb;
      }
    }
  }
  
  // Clean up memory and return configuration object.