summaryrefslogtreecommitdiff
path: root/test/correctness/routines
diff options
context:
space:
mode:
authorCNugteren <web@cedricnugteren.nl>2015-06-24 07:50:18 +0200
committerCNugteren <web@cedricnugteren.nl>2015-06-24 07:50:18 +0200
commit60a88aac8672d360eb05ba25b1c4ffbf53a78dff (patch)
tree25b6c8d59b293b3c7e0d7fb48bb8b6ca64a1f2d9 /test/correctness/routines
parenta17297937d757d9747adde600f832d1e0c2753c1 (diff)
Added the SYRK routine, tester, and client
Diffstat (limited to 'test/correctness/routines')
-rw-r--r--test/correctness/routines/xsyrk.cc96
1 files changed, 96 insertions, 0 deletions
diff --git a/test/correctness/routines/xsyrk.cc b/test/correctness/routines/xsyrk.cc
new file mode 100644
index 00000000..8d3bd82e
--- /dev/null
+++ b/test/correctness/routines/xsyrk.cc
@@ -0,0 +1,96 @@
+
+// =================================================================================================
+// This file is part of the CLBlast project. The project is licensed under the MIT license. 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 tests for the Xsyrk routine. It is based on the TestAC class.
+//
+// =================================================================================================
+
+#include "wrapper_clblas.h"
+#include "correctness/testac.h"
+
+namespace clblast {
+// =================================================================================================
+
+// The correctness tester, containing the function calls to CLBlast and to clBLAS for comparison.
+template <typename T>
+void XsyrkTest(int argc, char *argv[], const bool silent, const std::string &name) {
+
+ // Creates the CLBlast lambda
+ auto clblast_lambda = [](const Arguments<T> &args,
+ const Buffer &a_mat, const Buffer &c_mat,
+ CommandQueue &queue) -> StatusCode {
+ auto queue_plain = queue();
+ auto event = cl_event{};
+ return Syrk(args.layout, args.triangle, args.a_transpose,
+ args.n, args.k,
+ args.alpha,
+ a_mat(), args.a_offset, args.a_ld,
+ args.beta,
+ c_mat(), args.c_offset, args.c_ld,
+ &queue_plain, &event);
+ };
+
+ // Creates the clBLAS lambda (for comparison)
+ auto clblas_lambda = [](const Arguments<T> &args,
+ const Buffer &a_mat, const Buffer &c_mat,
+ CommandQueue &queue) -> StatusCode {
+ auto queue_plain = queue();
+ auto event = cl_event{};
+ auto status = clblasXsyrk(static_cast<clblasOrder>(args.layout),
+ static_cast<clblasUplo>(args.triangle),
+ static_cast<clblasTranspose>(args.a_transpose),
+ args.n, args.k,
+ args.alpha,
+ a_mat(), args.a_offset, args.a_ld,
+ args.beta,
+ c_mat(), args.c_offset, args.c_ld,
+ 1, &queue_plain, 0, nullptr, &event);
+ return static_cast<StatusCode>(status);
+ };
+
+ // Initializes the arguments relevant for this routine
+ auto args = Arguments<T>{};
+ const auto options = std::vector<std::string>{kArgN, kArgK, kArgLayout,
+ kArgTriangle, kArgATransp,
+ kArgALeadDim, kArgCLeadDim,
+ kArgAOffset, kArgCOffset};
+
+ // Creates a tester
+ TestAC<T> tester{argc, argv, silent, name, options, clblast_lambda, clblas_lambda};
+
+ // Loops over the test-cases from a data-layout point of view
+ for (auto &layout: tester.kLayouts) {
+ args.layout = layout;
+ for (auto &triangle: {Triangle::kUpper, Triangle::kLower}) {
+ args.triangle = triangle;
+ for (auto &a_transpose: {Transpose::kNo, Transpose::kYes}) { // No conjugate here since it is
+ args.a_transpose = a_transpose; // not supported by clBLAS
+ const auto case_name = ToString(layout)+" "+ToString(triangle)+" "+ToString(a_transpose);
+
+ // Runs the tests
+ tester.TestRegular(args, case_name);
+ tester.TestInvalidBufferSizes(args, case_name);
+ }
+ }
+ }
+}
+
+// =================================================================================================
+} // namespace clblast
+
+// Main function (not within the clblast namespace)
+int main(int argc, char *argv[]) {
+ clblast::XsyrkTest<float>(argc, argv, false, "SSYRK");
+ clblast::XsyrkTest<double>(argc, argv, true, "DSYRK");
+ clblast::XsyrkTest<clblast::float2>(argc, argv, true, "CSYRK");
+ clblast::XsyrkTest<clblast::double2>(argc, argv, true, "ZSYRK");
+ return 0;
+}
+
+// =================================================================================================