Commit 375e8961 authored by Giacomo Mulas's avatar Giacomo Mulas
Browse files

- fix logger (remove now unneeded omp barriers)

- fix cluster (make logging message buffers omp local)
- add cluster test case 3
parent 23b8597e
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -186,7 +186,7 @@ void cluster(const string& config_file, const string& data_file, const string& o
	int jer = cluster_jxi488_cycle(jxi488, sconf, gconf, p_scattering_angles, cid, output, output_path, tppoan);
	chrono::time_point<chrono::high_resolution_clock> end_iter_1 = chrono::high_resolution_clock::now();
	elapsed = start_iter_1 - t_start;
	message = "INFO: Calculation setup took " + to_string(elapsed.count()) + "s.\n";
	string message = "INFO: Calculation setup took " + to_string(elapsed.count()) + "s.\n";
	logger->log(message);
	time_logger->log(message);
	elapsed = end_iter_1 - start_iter_1;
@@ -251,7 +251,7 @@ void cluster(const string& config_file, const string& data_file, const string& o
	  }
#pragma omp barrier
	  {
	    message = "INFO: Closing thread-local output files of thread " + to_string(myompthread) + " and syncing threads.\n";
	    string message = "INFO: Closing thread-local output files of thread " + to_string(myompthread) + " and syncing threads.\n";
	    logger->log(message);
	  }
	} // closes pragma omp parallel
@@ -262,7 +262,7 @@ void cluster(const string& config_file, const string& data_file, const string& o
	  for (int ri = 1; ri < ompnumthreads; ri++) {
	    // Giovanni, please add here in this loop code to reopen the temporary files, reread them and append them respectively to the global output and tppoan, before closing them
	    string partial_file_name = output_path + "/c_OCLU_" + to_string(mpidata->rank) + "_" + to_string(ri);
	    message = "Copying ASCII output in MPI process " + to_string(mpidata->rank) + " of thread " + to_string(ri) + " of " + to_string(ompnumthreads - 1) + "... ";
	    string message = "Copying ASCII output in MPI process " + to_string(mpidata->rank) + " of thread " + to_string(ri) + " of " + to_string(ompnumthreads - 1) + "... ";
	    logger->log(message, LOG_DEBG);
	    FILE *partial_output = fopen(partial_file_name.c_str(), "r");
	    int c = fgetc(partial_output);
@@ -341,7 +341,7 @@ void cluster(const string& config_file, const string& data_file, const string& o
    delete gconf;
    chrono::time_point<chrono::high_resolution_clock> t_end = chrono::high_resolution_clock::now();
    elapsed = t_end - t_start;
    message = "INFO: Calculation lasted " + to_string(elapsed.count()) + "s.\n";
    string message = "INFO: Calculation lasted " + to_string(elapsed.count()) + "s.\n";
    logger->log(message);
    logger->log("Finished: output written to " + output_path + "/c_OCLU\n");
    time_logger->log(message);
@@ -409,7 +409,7 @@ void cluster(const string& config_file, const string& data_file, const string& o
      delete tppoanp_2;
#pragma omp barrier
      {
	message = "INFO: Closing thread-local output files of thread " + to_string(myompthread) + " and syncing threads.\n";
	string message = "INFO: Closing thread-local output files of thread " + to_string(myompthread) + " and syncing threads.\n";
	logger->log(message);
      }
    } // closes pragma omp parallel
@@ -421,7 +421,7 @@ void cluster(const string& config_file, const string& data_file, const string& o
      for (int ri = 0; ri < ompnumthreads; ri++) {
	// Giovanni, please add here in this loop code to reopen the temporary files, reread them and append them respectively to the global output and tppoan, before closing them
	string partial_file_name = output_path + "/c_OCLU_" + to_string(mpidata->rank) + "_" + to_string(ri);
	message = "Copying ASCII output in MPI process " + to_string(mpidata->rank) + " of thread " + to_string(ri) + " of " + to_string(ompnumthreads - 1) + "... ";
	string message = "Copying ASCII output in MPI process " + to_string(mpidata->rank) + " of thread " + to_string(ri) + " of " + to_string(ompnumthreads - 1) + "... ";
	logger->log(message, LOG_DEBG);
	FILE *partial_output = fopen(partial_file_name.c_str(), "r");
	int c = 0;
+1 −0
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@
#include <hdf5.h>
#include <regex>
#include <string>
#include <string.h>
#ifdef USE_MPI
#ifndef MPI_VERSION
#include <mpi.h>
+4 −4
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@ Logger::~Logger() {
}

void Logger::err(const std::string& message) {
#pragma omp critical
//#pragma omp critical
  {
    fprintf(err_output, "%s", message.c_str());
    fflush(err_output);
@@ -34,7 +34,7 @@ void Logger::err(const std::string& message) {
}

void Logger::flush(int level) {
#pragma omp critical
//#pragma omp critical
  {
    string summary = "\"" + *last_message + "\" issued " + to_string(repetitions);
    if (repetitions == 1) summary += " time.\n";
@@ -53,7 +53,7 @@ void Logger::flush(int level) {
}

void Logger::log(const std::string& message, int level) {
#pragma omp critical
//#pragma omp critical
  {
    if (level == LOG_ERRO) err(message);
    else {
@@ -66,7 +66,7 @@ void Logger::log(const std::string& message, int level) {
}

void Logger::push(const std::string& message) {
#pragma omp critical
//#pragma omp critical
  {
    if (repetitions > 0) {
      if (message.compare(*last_message) != 0) {
+9 −0
Original line number Diff line number Diff line
    4   12   12    9200   0  149  300    0    0
    0.0000000D+00       0.0000000D+00       0.0000000D+00
   -8.6999381D-09      -2.1432655D-08       2.1878060D-07
   -1.1123930D-07       1.0519369D-07       1.7163947D-07
   -6.8351972D-08      -1.5505574D-08      -2.3997413D-07
  0.00D01  1.00D01  5.00D01  0.00D00  1.00D01  5.00D01
  0.00D01  1.00D01  5.00D01  0.00D00  1.00D01  5.00D01
  1
 0
+2016 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading