Commit 4069dafd authored by Giovanni La Mura's avatar Giovanni La Mura
Browse files

Stop code execution if GPU is overflowed, too

parent a6369f92
Loading
Loading
Loading
Loading
+19 −0
Original line number Original line Diff line number Diff line
@@ -260,6 +260,25 @@ void cluster(const string& config_file, const string& data_file, const string& o
	  exit(1);
	  exit(1);
	}
	}
      }
      }
      if (gconf->gpu_ram_gb > 0.0) {
	// mat_size_bytes = sizeof(dcomplex) * 2 * 2 * NSPH * NSPH * LI * LI * (LI + 2) * (LI + 2)
	long matrix_size_bytes = sizeof(dcomplex)
	  * 4 * gconf->number_of_spheres * gconf->number_of_spheres
	  * gconf->li * gconf->li * (gconf->li + 2) * (gconf->li + 2);
	double matrix_size_gb = matrix_size_bytes / 1024.0 / 1024.0 / 1024.0;
	int refinement_factor = (gconf->refine_flag) ? 3 : 1;
	if (refinement_factor * omp_wavelength_threads * matrix_size_gb > gconf->gpu_ram_gb) {
	  // ERROR: GPU does not have the necessary RAM
	  message = "ERROR: the requested model saturates the GPU RAM!\n";
	  logger->log(message);
	  fclose(timing_file);
	  delete time_logger;
	  delete logger;
	  delete sconf;
	  delete gconf;
	  exit(1);
	}
      }
      ScatteringAngles *p_scattering_angles = new ScatteringAngles(gconf);
      ScatteringAngles *p_scattering_angles = new ScatteringAngles(gconf);
      double wp = sconf->wp;
      double wp = sconf->wp;
      // ClusterOutputInfo : Thread 0 of MPI process 0 allocates the memory to
      // ClusterOutputInfo : Thread 0 of MPI process 0 allocates the memory to