Commit 57f65b4a authored by Giovanni La Mura's avatar Giovanni La Mura
Browse files

Use RAM overhead estimator to check for calculation feasibility at runtime

parent 562e538e
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -142,6 +142,7 @@ void cluster(const string& config_file, const string& data_file, const string& o
  }
  Logger *logger = new Logger(LOG_DEBG);
  int device_count = 0;
  const double ram_overhead_factor = get_ram_overhead();

#ifdef USE_MAGMA
  //===========
@@ -237,7 +238,7 @@ void cluster(const string& config_file, const string& data_file, const string& o
      long cid_size_bytes = ClusterIterationData::get_size(gconf, sconf);
      double cid_size_gb = cid_size_bytes / 1024.0 / 1024.0 / 1024.0;
      sprintf(virtual_line, "%.5lg", cid_size_gb);
      message = "INFO: iteration data requires " + (string)virtual_line + "GB of RAM.\n";
      message = "INFO: iteration data requires " + (string)virtual_line + "GiB of RAM.\n";
      logger->log(message);
      int omp_wavelength_threads = 1;
#ifdef _OPENMP
@@ -249,8 +250,12 @@ void cluster(const string& config_file, const string& data_file, const string& o
	}
      }
#endif //_OPENMP
      double requested_ram_gb = (ram_overhead_factor + omp_wavelength_threads) * cid_size_gb;
      sprintf(virtual_line, "%.5lg", requested_ram_gb);
      message = "INFO: code execution needs " + (string)virtual_line + "GiB of RAM.\n";
      logger->log(message);
      if (gconf->host_ram_gb > 0.0) {
	if (omp_wavelength_threads * cid_size_gb > gconf->host_ram_gb) {
	if (requested_ram_gb > gconf->host_ram_gb) {
	  // ERROR: host system does not have the necessary RAM
	  message = "ERROR: the requested model saturates the system RAM!\n";
	  logger->log(message);
+42 −36
Original line number Diff line number Diff line
@@ -909,8 +909,10 @@ def test_system_resources(model, gconf, sconf):
        max_host_ram = int(model['system_settings']['max_host_ram'])
        max_host_ram_bytes = max_host_ram * 1024 * 1024 * 1024
        if (max_host_ram > 0):
            required_ram_bytes = 0
            if (gconf['application'] == "CLUSTER"):
                # ClusterIterationData section
            required_ram_bytes = 8 * 37
                required_ram_bytes += 8 * 37
                required_ram_bytes += 8 * 10
                required_ram_bytes += 16
                required_ram_bytes += 4 * 7
@@ -943,11 +945,15 @@ def test_system_resources(model, gconf, sconf):
                    4 * nllt + nlemt * nlemt + 36 + ncou * litpo + nsph * lmtpo
                    + ncou * litpos + nsph * lmtpos
                )
            else:
                print("ERROR: unrecognized application name \"%s\""%gconf['application'])
                raise KeyError("unrecognized application name \"{0:s}\"".format(gconf['application']))
            required_ram_gb = required_ram_bytes / 1024.0 / 1024.0 / 1024.0
            print("INFO: model requires %.5gGb of host RAM."%required_ram_gb)
            print("INFO: model requires %.5gGiB of host RAM."%required_ram_gb)
            if (required_ram_bytes < max_host_ram_bytes):
                max_host_processes = int(max_host_ram_bytes / required_ram_bytes)
                print("INFO: system supports up to %d simultaneous processes."%max_host_processes)
                print("INFO: system supports up to %d simultaneous processes"%max_host_processes)
                print("      (N.B.: not including overheads!)")
            else:
                print("WARNING: estimated matrix size is larger than available host memory!")
        else: