summaryrefslogtreecommitdiff
path: root/test/performance/client.h
diff options
context:
space:
mode:
authorCNugteren <web@cedricnugteren.nl>2015-05-30 12:30:43 +0200
committerCNugteren <web@cedricnugteren.nl>2015-05-30 12:30:43 +0200
commitbc5a341dfe591946e925db315fc7d8c0c25c2938 (patch)
treeb216ab5eee4863e3807d92b5ddd19fa22197ed22 /test/performance/client.h
parentc7b054ea6747039f4405fd93da6e924f3e5c7f4b (diff)
Initial commit of preview version
Diffstat (limited to 'test/performance/client.h')
-rw-r--r--test/performance/client.h85
1 files changed, 85 insertions, 0 deletions
diff --git a/test/performance/client.h b/test/performance/client.h
new file mode 100644
index 00000000..2b9991fe
--- /dev/null
+++ b/test/performance/client.h
@@ -0,0 +1,85 @@
+
+// =================================================================================================
+// This file is part of the CLBlast project. The project is licensed under Apache Version 2.0. This
+// project loosely follows the Google C++ styleguide and uses a tab-size of two spaces and a max-
+// width of 100 characters per line.
+//
+// Author(s):
+// Cedric Nugteren <www.cedricnugteren.nl>
+//
+// This file provides common function declarations to be used with the test clients.
+//
+// =================================================================================================
+
+#ifndef CLBLAST_TEST_PERFORMANCE_CLIENT_H_
+#define CLBLAST_TEST_PERFORMANCE_CLIENT_H_
+
+#include <string>
+#include <vector>
+
+// The libraries to test
+#include <clBLAS.h>
+#include "clblast.h"
+
+#include "internal/utilities.h"
+
+namespace clblast {
+// =================================================================================================
+
+// Types of devices to consider
+const cl_device_type kDeviceType = CL_DEVICE_TYPE_ALL;
+
+// =================================================================================================
+
+// Shorthand for a BLAS routine with 2 or 3 OpenCL buffers as argument
+template <typename T>
+using Routine2 = std::function<void(const Arguments<T>&,
+ const Buffer&, const Buffer&,
+ CommandQueue&)>;
+template <typename T>
+using Routine3 = std::function<void(const Arguments<T>&,
+ const Buffer&, const Buffer&, const Buffer&,
+ CommandQueue&)>;
+
+// =================================================================================================
+
+// These are the main client functions, setting-up arguments, matrices, OpenCL buffers, etc. After
+// set-up, they call the client routine, passed as argument to this function.
+template <typename T>
+void ClientXY(int argc, char *argv[], Routine2<T> client_routine,
+ const std::vector<std::string> &options);
+template <typename T>
+void ClientABC(int argc, char *argv[], Routine3<T> client_routine,
+ const std::vector<std::string> &options);
+
+// =================================================================================================
+
+// Parses all command-line arguments, filling in the arguments structure. If no command-line
+// argument is given for a particular argument, it is filled in with a default value.
+template <typename T>
+Arguments<T> ParseArguments(int argc, char *argv[], const std::vector<std::string> &options);
+
+// Retrieves only the precision command-line argument, since the above function is templated based
+// on the precision
+Precision GetPrecision(int argc, char *argv[]);
+
+// =================================================================================================
+
+// Runs a function a given number of times and returns the execution time of the shortest instance
+double TimedExecution(const size_t num_runs, std::function<void()> main_computation);
+
+// =================================================================================================
+
+// Prints the header of a performance-data table
+void PrintTableHeader(const bool silent, const std::vector<std::string> &args);
+
+// Prints a row of performance data, including results of two libraries
+void PrintTableRow(const std::vector<size_t> &args_int, const std::vector<std::string> &args_string,
+ const bool abbreviations, const double ms_clblast, const double ms_clblas,
+ const unsigned long long flops, const unsigned long long bytes);
+
+// =================================================================================================
+} // namespace clblast
+
+// CLBLAST_TEST_PERFORMANCE_CLIENT_H_
+#endif