From ee8ab08eaf00738e94df649f2eb3d970a6ba4dd1 Mon Sep 17 00:00:00 2001 From: Peter Steinbach Date: Wed, 26 Jul 2017 14:02:32 +0200 Subject: [PATCH 01/10] added csv flag --- main.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/main.cpp b/main.cpp index 33cef1e..cd1f6b0 100644 --- a/main.cpp +++ b/main.cpp @@ -42,6 +42,7 @@ unsigned int ARRAY_SIZE = 33554432; unsigned int num_times = 100; unsigned int deviceIndex = 0; bool use_float = false; +bool output_as_csv = false; template void check_solution(const unsigned int ntimes, std::vector& a, std::vector& b, std::vector& c, T& sum); @@ -327,6 +328,10 @@ void parseArguments(int argc, char *argv[]) { use_float = true; } + else if (!std::string("--csv").compare(argv[i])) + { + output_as_csv = true; + } else if (!std::string("--help").compare(argv[i]) || !std::string("-h").compare(argv[i])) { @@ -339,6 +344,7 @@ void parseArguments(int argc, char *argv[]) std::cout << " -s --arraysize SIZE Use SIZE elements in the array" << std::endl; std::cout << " -n --numtimes NUM Run the test NUM times (NUM >= 2)" << std::endl; std::cout << " --float Use floats (rather than doubles)" << std::endl; + std::cout << " --csv Output as csv table" << std::endl; std::cout << std::endl; exit(EXIT_SUCCESS); } From 99fad100c6252ead230f1fe127242cea03f0c025 Mon Sep 17 00:00:00 2001 From: Peter Steinbach Date: Wed, 26 Jul 2017 14:22:24 +0200 Subject: [PATCH 02/10] added csv-output-sentinals and output --- main.cpp | 88 ++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 63 insertions(+), 25 deletions(-) diff --git a/main.cpp b/main.cpp index cd1f6b0..35b344f 100644 --- a/main.cpp +++ b/main.cpp @@ -43,6 +43,7 @@ unsigned int num_times = 100; unsigned int deviceIndex = 0; bool use_float = false; bool output_as_csv = false; +std::string csv_seperator = ","; template void check_solution(const unsigned int ntimes, std::vector& a, std::vector& b, std::vector& c, T& sum); @@ -54,13 +55,16 @@ void parseArguments(int argc, char *argv[]); int main(int argc, char *argv[]) { - std::cout - << "BabelStream" << std::endl - << "Version: " << VERSION_STRING << std::endl - << "Implementation: " << IMPLEMENTATION_STRING << std::endl; parseArguments(argc, argv); + if(!output_as_csv){ + std::cout + << "BabelStream" << std::endl + << "Version: " << VERSION_STRING << std::endl + << "Implementation: " << IMPLEMENTATION_STRING << std::endl; + } + // TODO: Fix Kokkos to allow multiple template specializations #ifndef KOKKOS if (use_float) @@ -74,24 +78,30 @@ int main(int argc, char *argv[]) template void run() { - std::cout << "Running kernels " << num_times << " times" << std::endl; + std::streamsize ss = std::cout.precision(); - if (sizeof(T) == sizeof(float)) - std::cout << "Precision: float" << std::endl; - else - std::cout << "Precision: double" << std::endl; + if(!output_as_csv){ + std::cout << "Running kernels " << num_times << " times" << std::endl; + + if (sizeof(T) == sizeof(float)) + std::cout << "Precision: float" << std::endl; + else + std::cout << "Precision: double" << std::endl; + + + std::cout << std::setprecision(1) << std::fixed + << "Array size: " << ARRAY_SIZE*sizeof(T)*1.0E-6 << " MB" + << " (=" << ARRAY_SIZE*sizeof(T)*1.0E-9 << " GB)" << std::endl; + std::cout << "Total size: " << 3.0*ARRAY_SIZE*sizeof(T)*1.0E-6 << " MB" + << " (=" << 3.0*ARRAY_SIZE*sizeof(T)*1.0E-9 << " GB)" << std::endl; + std::cout.precision(ss); + + } // Create host vectors std::vector a(ARRAY_SIZE); std::vector b(ARRAY_SIZE); std::vector c(ARRAY_SIZE); - std::streamsize ss = std::cout.precision(); - std::cout << std::setprecision(1) << std::fixed - << "Array size: " << ARRAY_SIZE*sizeof(T)*1.0E-6 << " MB" - << " (=" << ARRAY_SIZE*sizeof(T)*1.0E-9 << " GB)" << std::endl; - std::cout << "Total size: " << 3.0*ARRAY_SIZE*sizeof(T)*1.0E-6 << " MB" - << " (=" << 3.0*ARRAY_SIZE*sizeof(T)*1.0E-9 << " GB)" << std::endl; - std::cout.precision(ss); // Result of the Dot kernel T sum; @@ -180,14 +190,29 @@ void run() check_solution(num_times, a, b, c, sum); // Display timing results - std::cout - << std::left << std::setw(12) << "Function" - << std::left << std::setw(12) << "MBytes/sec" - << std::left << std::setw(12) << "Min (sec)" - << std::left << std::setw(12) << "Max" - << std::left << std::setw(12) << "Average" << std::endl; + if(output_as_csv){ + std::cout + << "function" << csv_seperator + << "nreps" << csv_seperator + << "n_elements" << csv_seperator + << "sizeof" << csv_seperator + << "max_mbytes_per_sec"<< csv_seperator + << "min_runtime" << csv_seperator + << "max_runtime" << csv_seperator + << "avg_runtime" << std::endl; + } + else{ + std::cout + << std::left << std::setw(12) << "Function" + << std::left << std::setw(12) << "MBytes/sec" + << std::left << std::setw(12) << "Min (sec)" + << std::left << std::setw(12) << "Max" + << std::left << std::setw(12) << "Average" + << std::endl + << std::fixed; + } + - std::cout << std::fixed; std::string labels[5] = {"Copy", "Mul", "Add", "Triad", "Dot"}; size_t sizes[5] = { @@ -207,14 +232,27 @@ void run() double average = std::accumulate(timings[i].begin()+1, timings[i].end(), 0.0) / (double)(num_times - 1); // Display results - std::cout + if(output_as_csv){ + std::cout + << labels[i] << csv_seperator + << num_times << csv_seperator + << ARRAY_SIZE << csv_seperator + << sizeof(T) << csv_seperator + << 1.0E-6 * sizes[i] / (*minmax.first) << csv_seperator + << *minmax.first << csv_seperator + << *minmax.second << csv_seperator + << average << csv_seperator + << std::endl; + } + else { + std::cout << std::left << std::setw(12) << labels[i] << std::left << std::setw(12) << std::setprecision(3) << 1.0E-6 * sizes[i] / (*minmax.first) << std::left << std::setw(12) << std::setprecision(5) << *minmax.first << std::left << std::setw(12) << std::setprecision(5) << *minmax.second << std::left << std::setw(12) << std::setprecision(5) << average << std::endl; - + } } delete stream; From add9973b67d0e7ca3acc17a20b816869e5069890 Mon Sep 17 00:00:00 2001 From: Peter Steinbach Date: Wed, 26 Jul 2017 17:21:17 +0200 Subject: [PATCH 03/10] fixed typo --- main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index 35b344f..646c74d 100644 --- a/main.cpp +++ b/main.cpp @@ -43,7 +43,7 @@ unsigned int num_times = 100; unsigned int deviceIndex = 0; bool use_float = false; bool output_as_csv = false; -std::string csv_seperator = ","; +std::string csv_separator = ","; template void check_solution(const unsigned int ntimes, std::vector& a, std::vector& b, std::vector& c, T& sum); From 7911e6a0ae52f10acf41ae82d389122692675228 Mon Sep 17 00:00:00 2001 From: Peter Steinbach Date: Wed, 26 Jul 2017 17:28:41 +0200 Subject: [PATCH 04/10] fixed compilation error due to unpropagated typo fix --- main.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/main.cpp b/main.cpp index 646c74d..5b75828 100644 --- a/main.cpp +++ b/main.cpp @@ -192,13 +192,13 @@ void run() // Display timing results if(output_as_csv){ std::cout - << "function" << csv_seperator - << "nreps" << csv_seperator - << "n_elements" << csv_seperator - << "sizeof" << csv_seperator - << "max_mbytes_per_sec"<< csv_seperator - << "min_runtime" << csv_seperator - << "max_runtime" << csv_seperator + << "function" << csv_separator + << "nreps" << csv_separator + << "n_elements" << csv_separator + << "sizeof" << csv_separator + << "max_mbytes_per_sec"<< csv_separator + << "min_runtime" << csv_separator + << "max_runtime" << csv_separator << "avg_runtime" << std::endl; } else{ @@ -234,14 +234,14 @@ void run() // Display results if(output_as_csv){ std::cout - << labels[i] << csv_seperator - << num_times << csv_seperator - << ARRAY_SIZE << csv_seperator - << sizeof(T) << csv_seperator - << 1.0E-6 * sizes[i] / (*minmax.first) << csv_seperator - << *minmax.first << csv_seperator - << *minmax.second << csv_seperator - << average << csv_seperator + << labels[i] << csv_separator + << num_times << csv_separator + << ARRAY_SIZE << csv_separator + << sizeof(T) << csv_separator + << 1.0E-6 * sizes[i] / (*minmax.first) << csv_separator + << *minmax.first << csv_separator + << *minmax.second << csv_separator + << average << csv_separator << std::endl; } else { From 2415bdc7c064a4f17270ee51da83249a97962d25 Mon Sep 17 00:00:00 2001 From: Peter Steinbach Date: Mon, 31 Jul 2017 14:00:44 +0200 Subject: [PATCH 05/10] fixed if-clause formatting --- main.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/main.cpp b/main.cpp index 5b75828..ddfa844 100644 --- a/main.cpp +++ b/main.cpp @@ -58,7 +58,8 @@ int main(int argc, char *argv[]) parseArguments(argc, argv); - if(!output_as_csv){ + if (!output_as_csv) + { std::cout << "BabelStream" << std::endl << "Version: " << VERSION_STRING << std::endl @@ -80,7 +81,8 @@ void run() { std::streamsize ss = std::cout.precision(); - if(!output_as_csv){ + if (!output_as_csv) + { std::cout << "Running kernels " << num_times << " times" << std::endl; if (sizeof(T) == sizeof(float)) @@ -190,7 +192,8 @@ void run() check_solution(num_times, a, b, c, sum); // Display timing results - if(output_as_csv){ + if(output_as_csv) + { std::cout << "function" << csv_separator << "nreps" << csv_separator @@ -232,7 +235,8 @@ void run() double average = std::accumulate(timings[i].begin()+1, timings[i].end(), 0.0) / (double)(num_times - 1); // Display results - if(output_as_csv){ + if(output_as_csv) + { std::cout << labels[i] << csv_separator << num_times << csv_separator From 7ed0308cb7a50bcffd8e926e8ae8f9ecfa7821d6 Mon Sep 17 00:00:00 2001 From: Peter Steinbach Date: Mon, 31 Jul 2017 14:14:52 +0200 Subject: [PATCH 06/10] code formatting fixed --- main.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/main.cpp b/main.cpp index ddfa844..5cb3952 100644 --- a/main.cpp +++ b/main.cpp @@ -192,7 +192,7 @@ void run() check_solution(num_times, a, b, c, sum); // Display timing results - if(output_as_csv) + if (output_as_csv) { std::cout << "function" << csv_separator @@ -204,7 +204,8 @@ void run() << "max_runtime" << csv_separator << "avg_runtime" << std::endl; } - else{ + else + { std::cout << std::left << std::setw(12) << "Function" << std::left << std::setw(12) << "MBytes/sec" @@ -235,7 +236,7 @@ void run() double average = std::accumulate(timings[i].begin()+1, timings[i].end(), 0.0) / (double)(num_times - 1); // Display results - if(output_as_csv) + if (output_as_csv) { std::cout << labels[i] << csv_separator @@ -248,14 +249,15 @@ void run() << average << csv_separator << std::endl; } - else { + else + { std::cout - << std::left << std::setw(12) << labels[i] - << std::left << std::setw(12) << std::setprecision(3) << 1.0E-6 * sizes[i] / (*minmax.first) - << std::left << std::setw(12) << std::setprecision(5) << *minmax.first - << std::left << std::setw(12) << std::setprecision(5) << *minmax.second - << std::left << std::setw(12) << std::setprecision(5) << average - << std::endl; + << std::left << std::setw(12) << labels[i] + << std::left << std::setw(12) << std::setprecision(3) << 1.0E-6 * sizes[i] / (*minmax.first) + << std::left << std::setw(12) << std::setprecision(5) << *minmax.first + << std::left << std::setw(12) << std::setprecision(5) << *minmax.second + << std::left << std::setw(12) << std::setprecision(5) << average + << std::endl; } } From 2dbb6937613c38921b01fb24b945087073387d7c Mon Sep 17 00:00:00 2001 From: Peter Steinbach Date: Mon, 31 Jul 2017 14:23:39 +0200 Subject: [PATCH 07/10] renamed nreps to be more consistent with the naming scheme --- main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index 5cb3952..8f0bfd2 100644 --- a/main.cpp +++ b/main.cpp @@ -196,7 +196,7 @@ void run() { std::cout << "function" << csv_separator - << "nreps" << csv_separator + << "num_times" << csv_separator << "n_elements" << csv_separator << "sizeof" << csv_separator << "max_mbytes_per_sec"<< csv_separator From df6fff1d2ee49a247e67feac95d4ac3dacb164c8 Mon Sep 17 00:00:00 2001 From: Peter Steinbach Date: Mon, 31 Jul 2017 14:30:08 +0200 Subject: [PATCH 08/10] added missing space for consistency --- main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index 8f0bfd2..3b76b46 100644 --- a/main.cpp +++ b/main.cpp @@ -199,7 +199,7 @@ void run() << "num_times" << csv_separator << "n_elements" << csv_separator << "sizeof" << csv_separator - << "max_mbytes_per_sec"<< csv_separator + << "max_mbytes_per_sec" << csv_separator << "min_runtime" << csv_separator << "max_runtime" << csv_separator << "avg_runtime" << std::endl; From f9ffa712cf899b0b1c1bae95889599a92a5cef24 Mon Sep 17 00:00:00 2001 From: Peter Steinbach Date: Mon, 31 Jul 2017 14:46:50 +0200 Subject: [PATCH 09/10] removed doublicate spaces --- main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index 3b76b46..4904330 100644 --- a/main.cpp +++ b/main.cpp @@ -197,7 +197,7 @@ void run() std::cout << "function" << csv_separator << "num_times" << csv_separator - << "n_elements" << csv_separator + << "n_elements" << csv_separator << "sizeof" << csv_separator << "max_mbytes_per_sec" << csv_separator << "min_runtime" << csv_separator From 01d4eea7b7280c1a699d03052a5c3cabc1b05ac7 Mon Sep 17 00:00:00 2001 From: Peter Steinbach Date: Mon, 31 Jul 2017 14:52:18 +0200 Subject: [PATCH 10/10] removed obsolete spaces --- main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.cpp b/main.cpp index 4904330..522eeb8 100644 --- a/main.cpp +++ b/main.cpp @@ -195,10 +195,10 @@ void run() if (output_as_csv) { std::cout - << "function" << csv_separator - << "num_times" << csv_separator + << "function" << csv_separator + << "num_times" << csv_separator << "n_elements" << csv_separator - << "sizeof" << csv_separator + << "sizeof" << csv_separator << "max_mbytes_per_sec" << csv_separator << "min_runtime" << csv_separator << "max_runtime" << csv_separator