diff options
author | Tim Besard <tim.besard@gmail.com> | 2011-11-28 17:02:57 +0100 |
---|---|---|
committer | Tim Besard <tim.besard@gmail.com> | 2011-11-28 17:02:57 +0100 |
commit | 9177ded4c99840b02ea9e45ae90c287492785711 (patch) | |
tree | 42e7f485fa69c828e5275a930e0d471a3b9ab9e9 | |
parent | 3f20310855342804fe4299c1ae4a845aefd62798 (diff) |
Improving CSV output.
-rw-r--r-- | src/experiment.cpp | 18 | ||||
-rw-r--r-- | src/experiment.h | 2 | ||||
-rw-r--r-- | src/main.cpp | 4 | ||||
-rw-r--r-- | src/output.cpp | 18 | ||||
-rw-r--r-- | src/output.h | 11 | ||||
-rw-r--r-- | src/run.cpp | 11 | ||||
-rw-r--r-- | src/run.h | 8 |
7 files changed, 31 insertions, 41 deletions
diff --git a/src/experiment.cpp b/src/experiment.cpp index a6fdb8a..dcec720 100644 --- a/src/experiment.cpp +++ b/src/experiment.cpp @@ -87,10 +87,8 @@ Experiment::~Experiment() { // forward <stride> exclusive OR and mask // reverse <stride> addition and offset // -o or --output output mode -// hdr header only -// csv csv only -// both header + csv -// table human-readable table of values +// csv csv format (one entry per experiment) +// table human-readable table of values (averaged) // -n or --numa numa placement // local local allocation of all chains // xor <mask> exclusive OR and mask @@ -282,12 +280,6 @@ int Experiment::parse_args(int argc, char* argv[]) { this->output_mode = TABLE; } else if (strcasecmp(argv[i], "csv") == 0) { this->output_mode = CSV; - } else if (strcasecmp(argv[i], "both") == 0) { - this->output_mode = BOTH; - } else if (strcasecmp(argv[i], "hdr") == 0) { - this->output_mode = HEADER; - } else if (strcasecmp(argv[i], "header") == 0) { - this->output_mode = HEADER; } else { error = 1; break; @@ -364,10 +356,8 @@ int Experiment::parse_args(int argc, char* argv[]) { printf("Note: <stride> is always a small positive integer.\n"); printf("\n"); printf("<format> is selected from the following:\n"); - printf(" hdr # csv header only\n"); - printf(" csv # results in csv format only\n"); - printf(" both # header and results in csv format\n"); - printf(" table # human-readable table of values\n"); + printf(" csv # results in csv format (one entry per experiment)\n"); + printf(" table # human-readable table of values (averaged)\n"); printf("\n"); printf("<hint> is selected from the following:\n"); printf(" none # do not use prefetching\n"); diff --git a/src/experiment.h b/src/experiment.h index 38aee3c..332835d 100644 --- a/src/experiment.h +++ b/src/experiment.h @@ -63,7 +63,7 @@ public: enum { NONE, T0, T1, T2, NTA } prefetch_hint; // use of prefetching - enum { CSV, BOTH, HEADER, TABLE } + enum { CSV, TABLE } output_mode; // results output mode enum { RANDOM, STRIDED } diff --git a/src/main.cpp b/src/main.cpp index 9684f58..4200b3b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -83,9 +83,9 @@ int main(int argc, char* argv[]) { } int64 ops = Run::ops_per_chain(); - double secs = Run::seconds(); + std::vector<double> seconds = Run::seconds(); - Output::print(e, ops, secs, clk_res); + Output::print(e, ops, seconds, clk_res); return 0; } diff --git a/src/output.cpp b/src/output.cpp index 78a61da..c675945 100644 --- a/src/output.cpp +++ b/src/output.cpp @@ -27,20 +27,20 @@ // Implementation // -void Output::print(Experiment &e, int64 ops, double secs, double ck_res) { +void Output::print(Experiment &e, int64 ops, std::vector<double> seconds, double ck_res) { if (e.output_mode == Experiment::CSV) { - Output::csv(e, ops, secs, ck_res); - } else if (e.output_mode == Experiment::BOTH) { - Output::header(e, ops, secs, ck_res); - Output::csv(e, ops, secs, ck_res); - } else if (e.output_mode == Experiment::HEADER) { - Output::header(e, ops, secs, ck_res); + Output::header(e, ops, ck_res); + for (int i = 0; i < seconds.size(); i++) + Output::csv(e, ops, seconds[i], ck_res); } else { - Output::table(e, ops, secs, ck_res); + long double averaged_seconds = 0; + for (int i = 0; i < seconds.size(); i++) + averaged_seconds += seconds[i]; + Output::table(e, ops, (double) (averaged_seconds/seconds.size()), ck_res); } } -void Output::header(Experiment &e, int64 ops, double secs, double ck_res) { +void Output::header(Experiment &e, int64 ops, double ck_res) { printf("pointer size (bytes),"); printf("cache line size (bytes),"); printf("page size (bytes),"); diff --git a/src/output.h b/src/output.h index 42e3199..af718f0 100644 --- a/src/output.h +++ b/src/output.h @@ -18,6 +18,9 @@ #if !defined(OUTPUT_H) #define OUTPUT_H +// System includes +#include <vector> + // Local includes #include "types.h" #include "experiment.h" @@ -29,10 +32,10 @@ class Output { public: - static void print(Experiment &e, int64 ops, double secs, double ck_res); - static void header(Experiment &e, int64 ops, double secs, double ck_res); - static void csv(Experiment &e, int64 ops, double secs, double ck_res); - static void table(Experiment &e, int64 ops, double secs, double ck_res); + static void print(Experiment &e, int64 ops, std::vector<double> seconds, double ck_res); + static void header(Experiment &e, int64 ops, double ck_res); + static void csv(Experiment &e, int64 ops, double seconds, double ck_res); + static void table(Experiment &e, int64 ops, double seconds, double ck_res); private: }; diff --git a/src/run.cpp b/src/run.cpp index 57c03d8..75f716c 100644 --- a/src/run.cpp +++ b/src/run.cpp @@ -22,7 +22,6 @@ #include <cstdlib> #include <unistd.h> #include <cstddef> -#include <vector> #if defined(NUMA) #include <numa.h> #endif @@ -48,7 +47,7 @@ static benchmark chase_pointers(int64 chains_per_thread, Lock Run::global_mutex; int64 Run::_ops_per_chain = 0; -double Run::_seconds = 1E9; +std::vector<double> Run::_seconds; Run::Run() : exp(NULL), bp(NULL) { @@ -189,7 +188,7 @@ int Run::run() { if (this->thread_id() == 0) { double delta = stop - start; if (0 < delta) { - Run::_seconds = min(Run::_seconds, delta); + Run::_seconds.push_back(delta); } } } @@ -272,11 +271,9 @@ Run::random_mem_init(Chain *mem) { + link_within_line; if (root == 0) { -// printf("root = %d(%d)[0x%x].\n", page, line_within_page, mem+link); prev = root = mem + link; local_ops_per_chain += 1; } else { -// printf("0x%x = %d(%d)[0x%x].\n", prev, page, line_within_page, mem+link); prev->next = mem + link; prev = prev->next; local_ops_per_chain += 1; @@ -303,11 +300,9 @@ Run::forward_mem_init(Chain *mem) { for (int i = 0; i < this->exp->lines_per_chain; i += this->exp->stride) { int link = i * this->exp->links_per_line + link_within_line; if (root == NULL) { -// printf("root = %d(%d)[0x%x].\n", page, line_within_page, mem+link); prev = root = mem + link; local_ops_per_chain += 1; } else { -// printf("0x%x = %d(%d)[0x%x].\n", prev, page, line_within_page, mem+link); prev->next = mem + link; prev = prev->next; local_ops_per_chain += 1; @@ -339,11 +334,9 @@ Run::reverse_mem_init(Chain *mem) { for (int i = last; 0 <= i; i -= stride) { int link = i * this->exp->links_per_line + link_within_line; if (root == 0) { -// printf("root = %d(%d)[0x%x].\n", page, line_within_page, mem+link); prev = root = mem + link; local_ops_per_chain += 1; } else { -// printf("0x%x = %d(%d)[0x%x].\n", prev, page, line_within_page, mem+link); prev->next = mem + link; prev = prev->next; local_ops_per_chain += 1; @@ -18,6 +18,10 @@ #if !defined(RUN_H) #define RUN_H +// System includes +#include <vector> + + // Local includes #include "thread.h" #include "lock.h" @@ -41,7 +45,7 @@ public: static int64 ops_per_chain() { return _ops_per_chain; } - static double seconds() { + static std::vector<double> seconds() { return _seconds; } @@ -56,7 +60,7 @@ private: static Lock global_mutex; // global lock static int64 _ops_per_chain; // total number of operations per chain - static double _seconds; // total number of seconds + static std::vector<double> _seconds; // number of seconds for each experiment }; #endif |