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

Make sure that the logger is destroyed independently of whether code is under MPI or not

parent e39cb1e4
Loading
Loading
Loading
Loading
+1 −43
Original line number Diff line number Diff line
@@ -287,51 +287,9 @@ void cluster(const string& config_file, const string& data_file, const string& o
	p_output->vec_vk[0] = cid->vk;
      }

      // do the first iteration on jxi488 separately, since it seems to be different from the others
      // not anymore, now this iteration is at the same level as others
      int jxi488;
      int initialmaxrefiters = cid->maxrefiters;
      //chrono::time_point<chrono::high_resolution_clock> start_iter_1 = chrono::high_resolution_clock::now();
// #ifdef USE_NVTX
//       nvtxRangePush("First iteration");
// #endif
      // use these pragmas, which should have no effect on parallelism, just to push OMP nested levels at the same level also in the first wavelength iteration
      int jer = 0;
// #pragma omp parallel
//       {
// #pragma omp single
// 	{
// 	  jer = cluster_jxi488_cycle(jxi488, sconf, gconf, p_scattering_angles, cid, p_output, output_path, vtppoanp);
// 	} // OMP single
//       } // OMP parallel
// #ifdef USE_NVTX
//       nvtxRangePop();
// #endif
      //chrono::time_point<chrono::high_resolution_clock> end_iter_1 = chrono::high_resolution_clock::now();
      //elapsed = start_iter_1 - t_start;
      // 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;
      // message = "INFO: First iteration took " + to_string(elapsed.count()) + "s.\n";
      // logger->log(message);
      // time_logger->log(message);
      /* for the next iterations, just always do maxiter iterations, assuming the accuracy is good enough */
      // cid->refinemode = 0;
      /* add an extra iteration for margin, if this does not exceed initialmaxrefiters */
      // if (cid->maxrefiters < initialmaxrefiters) cid->maxrefiters++;
      // 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 sconf;
      // 	delete gconf;
      // 	return;
      // }

      //==================================================
      // do the first outputs here, so that I open here the new files, afterwards I only append
@@ -683,9 +641,9 @@ 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
    delete logger;
#ifdef MPI_VERSION
  }
  delete logger;
#endif
}

+1 −44
Original line number Diff line number Diff line
@@ -277,51 +277,9 @@ void inclusion(const string& config_file, const string& data_file, const string&
	p_output->vec_vk[0] = cid->vk;
      }
      
      // do the first iteration on jxi488 separately, since it seems to be different from the others
      int jxi488;
      int initialmaxrefiters = cid->maxrefiters;
      
//       chrono::time_point<chrono::high_resolution_clock> start_iter_1 = chrono::high_resolution_clock::now();
// #ifdef USE_NVTX
//       nvtxRangePush("First iteration");
// #endif
      // use these pragmas, which should have no effect on parallelism, just to push OMP nested levels at the same level also in the first wavelength iteration
      int jer = 0;
// #pragma omp parallel
//       {
// #pragma omp single
// 	{
// 	  jer = inclusion_jxi488_cycle(jxi488, sconf, gconf, p_scattering_angles, cid, p_output, output_path, vtppoanp);
// 	}
//       }
// #ifdef USE_NVTX
//       nvtxRangePop();
// #endif
//       chrono::time_point<chrono::high_resolution_clock> end_iter_1 = chrono::high_resolution_clock::now();
//       elapsed = start_iter_1 - t_start;
//       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;
//       message = "INFO: First iteration took " + to_string(elapsed.count()) + "s.\n";
//       logger->log(message);
//       time_logger->log(message);
      /* for the next iterations, just always do maxiter iterations, assuming the accuracy is good enough */
      // cid->refinemode = 0;
      // /* add an extra iteration for margin, if this does not exceed initialmaxrefiters */
      // // if (cid->maxrefiters < initialmaxrefiters) cid->maxrefiters++;
      // 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 sconf;
      // 	delete gconf;
      // 	return;
      // }

      //==================================================
      // do the first outputs here, so that I open here the new files, afterwards I only append
@@ -536,7 +494,6 @@ void inclusion(const string& config_file, const string& data_file, const string&
    time_logger->log(message);
    fclose(timing_file);
    delete time_logger;
    delete logger;
  } // end instructions block of MPI process 0
  
    //===============================
@@ -666,10 +623,10 @@ void inclusion(const string& config_file, const string& data_file, const string&
    logger->log("INFO: Process " + to_string(mpidata->rank) + " finalizes MAGMA.\n");
    magma_finalize();
#endif
    delete logger;
#ifdef MPI_VERSION
  }
#endif
  delete logger;
}

int inclusion_jxi488_cycle(int jxi488, ScattererConfiguration *sconf, GeometryConfiguration *gconf, ScatteringAngles *sa, InclusionIterationData *cid, InclusionOutputInfo *output, const string& output_path, VirtualBinaryFile *vtppoanp) {
+0 −19
Original line number Diff line number Diff line
@@ -200,26 +200,7 @@ void sphere(const string& config_file, const string& data_file, const string& ou
	p_output->vec_vk[0] = sid->vk;
      }

      // Do the first wavelength iteration
      // int jxi488 = 1;
      // Use pragmas to put OMP parallelism to second level.
      int jer = 0;
// #pragma omp parallel
//       {
// #pragma omp single
// 	{
// 	  jer = sphere_jxi488_cycle(jxi488 - 1, sconf, gconf, p_sa, sid, p_output, output_path, vtppoanp);
// 	} // OMP single
//       } // OMP parallel
//       if (jer != 0) { // First iteration failed. Halt the calculation.
// 	delete p_output;
// 	delete p_sa;
// 	delete sid;
// 	delete logger;
// 	delete sconf;
// 	delete gconf;
// 	return;
//       }

      //==================================================
      // do the first outputs here, so that I open here the new files, afterwards I only append