summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorCedric Nugteren <web@cedricnugteren.nl>2016-03-06 16:34:26 +0100
committerCedric Nugteren <web@cedricnugteren.nl>2016-03-06 16:34:26 +0100
commitfb58129afbbb4ff758924b9187cac4c954cafd0f (patch)
tree0bfd2e022380f9c0c4a15818f0520b0f28e46e17 /test
parent7468e2ba9db068ef7a11b11d12ac66752ea96713 (diff)
Made testing against clBLAS in the client binaries truely optional (was partly implemented before)
Diffstat (limited to 'test')
-rw-r--r--test/performance/client.cc65
-rw-r--r--test/performance/client.h6
2 files changed, 44 insertions, 27 deletions
diff --git a/test/performance/client.cc b/test/performance/client.cc
index ce97d273..ebfad3a6 100644
--- a/test/performance/client.cc
+++ b/test/performance/client.cc
@@ -15,6 +15,7 @@
#include <string>
#include <vector>
+#include <utility>
#include <algorithm>
#include <chrono>
@@ -112,7 +113,7 @@ template <typename T, typename U>
void Client<T,U>::PerformanceTest(Arguments<U> &args, const SetMetric set_sizes) {
// Prints the header of the output table
- PrintTableHeader(args.silent, options_);
+ PrintTableHeader(args);
// Initializes OpenCL and the libraries
auto platform = Platform(args.platform_id);
@@ -162,11 +163,16 @@ void Client<T,U>::PerformanceTest(Arguments<U> &args, const SetMetric set_sizes)
auto buffers = Buffers<T>{x_vec, y_vec, a_mat, b_mat, c_mat, ap_mat, dot};
// Runs the routines and collects the timings
+ auto timings = std::vector<std::pair<std::string, double>>();
auto ms_clblast = TimedExecution(args.num_runs, args, buffers, queue, run_routine_, "CLBlast");
- auto ms_clblas = TimedExecution(args.num_runs, args, buffers, queue, run_reference_, "clBLAS");
+ timings.push_back(std::pair<std::string, double>("CLBlast", ms_clblast));
+ if (args.compare_clblas) {
+ auto ms_clblas = TimedExecution(args.num_runs, args, buffers, queue, run_reference_, "clBLAS");
+ timings.push_back(std::pair<std::string, double>("clBLAS", ms_clblas));
+ }
- // Prints the performance of both libraries
- PrintTableRow(args, ms_clblast, ms_clblas);
+ // Prints the performance of the tested libraries
+ PrintTableRow(args, timings);
// Makes the jump to the next step
++s;
@@ -213,20 +219,27 @@ double Client<T,U>::TimedExecution(const size_t num_runs, const Arguments<U> &ar
// Prints the header of the performance table
template <typename T, typename U>
-void Client<T,U>::PrintTableHeader(const bool silent, const std::vector<std::string> &args) {
- if (!silent) {
- for (auto i=size_t{0}; i<args.size(); ++i) { fprintf(stdout, "%9s ", ""); }
- fprintf(stdout, " | <-- CLBlast --> | <-- clBLAS --> |\n");
+void Client<T,U>::PrintTableHeader(const Arguments<U>& args) {
+
+ // First line (optional)
+ if (!args.silent) {
+ for (auto i=size_t{0}; i<options_.size(); ++i) { fprintf(stdout, "%9s ", ""); }
+ fprintf(stdout, " | <-- CLBlast -->");
+ if (args.compare_clblas) { fprintf(stdout, " | <-- clBLAS -->"); }
+ fprintf(stdout, " |\n");
}
- for (auto &argument: args) { fprintf(stdout, "%9s;", argument.c_str()); }
- fprintf(stdout, "%9s;%9s;%9s;%9s;%9s;%9s\n",
- "ms_1", "GFLOPS_1", "GBs_1", "ms_2", "GFLOPS_2", "GBs_2");
+
+ // Second line
+ for (auto &option: options_) { fprintf(stdout, "%9s;", option.c_str()); }
+ fprintf(stdout, "%9s;%9s;%9s", "ms_1", "GFLOPS_1", "GBs_1");
+ if (args.compare_clblas) { fprintf(stdout, ";%9s;%9s;%9s", "ms_2", "GFLOPS_2", "GBs_2"); }
+ fprintf(stdout, "\n");
}
// Print a performance-result row
template <typename T, typename U>
-void Client<T,U>::PrintTableRow(const Arguments<U>& args, const double ms_clblast,
- const double ms_clblas) {
+void Client<T,U>::PrintTableRow(const Arguments<U>& args,
+ const std::vector<std::pair<std::string, double>>& timings) {
// Creates a vector of relevant variables
auto integers = std::vector<size_t>{};
@@ -261,14 +274,6 @@ void Client<T,U>::PrintTableRow(const Arguments<U>& args, const double ms_clblas
else if (o == kArgBeta) { strings.push_back(ToString(args.beta)); }
}
- // Computes the GFLOPS and GB/s metrics
- auto flops = get_flops_(args);
- auto bytes = get_bytes_(args);
- auto gflops_clblast = (ms_clblast != 0.0) ? (flops*1e-6)/ms_clblast : 0;
- auto gflops_clblas = (ms_clblas != 0.0) ? (flops*1e-6)/ms_clblas: 0;
- auto gbs_clblast = (ms_clblast != 0.0) ? (bytes*1e-6)/ms_clblast : 0;
- auto gbs_clblas = (ms_clblas != 0.0) ? (bytes*1e-6)/ms_clblas: 0;
-
// Outputs the argument values
for (auto &argument: integers) {
if (!args.no_abbrv && argument >= 1024*1024 && IsMultiple(argument, 1024*1024)) {
@@ -285,10 +290,20 @@ void Client<T,U>::PrintTableRow(const Arguments<U>& args, const double ms_clblas
fprintf(stdout, "%9s;", argument.c_str());
}
- // Outputs the performance numbers
- fprintf(stdout, "%9.2lf;%9.1lf;%9.1lf;%9.2lf;%9.1lf;%9.1lf\n",
- ms_clblast, gflops_clblast, gbs_clblast,
- ms_clblas, gflops_clblas, gbs_clblas);
+ // Loops over all tested libraries
+ for (const auto& timing : timings) {
+
+ // Computes the GFLOPS and GB/s metrics
+ auto flops = get_flops_(args);
+ auto bytes = get_bytes_(args);
+ auto gflops = (timing.second != 0.0) ? (flops*1e-6)/timing.second : 0;
+ auto gbs = (timing.second != 0.0) ? (bytes*1e-6)/timing.second : 0;
+
+ // Outputs the performance numbers
+ if (timing.first != "CLBlast") { fprintf(stdout, ";"); }
+ fprintf(stdout, "%9.2lf;%9.1lf;%9.1lf", timing.second, gflops, gbs);
+ }
+ fprintf(stdout, "\n");
}
// =================================================================================================
diff --git a/test/performance/client.h b/test/performance/client.h
index 9f6852d0..5805b8a5 100644
--- a/test/performance/client.h
+++ b/test/performance/client.h
@@ -23,6 +23,7 @@
#include <string>
#include <vector>
+#include <utility>
// The libraries to test
#include <clBLAS.h>
@@ -64,10 +65,11 @@ class Client {
Queue &queue, Routine run_blas, const std::string &library_name);
// Prints the header of a performance-data table
- void PrintTableHeader(const bool silent, const std::vector<std::string> &args);
+ void PrintTableHeader(const Arguments<U>& args);
// Prints a row of performance data, including results of two libraries
- void PrintTableRow(const Arguments<U>& args, const double ms_clblast, const double ms_clblas);
+ void PrintTableRow(const Arguments<U>& args,
+ const std::vector<std::pair<std::string, double>>& timings);
// The routine-specific functions passed to the tester
const Routine run_routine_;