From 2966ba290241820d631bde6f554893bb484407bb Mon Sep 17 00:00:00 2001 From: Thorsten Liebig Date: Mon, 24 Sep 2012 15:16:47 +0200 Subject: [PATCH] new option to dump FDTD simulation statistics Signed-off-by: Thorsten Liebig --- FDTD/openems_fdtd_mpi.cpp | 2 ++ main.cpp | 3 ++- openems.cpp | 33 +++++++++++++++++++++++++++++++++ openems.h | 7 +++++++ 4 files changed, 44 insertions(+), 1 deletion(-) diff --git a/FDTD/openems_fdtd_mpi.cpp b/FDTD/openems_fdtd_mpi.cpp index c8ae4cc..ba9ccfa 100644 --- a/FDTD/openems_fdtd_mpi.cpp +++ b/FDTD/openems_fdtd_mpi.cpp @@ -517,5 +517,7 @@ void openEMS_FDTD_MPI::RunFDTD() { cout << "Time for " << FDTD_Eng->GetNumberOfTimesteps() << " iterations with " << FDTD_Op->GetNumberCells() << " cells : " << t_diff << " sec" << endl; cout << "Speed: " << speed*(double)FDTD_Eng->GetNumberOfTimesteps()/t_diff << " MCells/s " << endl; + + DumpStatistics("openEMS_stats.txt", t_diff); } } diff --git a/main.cpp b/main.cpp index 5b5b0b3..7887a66 100644 --- a/main.cpp +++ b/main.cpp @@ -84,7 +84,8 @@ int main(int argc, char *argv[]) cout << "\t\t--engine=multithreaded\t\tengine using compressed operator + sse vector extensions + multithreading" << endl; #endif cout << "\t--numThreads=\tForce use n threads for multithreaded engine (needs: --engine=multithreaded)" << endl; - cout << "\t--no-simulation\tonly run preprocessing; do not simulate" << endl; + cout << "\t--no-simulation\t\tonly run preprocessing; do not simulate" << endl; + cout << "\t--dump-statistics\tdump simulation statistics to 'openEMS_stats.txt'" << endl; cout << "\n\t Additional global arguments " << endl; g_settings.ShowArguments(cout,"\t"); cout << endl; diff --git a/openems.cpp b/openems.cpp index 800c076..3003625 100644 --- a/openems.cpp +++ b/openems.cpp @@ -17,6 +17,8 @@ #include "openems.h" #include +#include +#include #include "tools/array_ops.h" #include "tools/useful.h" #include "FDTD/operator_cylinder.h" @@ -66,6 +68,7 @@ openEMS::openEMS() DebugOp = false; m_debugCSX = false; m_debugBox = m_debugPEC = m_no_simulation = false; + m_DumpStats = false; endCrit = 1e-6; m_OverSampling = 4; @@ -182,6 +185,12 @@ bool openEMS::parseCommandLineArgument( const char *argv ) m_no_simulation = true; return true; } + else if (strcmp(argv,"--dump-statistics")==0) + { + cout << "openEMS - dump simulation statistics to 'openEMS_stats.txt'" << endl; + m_DumpStats = true; + return true; + } return false; } @@ -843,4 +852,28 @@ void openEMS::RunFDTD() cout << "Time for " << FDTD_Eng->GetNumberOfTimesteps() << " iterations with " << FDTD_Op->GetNumberCells() << " cells : " << t_diff << " sec" << endl; cout << "Speed: " << speed*(double)FDTD_Eng->GetNumberOfTimesteps()/t_diff << " MCells/s " << endl; + + DumpStatistics("openEMS_stats.txt", t_diff); +} + +bool openEMS::DumpStatistics(const string& filename, double time) +{ + ofstream stat_file; + stat_file.open(filename.c_str()); + + if (!stat_file.is_open()) + { + cerr << "openEMS::DumpStatistics: Error, opening file failed..." << endl; + return false; + } + stat_file << std::setprecision( 16 ); + stat_file << FDTD_Op->GetNumberCells() << "\t% number of cells" << endl; + stat_file << FDTD_Op->GetTimestep() << "\t% timestep (s)" << endl; + stat_file << FDTD_Eng->GetNumberOfTimesteps() << "\t% number of iterations" << endl; + stat_file << FDTD_Eng->GetNumberOfTimesteps()*FDTD_Op->GetTimestep() << "\t% total numercial time (s)" << endl; + stat_file << time << "\t% simulation time (s)" << endl; + stat_file << (double)FDTD_Op->GetNumberCells()*(double)FDTD_Eng->GetNumberOfTimesteps()/time << "\t% speed (cells/s)" << endl; + + stat_file.close(); + return true; } diff --git a/openems.h b/openems.h index 8e7a519..4e67a41 100644 --- a/openems.h +++ b/openems.h @@ -74,11 +74,15 @@ protected: //! Number of Timesteps unsigned int NrTS; + + // some command line flags bool Enable_Dumps; bool DebugMat; bool DebugOp; bool m_debugCSX; + bool m_DumpStats; bool m_debugBox, m_debugPEC, m_no_simulation; + double endCrit; int m_OverSampling; Operator* FDTD_Op; @@ -108,6 +112,9 @@ protected: //! Setup all processings. virtual bool SetupProcessing(); + + //! Dump statistics to file + virtual bool DumpStatistics(const string& filename, double time); }; #endif // OPENEMS_H