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

Use logger in TRAPPING suite

parent 1e182f64
Loading
Loading
Loading
Loading
+30 −9
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
 *
 * C++ implementation of FRFME functions.
 */
#include <chrono>
#include <cstdio>
#include <exception>
#include <fstream>
@@ -71,6 +72,11 @@ void frfme(string data_file, string output_path) {
#ifdef USE_NVTX
  nvtxRangePush("Running frfme()");
#endif
  chrono::time_point<chrono::high_resolution_clock> t_start = chrono::high_resolution_clock::now();
  chrono::duration<double> elapsed;
  char buffer[256];
  string message = "INIT";
  Logger logger(LOG_INFO);
  string tfrfme_name = output_path + "/c_TFRFME.hd5";
  TFRFME *tfrfme = NULL;
  Swap1 *tt1 = NULL;
@@ -143,10 +149,12 @@ void frfme(string data_file, string output_path) {
	nlmmt = tt2->nlmmt;
	nrvc = tt2->nrvc;
      } else {
	printf("ERROR: could not open TEMPTAPE2 file.\n");
	message = "ERROR: could not open TEMPTAPE2 file.\n";
	logger.err(message);
      }
    } else {
      printf("ERROR: could not open TFRFME file.\n");
      message = "ERROR: could not open TFRFME file.\n";
      logger.err(message);
    }
    nks = nkv - 1;
#ifdef USE_NVTX
@@ -272,13 +280,16 @@ void frfme(string data_file, string output_path) {
	// Array initialization
	long swap1_size, swap2_size, tfrfme_size;
	double size_mb;
	printf("INFO: calculating memory requirements\n");
	message = "INFO: calculating memory requirements...\n";
	logger.log(message);
	swap1_size = Swap1::get_size(lm, nkv);
	size_mb = 1.0 * swap1_size / 1024.0 / 1024.0;
	printf("Swap 1: %.2lg MB\n", size_mb);
	swap2_size = Swap2::get_size(nkv);
	size_mb = 1.0 * swap2_size / 1024.0 / 1024.0;
	printf("Swap 2: %.2lg MB\n", size_mb);
	sprintf(buffer, "Swap 2: %.2lg MB\n", size_mb);
	message = string(buffer);
	logger.log(message);
	tt2 = new Swap2(nkv);
	vkv = tt2->get_vector();
	vkzm = tt2->get_matrix();
@@ -301,9 +312,13 @@ void frfme(string data_file, string output_path) {
	int nzshpo = nzsh + 1;
	tfrfme_size = TFRFME::get_size(lm, nkv, nxv, nyv, nzv);
	size_mb = 1.0 * tfrfme_size / 1024.0 / 1024.0;
	printf("TFRFME: %.2lg MB\n", size_mb);
	sprintf(buffer, "TFRFME: %.2lg MB\n", size_mb);
	message = string(buffer);
	logger.log(message);
	size_mb = 1.0 * (swap1_size + swap2_size + tfrfme_size) / 1024.0 / 1024.0;
	printf("TOTAL: %.2lg MB\n", size_mb);
	sprintf(buffer, "TOTAL: %.2lg MB\n", size_mb);
	message = string(buffer);
	logger.log(message);
	tfrfme = new TFRFME(lmode, lm, nkv, nxv, nyv, nzv);
	double *_xv = tfrfme->get_x();
	double *_yv = tfrfme->get_y();
@@ -383,10 +398,12 @@ void frfme(string data_file, string output_path) {
	    dcomplex *wk_local = new dcomplex[nlmmt]();
	    for (int wi = 0; wi < nkv; wi++) w[wi] = vec_w + wi * nkv;
	    int wk_index = 0;
	    int nkvs = nkv * nkv;
	    for (int jy50 = 0; jy50 < nkv; jy50++) {
	      for (int jx50 = 0; jx50 < nkv; jx50++) {
		for (int wi = 0; wi < nlmmt; wi++) wk_local[wi] = tt1->wk[wk_index++];
		w[jx50][jy50] = wk_local[j80 - 1];
		// w[jx50][jy50] = tt1->wk[jy50 * nkvs + jx50 * nkv + j80 - 1];
	      } // jx50
	    } // jy50 loop
	    int ixyz = 0;
@@ -443,10 +460,12 @@ void frfme(string data_file, string output_path) {
	  nvtxRangePop();
#endif
	} else { // Should never happen.
	  printf("ERROR: could not open TFRFME file for output.\n");
	  message = "ERROR: could not open TFRFME file for output.\n";
	  logger.err(message);
	}
      } else {
	printf("ERROR: could not open TEDF file.\n");
	message = "ERROR: could not open TEDF file.\n";
	logger.err(message);
      }
    } else { // label 98
      string output_name = output_path + "/c_OFRFME";
@@ -470,7 +489,9 @@ void frfme(string data_file, string output_path) {
#ifdef USE_NVTX
  nvtxRangePop();
#endif
  printf("FRFME: Done.\n");
  elapsed = chrono::high_resolution_clock::now() - t_start;
  message = "INFO: FRFME took " + to_string(elapsed.count()) + "s.\n";
  logger.log(message);
#ifdef USE_NVTX
  nvtxRangePop();
#endif
+9 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
 *
 * \brief C++ implementation of LFFFT functions.
 */
#include <chrono>
#include <cstdio>
#include <exception>
#include <fstream>
@@ -71,10 +72,15 @@ void lffft(string data_file, string output_path) {
#ifdef USE_NVTX
  nvtxRangePush("Running lffft()");
#endif
  chrono::time_point<chrono::high_resolution_clock> t_start = chrono::high_resolution_clock::now();
  chrono::duration<double> elapsed;
  const dcomplex uim = 0.0 + 1.0 * I;
  const double sq2i = 1.0 / sqrt(2.0);
  const dcomplex sq2iti = sq2i * uim;

  char buffer[256];
  string message = "INIT";
  Logger logger(LOG_INFO);
  fstream tlfff, tlfft;
  double ****zpv = NULL;
  dcomplex *ac = NULL, *ws = NULL, *wsl = NULL;
@@ -480,7 +486,9 @@ void lffft(string data_file, string output_path) {
  delete cil;
  delete ccr;
  delete[] file_lines;
  printf("LFFT: Done.\n");
  elapsed = chrono::high_resolution_clock::now() - t_start;
  message = "INFO: LFFT took " + to_string(elapsed.count()) + "s.\n";
  logger.log(message);
#ifdef USE_NVTX
  nvtxRangePop();
#endif