Commit 3da363c0 authored by Giovanni La Mura's avatar Giovanni La Mura
Browse files

Write timing log file only from MPI process 0

parent c84dc8c5
Loading
Loading
Loading
Loading
+15 −8
Original line number Diff line number Diff line
@@ -100,9 +100,14 @@ void cluster(const string& config_file, const string& data_file, const string& o
  chrono::time_point<chrono::high_resolution_clock> t_start = chrono::high_resolution_clock::now();
  chrono::duration<double> elapsed;
  string message;
  string timing_name = output_path + "/c_timing_mpi"+ to_string(mpidata->rank) +".log";
  FILE *timing_file = fopen(timing_name.c_str(), "w");
  Logger *time_logger = new Logger(LOG_DEBG, timing_file);
  string timing_name;
  FILE *timing_file;
  Logger *time_logger;
  if (mpidata->rank == 0) {
    timing_name = output_path + "/c_timing_mpi"+ to_string(mpidata->rank) +".log";
    timing_file = fopen(timing_name.c_str(), "w");
    time_logger = new Logger(LOG_DEBG, timing_file);
  }
  Logger *logger = new Logger(LOG_DEBG);
  int device_count = 0;

@@ -117,8 +122,10 @@ void cluster(const string& config_file, const string& data_file, const string& o
  if (magma_result != MAGMA_SUCCESS) {
    logger->err("ERROR: Process " + to_string(mpidata->rank) + " failed to initilize MAGMA.\n");
    logger->err("PROC-" + to_string(mpidata->rank) + ": MAGMA error code " + to_string(magma_result) + "\n");
    if (mpidata->rank == 0) {
      fclose(timing_file);
      delete time_logger;
    }
    delete logger;
    return;
  }
@@ -330,11 +337,11 @@ void cluster(const string& config_file, const string& data_file, const string& o
      if (jer != 0) {
	// First loop failed. Halt the calculation.
	fclose(timing_file);
	delete time_logger;
	delete p_output;
	delete p_scattering_angles;
	delete cid;
	delete logger;
	delete time_logger;
	delete sconf;
	delete gconf;
	return;
@@ -646,8 +653,8 @@ void cluster(const string& config_file, const string& data_file, const string& o
    logger->log("INFO: Process " + to_string(mpidata->rank) + " finalizes MAGMA.\n");
    magma_finalize();
#endif
    fclose(timing_file);
    delete time_logger;
    // fclose(timing_file);
    // delete time_logger;
    delete logger;
#ifdef MPI_VERSION
  }