summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorCedric Nugteren <web@cedricnugteren.nl>2017-08-12 20:50:00 +0200
committerCedric Nugteren <web@cedricnugteren.nl>2017-08-12 20:50:00 +0200
commit777681dcbdf18493320dd7b94fccd5c6faee9455 (patch)
treeb8597f5d79f8ef33bffbf33f3de2548cc51d4c5c /test
parent97bcf77d4bc9b31e32a8785787e0497ac5440e44 (diff)
parentd67fd6604b4a6584c4f9e856057fcc8076ce377d (diff)
Merge branch 'master' into im_to_col
Diffstat (limited to 'test')
-rw-r--r--test/correctness/misc/override_parameters.cpp7
-rw-r--r--test/correctness/testblas.cpp10
-rw-r--r--test/correctness/testblas.hpp6
-rw-r--r--test/correctness/tester.cpp24
-rw-r--r--test/correctness/tester.hpp44
-rw-r--r--test/performance/client.hpp2
-rw-r--r--test/routines/common.hpp1
-rw-r--r--test/routines/levelx/xgemmbatched.hpp9
-rw-r--r--test/test_utilities.cpp114
-rw-r--r--test/test_utilities.hpp99
10 files changed, 282 insertions, 34 deletions
diff --git a/test/correctness/misc/override_parameters.cpp b/test/correctness/misc/override_parameters.cpp
index 4283c039..535d9286 100644
--- a/test/correctness/misc/override_parameters.cpp
+++ b/test/correctness/misc/override_parameters.cpp
@@ -15,6 +15,7 @@
#include <vector>
#include <unordered_map>
#include <random>
+#include <iostream>
#include "utilities/utilities.hpp"
#include "test/routines/level3/xgemm.hpp"
@@ -120,9 +121,9 @@ size_t RunOverrideTests(int argc, char *argv[], const bool silent, const std::st
}
// Prints and returns the statistics
- fprintf(stdout, " %zu test(s) passed\n", passed);
- fprintf(stdout, " %zu test(s) failed\n", errors);
- fprintf(stdout, "\n");
+ std::cout << " " << passed << " test(s) passed" << std::endl;
+ std::cout << " " << errors << " test(s) failed" << std::endl;
+ std::cout << std::endl;
return errors;
}
diff --git a/test/correctness/testblas.cpp b/test/correctness/testblas.cpp
index edd9d4ea..659131c5 100644
--- a/test/correctness/testblas.cpp
+++ b/test/correctness/testblas.cpp
@@ -198,12 +198,12 @@ void TestBlas<T,U>::TestRegular(std::vector<Arguments<U>> &test_vector, const st
if (!TestSimilarity(result1[index], result2[index])) {
if (l2error >= kErrorMarginL2) { errors++; }
if (verbose_) {
- if (get_id2_(args) == 1) { fprintf(stdout, "\n Error at index %zu: ", id1); }
- else { fprintf(stdout, "\n Error at %zu,%zu: ", id1, id2); }
- fprintf(stdout, " %s (reference) versus ", ToString(result1[index]).c_str());
- fprintf(stdout, " %s (CLBlast)", ToString(result2[index]).c_str());
+ if (get_id2_(args) == 1) { std::cout << std::endl << " Error at index " << id1 << ": "; }
+ else { std::cout << std::endl << " Error at " << id1 << "," << id2 << ": "; }
+ std::cout << " " << ToString(result1[index]) << " (reference) versus ";
+ std::cout << " " << ToString(result2[index]) << " (CLBlast)";
if (l2error < kErrorMarginL2) {
- fprintf(stdout, " - error suppressed by a low total L2 error\n");
+ std::cout << " - error suppressed by a low total L2 error" << std::endl;
}
}
}
diff --git a/test/correctness/testblas.hpp b/test/correctness/testblas.hpp
index 577a289e..1c0cf9e3 100644
--- a/test/correctness/testblas.hpp
+++ b/test/correctness/testblas.hpp
@@ -391,6 +391,12 @@ size_t RunTests(int argc, char *argv[], const bool silent, const std::string &na
auto i_args = args;
i_args.m = i_args.n = i_args.k = i_args.kl = i_args.ku = tester.kBufferSize;
i_args.a_ld = i_args.b_ld = i_args.c_ld = tester.kBufferSize;
+ i_args.batch_count = 3;
+ i_args.alphas = std::vector<U>(i_args.batch_count);
+ i_args.betas = std::vector<U>(i_args.batch_count);
+ i_args.a_offsets = std::vector<size_t>(i_args.batch_count);
+ i_args.b_offsets = std::vector<size_t>(i_args.batch_count);
+ i_args.c_offsets = std::vector<size_t>(i_args.batch_count);
for (auto &x_size: x_sizes) { i_args.x_size = x_size;
for (auto &y_size: y_sizes) { i_args.y_size = y_size;
for (auto &a_size: a_sizes) { i_args.a_size = a_size;
diff --git a/test/correctness/tester.cpp b/test/correctness/tester.cpp
index 1581fbfb..648aef6e 100644
--- a/test/correctness/tester.cpp
+++ b/test/correctness/tester.cpp
@@ -185,14 +185,14 @@ Tester<T,U>::Tester(const std::vector<std::string> &arguments, const bool silent
template <typename T, typename U>
Tester<T,U>::~Tester() {
if (PrecisionSupported<T>(device_)) {
- fprintf(stdout, "* Completed all test-cases for this routine. Results:\n");
- fprintf(stdout, " %zu test(s) passed\n", tests_passed_);
- if (tests_skipped_ > 0) { fprintf(stdout, "%s", kPrintWarning.c_str()); }
- fprintf(stdout, " %zu test(s) skipped%s\n", tests_skipped_, kPrintEnd.c_str());
- if (tests_failed_ > 0) { fprintf(stdout, "%s", kPrintError.c_str()); }
- fprintf(stdout, " %zu test(s) failed%s\n", tests_failed_, kPrintEnd.c_str());
+ std::cout << "* Completed all test-cases for this routine. Results:" << std::endl;
+ std::cout << " " << tests_passed_ << " test(s) passed" << std::endl;
+ if (tests_skipped_ > 0) { std::cout << kPrintWarning; }
+ std::cout << " " << tests_skipped_ << " test(s) skipped" << kPrintEnd << std::endl;
+ if (tests_failed_ > 0) { std::cout << kPrintError; }
+ std::cout << " " << tests_failed_ << " test(s) failed" << kPrintEnd << std::endl;
}
- fprintf(stdout, "\n");
+ std::cout << std::endl;
// Cleans-up clBLAS
#ifdef CLBLAST_REF_CLBLAS
@@ -238,18 +238,18 @@ void Tester<T,U>::TestEnd() {
// Prints a test summary
auto pass_rate = 100*num_passed_ / static_cast<float>(num_passed_ + num_skipped_ + num_failed_);
fprintf(stdout, " Pass rate %s%5.1lf%%%s:", kPrintMessage.c_str(), pass_rate, kPrintEnd.c_str());
- fprintf(stdout, " %zu passed /", num_passed_);
+ std::cout << " " << num_passed_ << " passed /";
if (num_skipped_ != 0) {
- fprintf(stdout, " %s%zu skipped%s /", kPrintWarning.c_str(), num_skipped_, kPrintEnd.c_str());
+ std::cout << " " << kPrintWarning << num_skipped_ << " skipped" << kPrintEnd << " /";
}
else {
- fprintf(stdout, " %zu skipped /", num_skipped_);
+ std::cout << " " << num_skipped_ << " skipped /";
}
if (num_failed_ != 0) {
- fprintf(stdout, " %s%zu failed%s\n", kPrintError.c_str(), num_failed_, kPrintEnd.c_str());
+ std::cout << " " << kPrintError << num_failed_ << " failed" << kPrintEnd << std::endl;
}
else {
- fprintf(stdout, " %zu failed\n", num_failed_);
+ std::cout << " " << num_failed_ << " failed" << std::endl;
}
}
diff --git a/test/correctness/tester.hpp b/test/correctness/tester.hpp
index e544f776..caf03787 100644
--- a/test/correctness/tester.hpp
+++ b/test/correctness/tester.hpp
@@ -22,7 +22,7 @@
#include <vector>
#include <memory>
-#include "utilities/utilities.hpp"
+#include "test/test_utilities.hpp"
// The libraries
#ifdef CLBLAST_REF_CLBLAS
@@ -153,20 +153,38 @@ template <typename T, typename U> const size_t Tester<T,U>::kResultsPerLine = si
template <typename T, typename U> const float Tester<T,U>::kStatusError = -1.0f;
// Constants holding start and end strings for terminal-output in colour
-template <typename T, typename U> const std::string Tester<T,U>::kPrintError = "\x1b[31m";
-template <typename T, typename U> const std::string Tester<T,U>::kPrintSuccess = "\x1b[32m";
-template <typename T, typename U> const std::string Tester<T,U>::kPrintWarning = "\x1b[35m";
-template <typename T, typename U> const std::string Tester<T,U>::kPrintMessage = "\x1b[1m";
-template <typename T, typename U> const std::string Tester<T,U>::kPrintEnd = "\x1b[0m";
+#if defined(_WIN32)
+ template <typename T, typename U> const std::string Tester<T,U>::kPrintError = "";
+ template <typename T, typename U> const std::string Tester<T,U>::kPrintSuccess = "";
+ template <typename T, typename U> const std::string Tester<T,U>::kPrintWarning = "";
+ template <typename T, typename U> const std::string Tester<T,U>::kPrintMessage = "";
+ template <typename T, typename U> const std::string Tester<T,U>::kPrintEnd = "";
+#else
+ template <typename T, typename U> const std::string Tester<T,U>::kPrintError = "\x1b[31m";
+ template <typename T, typename U> const std::string Tester<T,U>::kPrintSuccess = "\x1b[32m";
+ template <typename T, typename U> const std::string Tester<T,U>::kPrintWarning = "\x1b[35m";
+ template <typename T, typename U> const std::string Tester<T,U>::kPrintMessage = "\x1b[1m";
+ template <typename T, typename U> const std::string Tester<T,U>::kPrintEnd = "\x1b[0m";
+#endif
// Sets the output error coding
-template <typename T, typename U> const std::string Tester<T,U>::kSuccessData = "\x1b[32m:\x1b[0m"; // success
-template <typename T, typename U> const std::string Tester<T,U>::kSuccessStatus = "\x1b[32m.\x1b[0m"; // success
-template <typename T, typename U> const std::string Tester<T,U>::kErrorData = "\x1b[31mX\x1b[0m"; // error
-template <typename T, typename U> const std::string Tester<T,U>::kErrorStatus = "\x1b[31m/\x1b[0m"; // error
-template <typename T, typename U> const std::string Tester<T,U>::kSkippedCompilation = "\x1b[35m\\\x1b[0m"; // warning
-template <typename T, typename U> const std::string Tester<T,U>::kUnsupportedPrecision = "\x1b[35mo\x1b[0m"; // warning
-template <typename T, typename U> const std::string Tester<T,U>::kUnsupportedReference = "\x1b[35m-\x1b[0m"; // warning
+#if defined(_WIN32)
+ template <typename T, typename U> const std::string Tester<T,U>::kSuccessData = ":"; // success
+ template <typename T, typename U> const std::string Tester<T,U>::kSuccessStatus = "."; // success
+ template <typename T, typename U> const std::string Tester<T,U>::kErrorData = "X"; // error
+ template <typename T, typename U> const std::string Tester<T,U>::kErrorStatus = "/"; // error
+ template <typename T, typename U> const std::string Tester<T,U>::kSkippedCompilation = "\\"; // warning
+ template <typename T, typename U> const std::string Tester<T,U>::kUnsupportedPrecision = "o"; // warning
+ template <typename T, typename U> const std::string Tester<T,U>::kUnsupportedReference = "-"; // warning
+#else
+ template <typename T, typename U> const std::string Tester<T,U>::kSuccessData = "\x1b[32m:\x1b[0m"; // success
+ template <typename T, typename U> const std::string Tester<T,U>::kSuccessStatus = "\x1b[32m.\x1b[0m"; // success
+ template <typename T, typename U> const std::string Tester<T,U>::kErrorData = "\x1b[31mX\x1b[0m"; // error
+ template <typename T, typename U> const std::string Tester<T,U>::kErrorStatus = "\x1b[31m/\x1b[0m"; // error
+ template <typename T, typename U> const std::string Tester<T,U>::kSkippedCompilation = "\x1b[35m\\\x1b[0m"; // warning
+ template <typename T, typename U> const std::string Tester<T,U>::kUnsupportedPrecision = "\x1b[35mo\x1b[0m"; // warning
+ template <typename T, typename U> const std::string Tester<T,U>::kUnsupportedReference = "\x1b[35m-\x1b[0m"; // warning
+#endif
// =================================================================================================
// Below are the non-member functions (separated because of otherwise required partial class
diff --git a/test/performance/client.hpp b/test/performance/client.hpp
index 47a13017..2ba09cb9 100644
--- a/test/performance/client.hpp
+++ b/test/performance/client.hpp
@@ -25,7 +25,7 @@
#include <vector>
#include <utility>
-#include "utilities/utilities.hpp"
+#include "test/test_utilities.hpp"
// The libraries to test
#ifdef CLBLAST_REF_CLBLAS
diff --git a/test/routines/common.hpp b/test/routines/common.hpp
index 9708288a..47c8f8d7 100644
--- a/test/routines/common.hpp
+++ b/test/routines/common.hpp
@@ -18,6 +18,7 @@
#include <string>
#include "utilities/utilities.hpp"
+#include "test/test_utilities.hpp"
#ifdef CLBLAST_REF_CLBLAS
#include "test/wrapper_clblas.hpp"
diff --git a/test/routines/levelx/xgemmbatched.hpp b/test/routines/levelx/xgemmbatched.hpp
index 56823e47..704d0578 100644
--- a/test/routines/levelx/xgemmbatched.hpp
+++ b/test/routines/levelx/xgemmbatched.hpp
@@ -110,6 +110,15 @@ class TestXgemmBatched {
static StatusCode RunRoutine(const Arguments<T> &args, Buffers<T> &buffers, Queue &queue) {
auto queue_plain = queue();
auto event = cl_event{};
+ // Relaxed requirement on ld_a and ld_b within the library, this is here to match clBLAS
+ auto a_rotated = (args.layout == Layout::kColMajor && args.a_transpose != Transpose::kNo) ||
+ (args.layout == Layout::kRowMajor && args.a_transpose == Transpose::kNo);
+ auto b_rotated = (args.layout == Layout::kColMajor && args.b_transpose != Transpose::kNo) ||
+ (args.layout == Layout::kRowMajor && args.b_transpose == Transpose::kNo);
+ auto a_one = (!a_rotated) ? args.m : args.k;
+ auto b_one = (!b_rotated) ? args.k : args.n;
+ if (args.a_ld < a_one) { return StatusCode::kInvalidLeadDimA; }
+ if (args.b_ld < b_one) { return StatusCode::kInvalidLeadDimB; }
auto status = GemmBatched(args.layout, args.a_transpose, args.b_transpose,
args.m, args.n, args.k, args.alphas.data(),
buffers.a_mat(), args.a_offsets.data(), args.a_ld,
diff --git a/test/test_utilities.cpp b/test/test_utilities.cpp
new file mode 100644
index 00000000..b8fd94a9
--- /dev/null
+++ b/test/test_utilities.cpp
@@ -0,0 +1,114 @@
+
+// =================================================================================================
+// 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 implements the test utility functions.
+//
+// =================================================================================================
+
+#include "test/test_utilities.hpp"
+
+#include <string>
+#include <vector>
+
+namespace clblast {
+// =================================================================================================
+
+// Returns whether a scalar is close to zero
+template <typename T> bool IsCloseToZero(const T value) { return (value > -SmallConstant<T>()) && (value < SmallConstant<T>()); }
+template bool IsCloseToZero<float>(const float);
+template bool IsCloseToZero<double>(const double);
+template <> bool IsCloseToZero(const half value) { return IsCloseToZero(HalfToFloat(value)); }
+template <> bool IsCloseToZero(const float2 value) { return IsCloseToZero(value.real()) || IsCloseToZero(value.imag()); }
+template <> bool IsCloseToZero(const double2 value) { return IsCloseToZero(value.real()) || IsCloseToZero(value.imag()); }
+
+// =================================================================================================
+
+template <typename T, typename U>
+void DeviceToHost(const Arguments<U> &args, Buffers<T> &buffers, BuffersHost<T> &buffers_host,
+ Queue &queue, const std::vector<std::string> &names) {
+ for (auto &name: names) {
+ if (name == kBufVecX) {buffers_host.x_vec = std::vector<T>(args.x_size, static_cast<T>(0)); buffers.x_vec.Read(queue, args.x_size, buffers_host.x_vec); }
+ else if (name == kBufVecY) { buffers_host.y_vec = std::vector<T>(args.y_size, static_cast<T>(0)); buffers.y_vec.Read(queue, args.y_size, buffers_host.y_vec); }
+ else if (name == kBufMatA) { buffers_host.a_mat = std::vector<T>(args.a_size, static_cast<T>(0)); buffers.a_mat.Read(queue, args.a_size, buffers_host.a_mat); }
+ else if (name == kBufMatB) { buffers_host.b_mat = std::vector<T>(args.b_size, static_cast<T>(0)); buffers.b_mat.Read(queue, args.b_size, buffers_host.b_mat); }
+ else if (name == kBufMatC) { buffers_host.c_mat = std::vector<T>(args.c_size, static_cast<T>(0)); buffers.c_mat.Read(queue, args.c_size, buffers_host.c_mat); }
+ else if (name == kBufMatAP) { buffers_host.ap_mat = std::vector<T>(args.ap_size, static_cast<T>(0)); buffers.ap_mat.Read(queue, args.ap_size, buffers_host.ap_mat); }
+ else if (name == kBufScalar) { buffers_host.scalar = std::vector<T>(args.scalar_size, static_cast<T>(0)); buffers.scalar.Read(queue, args.scalar_size, buffers_host.scalar); }
+ else { throw std::runtime_error("Invalid buffer name"); }
+ }
+}
+
+template <typename T, typename U>
+void HostToDevice(const Arguments<U> &args, Buffers<T> &buffers, BuffersHost<T> &buffers_host,
+ Queue &queue, const std::vector<std::string> &names) {
+ for (auto &name: names) {
+ if (name == kBufVecX) { buffers.x_vec.Write(queue, args.x_size, buffers_host.x_vec); }
+ else if (name == kBufVecY) { buffers.y_vec.Write(queue, args.y_size, buffers_host.y_vec); }
+ else if (name == kBufMatA) { buffers.a_mat.Write(queue, args.a_size, buffers_host.a_mat); }
+ else if (name == kBufMatB) { buffers.b_mat.Write(queue, args.b_size, buffers_host.b_mat); }
+ else if (name == kBufMatC) { buffers.c_mat.Write(queue, args.c_size, buffers_host.c_mat); }
+ else if (name == kBufMatAP) { buffers.ap_mat.Write(queue, args.ap_size, buffers_host.ap_mat); }
+ else if (name == kBufScalar) { buffers.scalar.Write(queue, args.scalar_size, buffers_host.scalar); }
+ else { throw std::runtime_error("Invalid buffer name"); }
+ }
+}
+
+// Compiles the above functions
+template void DeviceToHost(const Arguments<half>&, Buffers<half>&, BuffersHost<half>&, Queue&, const std::vector<std::string>&);
+template void DeviceToHost(const Arguments<float>&, Buffers<float>&, BuffersHost<float>&, Queue&, const std::vector<std::string>&);
+template void DeviceToHost(const Arguments<double>&, Buffers<double>&, BuffersHost<double>&, Queue&, const std::vector<std::string>&);
+template void DeviceToHost(const Arguments<float>&, Buffers<float2>&, BuffersHost<float2>&, Queue&, const std::vector<std::string>&);
+template void DeviceToHost(const Arguments<double>&, Buffers<double2>&, BuffersHost<double2>&, Queue&, const std::vector<std::string>&);
+template void DeviceToHost(const Arguments<float2>&, Buffers<float2>&, BuffersHost<float2>&, Queue&, const std::vector<std::string>&);
+template void DeviceToHost(const Arguments<double2>&, Buffers<double2>&, BuffersHost<double2>&, Queue&, const std::vector<std::string>&);
+template void HostToDevice(const Arguments<half>&, Buffers<half>&, BuffersHost<half>&, Queue&, const std::vector<std::string>&);
+template void HostToDevice(const Arguments<float>&, Buffers<float>&, BuffersHost<float>&, Queue&, const std::vector<std::string>&);
+template void HostToDevice(const Arguments<double>&, Buffers<double>&, BuffersHost<double>&, Queue&, const std::vector<std::string>&);
+template void HostToDevice(const Arguments<float>&, Buffers<float2>&, BuffersHost<float2>&, Queue&, const std::vector<std::string>&);
+template void HostToDevice(const Arguments<double>&, Buffers<double2>&, BuffersHost<double2>&, Queue&, const std::vector<std::string>&);
+template void HostToDevice(const Arguments<float2>&, Buffers<float2>&, BuffersHost<float2>&, Queue&, const std::vector<std::string>&);
+template void HostToDevice(const Arguments<double2>&, Buffers<double2>&, BuffersHost<double2>&, Queue&, const std::vector<std::string>&);
+
+// =================================================================================================
+
+// Conversion between half and single-precision
+std::vector<float> HalfToFloatBuffer(const std::vector<half>& source) {
+ auto result = std::vector<float>(source.size());
+ for (auto i = size_t(0); i < source.size(); ++i) { result[i] = HalfToFloat(source[i]); }
+ return result;
+}
+void FloatToHalfBuffer(std::vector<half>& result, const std::vector<float>& source) {
+ for (auto i = size_t(0); i < source.size(); ++i) { result[i] = FloatToHalf(source[i]); }
+}
+
+// As above, but now for OpenCL data-types instead of std::vectors
+Buffer<float> HalfToFloatBuffer(const Buffer<half>& source, cl_command_queue queue_raw) {
+ const auto size = source.GetSize() / sizeof(half);
+ auto queue = Queue(queue_raw);
+ auto context = queue.GetContext();
+ auto source_cpu = std::vector<half>(size);
+ source.Read(queue, size, source_cpu);
+ auto result_cpu = HalfToFloatBuffer(source_cpu);
+ auto result = Buffer<float>(context, size);
+ result.Write(queue, size, result_cpu);
+ return result;
+}
+void FloatToHalfBuffer(Buffer<half>& result, const Buffer<float>& source, cl_command_queue queue_raw) {
+ const auto size = source.GetSize() / sizeof(float);
+ auto queue = Queue(queue_raw);
+ auto context = queue.GetContext();
+ auto source_cpu = std::vector<float>(size);
+ source.Read(queue, size, source_cpu);
+ auto result_cpu = std::vector<half>(size);
+ FloatToHalfBuffer(result_cpu, source_cpu);
+ result.Write(queue, size, result_cpu);
+}
+
+// =================================================================================================
+} // namespace clblast
diff --git a/test/test_utilities.hpp b/test/test_utilities.hpp
new file mode 100644
index 00000000..fc50a754
--- /dev/null
+++ b/test/test_utilities.hpp
@@ -0,0 +1,99 @@
+
+// =================================================================================================
+// 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 declarations for the common test utility functions (performance clients and
+// correctness testers).
+//
+// =================================================================================================
+
+#ifndef CLBLAST_TEST_UTILITIES_H_
+#define CLBLAST_TEST_UTILITIES_H_
+
+#include <string>
+
+#include "utilities/utilities.hpp"
+
+namespace clblast {
+// =================================================================================================
+
+// The client-specific arguments in string form
+constexpr auto kArgCompareclblas = "clblas";
+constexpr auto kArgComparecblas = "cblas";
+constexpr auto kArgComparecublas = "cublas";
+constexpr auto kArgStepSize = "step";
+constexpr auto kArgNumSteps = "num_steps";
+constexpr auto kArgWarmUp = "warm_up";
+
+// The test-specific arguments in string form
+constexpr auto kArgFullTest = "full_test";
+constexpr auto kArgVerbose = "verbose";
+
+// =================================================================================================
+
+// Returns whether a scalar is close to zero
+template <typename T> bool IsCloseToZero(const T value);
+
+// =================================================================================================
+
+// Structure containing all possible buffers for test clients
+template <typename T>
+struct Buffers {
+ Buffer<T> x_vec;
+ Buffer<T> y_vec;
+ Buffer<T> a_mat;
+ Buffer<T> b_mat;
+ Buffer<T> c_mat;
+ Buffer<T> ap_mat;
+ Buffer<T> scalar;
+};
+template <typename T>
+struct BuffersHost {
+ std::vector<T> x_vec;
+ std::vector<T> y_vec;
+ std::vector<T> a_mat;
+ std::vector<T> b_mat;
+ std::vector<T> c_mat;
+ std::vector<T> ap_mat;
+ std::vector<T> scalar;
+};
+
+// =================================================================================================
+
+// Converts a value (e.g. an integer) to a string. This also covers special cases for CLBlast
+// data-types such as the Layout and Transpose data-types.
+template <typename T>
+std::string ToString(T value);
+
+// =================================================================================================
+
+// Copies buffers from the OpenCL device to the host
+template <typename T, typename U>
+void DeviceToHost(const Arguments<U> &args, Buffers<T> &buffers, BuffersHost<T> &buffers_host,
+ Queue &queue, const std::vector<std::string> &names);
+
+// Copies buffers from the host to the OpenCL device
+template <typename T, typename U>
+void HostToDevice(const Arguments<U> &args, Buffers<T> &buffers, BuffersHost<T> &buffers_host,
+ Queue &queue, const std::vector<std::string> &names);
+
+// =================================================================================================
+
+// Conversion between half and single-precision
+std::vector<float> HalfToFloatBuffer(const std::vector<half>& source);
+void FloatToHalfBuffer(std::vector<half>& result, const std::vector<float>& source);
+
+// As above, but now for OpenCL data-types instead of std::vectors
+Buffer<float> HalfToFloatBuffer(const Buffer<half>& source, cl_command_queue queue_raw);
+void FloatToHalfBuffer(Buffer<half>& result, const Buffer<float>& source, cl_command_queue queue_raw);
+
+// =================================================================================================
+} // namespace clblast
+
+// CLBLAST_TEST_UTILITIES_H_
+#endif