Преглед изворни кода

Prints totals for each problem.

The controller prints the total number of kernel launches and total worker time for each problem.
Steven Engler пре 8 година
родитељ
комит
2ca52915e4
1 измењених фајлова са 16 додато и 0 уклоњено
  1. 16 0
      controller.cc

+ 16 - 0
controller.cc

@@ -121,6 +121,8 @@ static struct ControllerState {
     struct evconnlistener *listener;
     unsigned int problemid;
     unsigned int dpnode_count;
+    unsigned long long total_kernel_launches;
+    unsigned long long total_worker_time_ms;
 
     ControllerState() : working(false), num_unsolved_subproblems(0),
 	listener(NULL), problemid(0), dpnode_count(0) {}
@@ -135,6 +137,8 @@ static struct ControllerState {
 	num_unsolved_subproblems = 0;
 	started_working.tv_sec = 0;
 	started_working.tv_usec = 0;
+	total_kernel_launches = 0;
+	total_worker_time_ms = 0;
 	problemid = curproblemid++;
     }
 
@@ -435,10 +439,20 @@ static void computation_complete(void)
     sprintf(length_buf, "%lld.%03lld s", computation_length_ms / 1000,
 					    computation_length_ms % 1000);
 
+    char worker_time_sec_buf[50];
+    sprintf(worker_time_sec_buf, "%lld.%03lld",
+                ctrlstate.total_worker_time_ms / 1000,
+                ctrlstate.total_worker_time_ms % 1000);
+
     char timestamp[20];
     sprintf(timestamp, "%d.%06d",
 	    (int)ended_working.tv_sec, (int)ended_working.tv_usec);
 
+    cout << "Totals (problemid, launches, worker_time): "
+         << ctrlstate.problemid << ", "
+         << ctrlstate.total_kernel_launches << ", "
+         << worker_time_sec_buf << "\n";
+
     cout << timestamp << ":" << output_prefix << ": " <<
 	    "expon = " << expon << "\n";
     cout << timestamp << ":" << output_prefix << ": " <<
@@ -731,6 +745,8 @@ static void controller_worker_reader(struct bufferevent *bev, void *ctx)
 	         << worker_time_sec_buf << "\n";
 	    cout.flush();
 
+	    ctrlstate.total_kernel_launches += spp->kernel_launch_count;
+	    ctrlstate.total_worker_time_ms += spp->worker_time_ms;
 	    spp->reset();
 	    schedule();
 	}