mirror of
https://github.com/CNugteren/CLBlast.git
synced 2024-08-25 06:17:01 +02:00
Made testing against clBLAS in the client binaries truely optional (was partly implemented before)
This commit is contained in:
parent
7468e2ba9d
commit
fb58129afb
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <utility>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
|
||||||
|
@ -112,7 +113,7 @@ template <typename T, typename U>
|
||||||
void Client<T,U>::PerformanceTest(Arguments<U> &args, const SetMetric set_sizes) {
|
void Client<T,U>::PerformanceTest(Arguments<U> &args, const SetMetric set_sizes) {
|
||||||
|
|
||||||
// Prints the header of the output table
|
// Prints the header of the output table
|
||||||
PrintTableHeader(args.silent, options_);
|
PrintTableHeader(args);
|
||||||
|
|
||||||
// Initializes OpenCL and the libraries
|
// Initializes OpenCL and the libraries
|
||||||
auto platform = Platform(args.platform_id);
|
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};
|
auto buffers = Buffers<T>{x_vec, y_vec, a_mat, b_mat, c_mat, ap_mat, dot};
|
||||||
|
|
||||||
// Runs the routines and collects the timings
|
// 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_clblast = TimedExecution(args.num_runs, args, buffers, queue, run_routine_, "CLBlast");
|
||||||
|
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");
|
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
|
// Prints the performance of the tested libraries
|
||||||
PrintTableRow(args, ms_clblast, ms_clblas);
|
PrintTableRow(args, timings);
|
||||||
|
|
||||||
// Makes the jump to the next step
|
// Makes the jump to the next step
|
||||||
++s;
|
++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
|
// Prints the header of the performance table
|
||||||
template <typename T, typename U>
|
template <typename T, typename U>
|
||||||
void Client<T,U>::PrintTableHeader(const bool silent, const std::vector<std::string> &args) {
|
void Client<T,U>::PrintTableHeader(const Arguments<U>& args) {
|
||||||
if (!silent) {
|
|
||||||
for (auto i=size_t{0}; i<args.size(); ++i) { fprintf(stdout, "%9s ", ""); }
|
// First line (optional)
|
||||||
fprintf(stdout, " | <-- CLBlast --> | <-- clBLAS --> |\n");
|
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",
|
// Second line
|
||||||
"ms_1", "GFLOPS_1", "GBs_1", "ms_2", "GFLOPS_2", "GBs_2");
|
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
|
// Print a performance-result row
|
||||||
template <typename T, typename U>
|
template <typename T, typename U>
|
||||||
void Client<T,U>::PrintTableRow(const Arguments<U>& args, const double ms_clblast,
|
void Client<T,U>::PrintTableRow(const Arguments<U>& args,
|
||||||
const double ms_clblas) {
|
const std::vector<std::pair<std::string, double>>& timings) {
|
||||||
|
|
||||||
// Creates a vector of relevant variables
|
// Creates a vector of relevant variables
|
||||||
auto integers = std::vector<size_t>{};
|
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)); }
|
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
|
// Outputs the argument values
|
||||||
for (auto &argument: integers) {
|
for (auto &argument: integers) {
|
||||||
if (!args.no_abbrv && argument >= 1024*1024 && IsMultiple(argument, 1024*1024)) {
|
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());
|
fprintf(stdout, "%9s;", argument.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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
|
// Outputs the performance numbers
|
||||||
fprintf(stdout, "%9.2lf;%9.1lf;%9.1lf;%9.2lf;%9.1lf;%9.1lf\n",
|
if (timing.first != "CLBlast") { fprintf(stdout, ";"); }
|
||||||
ms_clblast, gflops_clblast, gbs_clblast,
|
fprintf(stdout, "%9.2lf;%9.1lf;%9.1lf", timing.second, gflops, gbs);
|
||||||
ms_clblas, gflops_clblas, gbs_clblas);
|
}
|
||||||
|
fprintf(stdout, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// =================================================================================================
|
// =================================================================================================
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
// The libraries to test
|
// The libraries to test
|
||||||
#include <clBLAS.h>
|
#include <clBLAS.h>
|
||||||
|
@ -64,10 +65,11 @@ class Client {
|
||||||
Queue &queue, Routine run_blas, const std::string &library_name);
|
Queue &queue, Routine run_blas, const std::string &library_name);
|
||||||
|
|
||||||
// Prints the header of a performance-data table
|
// 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
|
// 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
|
// The routine-specific functions passed to the tester
|
||||||
const Routine run_routine_;
|
const Routine run_routine_;
|
||||||
|
|
Loading…
Reference in a new issue