Skip to content
Snippets Groups Projects
Commit 64c863b9 authored by KyleKlenk's avatar KyleKlenk
Browse files

added timing info to summa_actor, removed unencessary print statements

parent 7595416e
No related branches found
No related tags found
No related merge requests found
...@@ -4,7 +4,11 @@ ...@@ -4,7 +4,11 @@
#include <vector> #include <vector>
using chrono_time = std::chrono::time_point<std::chrono::system_clock>; using chrono_time = std::chrono::time_point<std::chrono::system_clock>;
/**
* Class to manage timing information. This allows the user to add an arbitrary amount of timing variables.
* The timing variables are accessed through their named string and will keep a running duration of the amount
* of time spent through multiple calls to updateStartPoint and updateEndPoint
*/
class TimingInfo { class TimingInfo {
private: private:
std::vector<std::optional<chrono_time>> start; std::vector<std::optional<chrono_time>> start;
......
...@@ -2,14 +2,17 @@ ...@@ -2,14 +2,17 @@
#include "caf/all.hpp" #include "caf/all.hpp"
#include "caf/io/all.hpp" #include "caf/io/all.hpp"
#include "timing_info.hpp"
#include <chrono> #include <chrono>
#include <string> #include <string>
#include <vector>
namespace caf { namespace caf {
struct summa_actor_timing_info { struct job_timing_info {
std:
std::chrono::time_point<std::chrono::system_clock> start; std::chrono::time_point<std::chrono::system_clock> start;
std::chrono::time_point<std::chrono::system_clock> end; std::chrono::time_point<std::chrono::system_clock> end;
double summa_actor_duration; double summa_actor_duration;
...@@ -18,9 +21,8 @@ struct summa_actor_timing_info { ...@@ -18,9 +21,8 @@ struct summa_actor_timing_info {
struct summa_actor_state { struct summa_actor_state {
// Timing Information For Summa-Actor // Timing Information For Summa-Actor
std::chrono::time_point<std::chrono::system_clock> start; TimingInfo summa_actor_timing;
std::chrono::time_point<std::chrono::system_clock> end;
double duration;
// Program Parameters // Program Parameters
int startGRU; // starting GRU for the simulation int startGRU; // starting GRU for the simulation
int numGRU; // number of GRUs to compute int numGRU; // number of GRUs to compute
......
...@@ -90,7 +90,7 @@ behavior hru_actor(stateful_actor<hru_state>* self, int refGRU, int indxGRU, ...@@ -90,7 +90,7 @@ behavior hru_actor(stateful_actor<hru_state>* self, int refGRU, int indxGRU,
self->state.hru_timing.updateEndPoint("total_duration"); self->state.hru_timing.updateEndPoint("total_duration");
// Tell our parent we are done, convert all timings to seconds // Tell our parent we are done, convert all timings to seconds
aout(self) << "\n________________PRINTING HRU TIMING INFO RESULTS________________\n"; aout(self) << "\n________________HRU TIMING INFO RESULTS________________\n";
aout(self) << "Total Duration = " << self->state.hru_timing.getDuration("total_duration").value_or(-1.0) << " Seconds\n"; aout(self) << "Total Duration = " << self->state.hru_timing.getDuration("total_duration").value_or(-1.0) << " Seconds\n";
aout(self) << "Init Duration = " << self->state.hru_timing.getDuration("init_duration").value_or(-1.0) << " Seconds\n"; aout(self) << "Init Duration = " << self->state.hru_timing.getDuration("init_duration").value_or(-1.0) << " Seconds\n";
aout(self) << "Forcing Duration = " << self->state.hru_timing.getDuration("forcing_duration").value_or(-1.0) << " Seconds\n"; aout(self) << "Forcing Duration = " << self->state.hru_timing.getDuration("forcing_duration").value_or(-1.0) << " Seconds\n";
...@@ -145,16 +145,13 @@ behavior hru_actor(stateful_actor<hru_state>* self, int refGRU, int indxGRU, ...@@ -145,16 +145,13 @@ behavior hru_actor(stateful_actor<hru_state>* self, int refGRU, int indxGRU,
self->state.dt_init_factor = dt_init_factor; self->state.dt_init_factor = dt_init_factor;
}, },
}; };
/*********************************************************************************************************
*********************************** END ACTOR MESSAGE HANDLERS ******************************************
*********************************************************************************************************/
} }
void Initialize_HRU(stateful_actor<hru_state>* self) { void Initialize_HRU(stateful_actor<hru_state>* self) {
self->state.hru_timing.updateStartPoint("init_duration"); self->state.hru_timing.updateStartPoint("init_duration");
// aout(self) << "Initalizing HRU" << std::endl;
// aout(self) << "Entering Initalize \n";
summaActors_initialize(&self->state.indxGRU, summaActors_initialize(&self->state.indxGRU,
&self->state.num_steps, &self->state.num_steps,
self->state.handle_forcStat, self->state.handle_forcStat,
...@@ -209,7 +206,6 @@ void Initialize_HRU(stateful_actor<hru_state>* self) { ...@@ -209,7 +206,6 @@ void Initialize_HRU(stateful_actor<hru_state>* self) {
self->quit(); self->quit();
return; return;
} }
// aout(self) << "Restart" << std::endl;
Restart(&self->state.indxGRU, Restart(&self->state.indxGRU,
&self->state.indxHRU, &self->state.indxHRU,
...@@ -294,9 +290,6 @@ int Run_HRU(stateful_actor<hru_state>* self) { ...@@ -294,9 +290,6 @@ int Run_HRU(stateful_actor<hru_state>* self) {
} }
self->state.hru_timing.updateEndPoint("run_physics_duration"); self->state.hru_timing.updateEndPoint("run_physics_duration");
/**********************************************************************
** WRITE_OUTPUT
**********************************************************************/
self->state.hru_timing.updateStartPoint("write_output_duration"); self->state.hru_timing.updateStartPoint("write_output_duration");
WriteOutput(&self->state.indxHRU, WriteOutput(&self->state.indxHRU,
&self->state.indxGRU, &self->state.indxGRU,
...@@ -349,13 +342,6 @@ bool check_HRU(stateful_actor<hru_state>* self, int err) { ...@@ -349,13 +342,6 @@ bool check_HRU(stateful_actor<hru_state>* self, int err) {
} else if (self->state.timestep > self->state.num_steps) { } else if (self->state.timestep > self->state.num_steps) {
// check if simulation is finished // check if simulation is finished
self->state.outputStep -= 1; // prevents segfault self->state.outputStep -= 1; // prevents segfault
if (debug)
aout(self) << "Sending Final Write" <<
"forcingStep = " << self->state.forcingStep << "\n" <<
"stepsInCurrentFFile = " << self->state.stepsInCurrentFFile << "\n" <<
"timeStep = " << self->state.timestep << "\n" <<
"outputStep = " << self->state.outputStep << "\n";
self->send(self->state.file_access_actor, write_output_v, self->send(self->state.file_access_actor, write_output_v,
self->state.indxGRU, self->state.indxHRU, self->state.outputStep, self); self->state.indxGRU, self->state.indxHRU, self->state.outputStep, self);
...@@ -369,14 +355,6 @@ bool check_HRU(stateful_actor<hru_state>* self, int err) { ...@@ -369,14 +355,6 @@ bool check_HRU(stateful_actor<hru_state>* self, int err) {
// Special case where we need both reading and writing // Special case where we need both reading and writing
self->state.outputStep -= 1; // prevents segfault self->state.outputStep -= 1; // prevents segfault
if (debug)
aout(self) << "Need to read forcing and write to outputstruc\n" <<
"forcingStep = " << self->state.forcingStep << "\n" <<
"stepsInCurrentFFile = " << self->state.stepsInCurrentFFile << "\n" <<
"timeStep = " << self->state.timestep << "\n" <<
"outputStep = " << self->state.outputStep << "\n";
self->send(self->state.file_access_actor, read_and_write_v, self->state.indxGRU, self->send(self->state.file_access_actor, read_and_write_v, self->state.indxGRU,
self->state.indxHRU, self->state.outputStep, self->state.iFile + 1, self); self->state.indxHRU, self->state.outputStep, self->state.iFile + 1, self);
self->state.outputStep = 1; self->state.outputStep = 1;
...@@ -386,14 +364,6 @@ bool check_HRU(stateful_actor<hru_state>* self, int err) { ...@@ -386,14 +364,6 @@ bool check_HRU(stateful_actor<hru_state>* self, int err) {
} else if (self->state.outputStep > self->state.outputStrucSize) { } else if (self->state.outputStep > self->state.outputStrucSize) {
// check if we need to clear the output struc // check if we need to clear the output struc
self->state.outputStep -= 1; self->state.outputStep -= 1;
if (debug)
aout(self) << "Sending Write \n" <<
"forcingStep = " << self->state.forcingStep << "\n" <<
"stepsInCurrentFFile = " << self->state.stepsInCurrentFFile << "\n" <<
"timeStep = " << self->state.timestep << "\n" <<
"outputStep = " << self->state.outputStep << "\n";
self->send(self->state.file_access_actor, write_output_v, self->send(self->state.file_access_actor, write_output_v,
self->state.indxGRU, self->state.indxHRU, self->state.outputStep, self); self->state.indxGRU, self->state.indxHRU, self->state.outputStep, self);
...@@ -403,14 +373,6 @@ bool check_HRU(stateful_actor<hru_state>* self, int err) { ...@@ -403,14 +373,6 @@ bool check_HRU(stateful_actor<hru_state>* self, int err) {
} else if (self->state.forcingStep > self->state.stepsInCurrentFFile) { } else if (self->state.forcingStep > self->state.stepsInCurrentFFile) {
// we need more forcing data // we need more forcing data
if (debug)
aout(self) << "Asking for more forcing data\n" <<
"forcingStep = " << self->state.forcingStep << "\n" <<
"stepsInCurrentFFile = " << self->state.stepsInCurrentFFile << "\n" <<
"timeStep = " << self->state.timestep << "\n" <<
"outputStep = " << self->state.outputStep << "\n";
self->send(self->state.file_access_actor, access_forcing_v, self->state.iFile + 1, self); self->send(self->state.file_access_actor, access_forcing_v, self->state.iFile + 1, self);
return false; return false;
......
...@@ -15,7 +15,10 @@ using json = nlohmann::json; ...@@ -15,7 +15,10 @@ using json = nlohmann::json;
namespace caf { namespace caf {
behavior summa_actor(stateful_actor<summa_actor_state>* self, int startGRU, int numGRU, std::string configPath, actor parent) { behavior summa_actor(stateful_actor<summa_actor_state>* self, int startGRU, int numGRU, std::string configPath, actor parent) {
self->state.start = std::chrono::high_resolution_clock::now(); // Set Timing Variables
self->state.summa_actor_timing = TimingInfo();
self->state.summa_actor_timing.addTimePoint("total_duration");
self->state.summa_actor_timing.updateStartPoint("total_duration");
// Set Variables // Set Variables
self->state.startGRU = startGRU; self->state.startGRU = startGRU;
self->state.numGRU = numGRU; self->state.numGRU = numGRU;
...@@ -35,24 +38,19 @@ behavior summa_actor(stateful_actor<summa_actor_state>* self, int startGRU, int ...@@ -35,24 +38,19 @@ behavior summa_actor(stateful_actor<summa_actor_state>* self, int startGRU, int
spawnJob(self); spawnJob(self);
return { return {
[=](done_job, int numFailed, int job_duration, int read_duration, int write_duration) { [=](done_job, int numFailed, double job_duration, double read_duration, double write_duration) {
self->state.numFailed += numFailed; self->state.numFailed += numFailed;
aout(self) << "Job Done\n"; aout(self) << "Job Done\n";
if (self->state.numGRU <= 0) { if (self->state.numGRU <= 0) {
self->state.summa_actor_timing.updateEndPoint("total_duration");
self->state.end = std::chrono::high_resolution_clock::now();
self->state.duration = calculateTime(self->state.start, self->state.end);
self->state.duration = self->state.duration / 1000; // Convert to milliseconds
aout(self) << "Total Program Duration:\n"; aout(self) << "\n________________SUMMA_ACTOR TIMING INFO________________\n";
aout(self) << " " << self->state.duration / 1000 << " Seconds\n"; aout(self) << "Total Duration = " << self->state.summa_actor_timing.getDuration("total_duration").value_or(-1.0) << " Seconds\n";
aout(self) << " " << (self->state.duration / 1000) / 60 << " Minutes\n"; aout(self) << "Total Duration = " << self->state.summa_actor_timing.getDuration("total_duration").value_or(-1.0) / 60 << " Minutes\n";
aout(self) << " " << ((self->state.duration / 1000) / 60) / 60 << " Hours\n"; aout(self) << "Total Duration = " << (self->state.summa_actor_timing.getDuration("total_duration").value_or(-1.0) / 60) / 60 << " Hours\n\n";
aout(self) << "Program Finished \n"; aout(self) << "Program Finished \n";
self->send(self->state.parent, done_batch_v, self->state.duration); self->send(self->state.parent, done_batch_v, self->state.summa_actor_timing.getDuration("total duration").value_or(-1.0));
} else { } else {
// spawn a new job // spawn a new job
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment