From fb58129afbbb4ff758924b9187cac4c954cafd0f Mon Sep 17 00:00:00 2001 From: Cedric Nugteren Date: Sun, 6 Mar 2016 16:34:26 +0100 Subject: Made testing against clBLAS in the client binaries truely optional (was partly implemented before) --- test/performance/client.cc | 65 ++++++++++++++++++++++++++++------------------ test/performance/client.h | 6 +++-- 2 files changed, 44 insertions(+), 27 deletions(-) (limited to 'test') 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 #include +#include #include #include @@ -112,7 +113,7 @@ template void Client::PerformanceTest(Arguments &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::PerformanceTest(Arguments &args, const SetMetric set_sizes) auto buffers = Buffers{x_vec, y_vec, a_mat, b_mat, c_mat, ap_mat, dot}; // Runs the routines and collects the timings + auto timings = std::vector>(); 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("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("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::TimedExecution(const size_t num_runs, const Arguments &ar // Prints the header of the performance table template -void Client::PrintTableHeader(const bool silent, const std::vector &args) { - if (!silent) { - for (auto i=size_t{0}; i | <-- clBLAS --> |\n"); +void Client::PrintTableHeader(const Arguments& args) { + + // First line (optional) + if (!args.silent) { + for (auto i=size_t{0}; i"); + 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 -void Client::PrintTableRow(const Arguments& args, const double ms_clblast, - const double ms_clblas) { +void Client::PrintTableRow(const Arguments& args, + const std::vector>& timings) { // Creates a vector of relevant variables auto integers = std::vector{}; @@ -261,14 +274,6 @@ void Client::PrintTableRow(const Arguments& 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::PrintTableRow(const Arguments& 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 #include +#include // The libraries to test #include @@ -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 &args); + void PrintTableHeader(const Arguments& args); // Prints a row of performance data, including results of two libraries - void PrintTableRow(const Arguments& args, const double ms_clblast, const double ms_clblas); + void PrintTableRow(const Arguments& args, + const std::vector>& timings); // The routine-specific functions passed to the tester const Routine run_routine_; -- cgit v1.2.3