summaryrefslogtreecommitdiff
path: root/test/correctness/routines
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/correctness/routines
parentc7b054ea6747039f4405fd93da6e924f3e5c7f4b (diff)
Initial commit of preview version
Diffstat (limited to 'test/correctness/routines')
-rw-r--r--test/correctness/routines/xaxpy.cc81
-rw-r--r--test/correctness/routines/xgemm.cc104
-rw-r--r--test/correctness/routines/xsymm.cc104
3 files changed, 289 insertions, 0 deletions
diff --git a/test/correctness/routines/xaxpy.cc b/test/correctness/routines/xaxpy.cc
new file mode 100644
index 00000000..aa90766e
--- /dev/null
+++ b/test/correctness/routines/xaxpy.cc
@@ -0,0 +1,81 @@
+
+// =================================================================================================
+// 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 Xaxpy routine. It is based on the TestXY class.
+//
+// =================================================================================================
+
+#include "wrapper_clblas.h"
+#include "correctness/testxy.h"
+
+namespace clblast {
+// =================================================================================================
+
+// The correctness tester, containing the function calls to CLBlast and to clBLAS for comparison.
+template <typename T>
+void XaxpyTest(int argc, char *argv[], const bool silent, const std::string &name) {
+
+ // Creates the CLBlast lambda
+ auto clblast_lambda = [](const Arguments<T> &args,
+ const Buffer &x_vec, const Buffer &y_vec,
+ CommandQueue &queue) -> StatusCode {
+ auto queue_plain = queue();
+ auto event = cl_event{};
+ return Axpy(args.n, args.alpha,
+ x_vec(), args.x_offset, args.x_inc,
+ y_vec(), args.y_offset, args.y_inc,
+ &queue_plain, &event);
+ };
+
+ // Creates the clBLAS lambda (for comparison)
+ auto clblas_lambda = [](const Arguments<T> &args,
+ const Buffer &x_vec, const Buffer &y_vec,
+ CommandQueue &queue) -> StatusCode {
+ auto queue_plain = queue();
+ auto event = cl_event{};
+ auto status = clblasXaxpy(args.n, args.alpha,
+ x_vec(), args.x_offset, args.x_inc,
+ y_vec(), args.y_offset, args.y_inc,
+ 1, &queue_plain, 0, nullptr, &event);
+ return static_cast<StatusCode>(status);
+ };
+
+ // Selects the platform and device on which to test (command-line options)
+ auto help = std::string{"Options given/available:\n"};
+ const auto platform_id = GetArgument(argc, argv, help, kArgPlatform, size_t{0});
+ const auto device_id = GetArgument(argc, argv, help, kArgDevice, size_t{0});
+ if (!silent) { fprintf(stdout, "\n* %s\n", help.c_str()); }
+
+ // Initializes the other arguments relevant for this routine
+ auto args = Arguments<T>{};
+ const auto options = std::vector<std::string>{kArgN, kArgXInc, kArgYInc,
+ kArgXOffset, kArgYOffset, kArgAlpha};
+
+ // Creates a tester
+ TestXY<T> tester{platform_id, device_id, name, options, clblast_lambda, clblas_lambda};
+
+ // Runs the tests
+ const auto case_name = "default";
+ 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::XaxpyTest<float>(argc, argv, false, "SAXPY");
+ clblast::XaxpyTest<double>(argc, argv, true, "DAXPY");
+ clblast::XaxpyTest<clblast::float2>(argc, argv, true, "CAXPY");
+ clblast::XaxpyTest<clblast::double2>(argc, argv, true, "ZAXPY");
+ return 0;
+}
+
+// =================================================================================================
diff --git a/test/correctness/routines/xgemm.cc b/test/correctness/routines/xgemm.cc
new file mode 100644
index 00000000..04525cc5
--- /dev/null
+++ b/test/correctness/routines/xgemm.cc
@@ -0,0 +1,104 @@
+
+// =================================================================================================
+// 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 Xgemm routine. It is based on the TestABC class.
+//
+// =================================================================================================
+
+#include "wrapper_clblas.h"
+#include "correctness/testabc.h"
+
+namespace clblast {
+// =================================================================================================
+
+// The correctness tester, containing the function calls to CLBlast and to clBLAS for comparison.
+template <typename T>
+void XgemmTest(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 &b_mat, const Buffer &c_mat,
+ CommandQueue &queue) -> StatusCode {
+ auto queue_plain = queue();
+ auto event = cl_event{};
+ return Gemm(args.layout, args.a_transpose, args.b_transpose,
+ args.m, args.n, args.k,
+ args.alpha,
+ a_mat(), args.a_offset, args.a_ld,
+ b_mat(), args.b_offset, args.b_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 &b_mat, const Buffer &c_mat,
+ CommandQueue &queue) -> StatusCode {
+ auto queue_plain = queue();
+ auto event = cl_event{};
+ auto status = clblasXgemm(static_cast<clblasOrder>(args.layout),
+ static_cast<clblasTranspose>(args.a_transpose),
+ static_cast<clblasTranspose>(args.b_transpose),
+ args.m, args.n, args.k,
+ args.alpha,
+ a_mat(), args.a_offset, args.a_ld,
+ b_mat(), args.b_offset, args.b_ld,
+ args.beta,
+ c_mat(), args.c_offset, args.c_ld,
+ 1, &queue_plain, 0, nullptr, &event);
+ return static_cast<StatusCode>(status);
+ };
+
+ // Selects the platform and device on which to test (command-line options)
+ auto help = std::string{"Options given/available:\n"};
+ const auto platform_id = GetArgument(argc, argv, help, kArgPlatform, size_t{0});
+ const auto device_id = GetArgument(argc, argv, help, kArgDevice, size_t{0});
+ if (!silent) { fprintf(stdout, "\n* %s\n", help.c_str()); }
+
+ // Initializes the other arguments relevant for this routine
+ auto args = Arguments<T>{};
+ const auto options = std::vector<std::string>{kArgM, kArgN, kArgK, kArgLayout,
+ kArgATransp, kArgBTransp,
+ kArgALeadDim, kArgBLeadDim, kArgCLeadDim,
+ kArgAOffset, kArgBOffset, kArgCOffset};
+
+ // Creates a tester
+ TestABC<T> tester{platform_id, device_id, name, options, clblast_lambda, clblas_lambda};
+
+ // Loops over the test-cases from a data-layout point of view
+ for (auto &layout: {Layout::kRowMajor, Layout::kColMajor}) {
+ args.layout = layout;
+ for (auto &a_transpose: {Transpose::kNo, Transpose::kYes}) {
+ args.a_transpose = a_transpose;
+ for (auto &b_transpose: {Transpose::kNo, Transpose::kYes}) {
+ args.b_transpose = b_transpose;
+ const auto case_name = ToString(layout)+" "+ToString(a_transpose)+" "+ToString(b_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::XgemmTest<float>(argc, argv, false, "SGEMM");
+ clblast::XgemmTest<double>(argc, argv, true, "DGEMM");
+ //clblast::XgemmTest<float2>(argc, argv, true, "CGEMM");
+ //clblast::XgemmTest<double2>(argc, argv, true, "ZGEMM");
+ return 0;
+}
+
+// =================================================================================================
diff --git a/test/correctness/routines/xsymm.cc b/test/correctness/routines/xsymm.cc
new file mode 100644
index 00000000..9bcad253
--- /dev/null
+++ b/test/correctness/routines/xsymm.cc
@@ -0,0 +1,104 @@
+
+// =================================================================================================
+// 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 Xsymm routine. It is based on the TestABC class.
+//
+// =================================================================================================
+
+#include "wrapper_clblas.h"
+#include "correctness/testabc.h"
+
+namespace clblast {
+// =================================================================================================
+
+// The correctness tester, containing the function calls to CLBlast and to clBLAS for comparison.
+template <typename T>
+void XsymmTest(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 &b_mat, const Buffer &c_mat,
+ CommandQueue &queue) -> StatusCode {
+ auto queue_plain = queue();
+ auto event = cl_event{};
+ return Symm(args.layout, args.side, args.triangle,
+ args.m, args.n,
+ args.alpha,
+ a_mat(), args.a_offset, args.a_ld,
+ b_mat(), args.b_offset, args.b_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 &b_mat, const Buffer &c_mat,
+ CommandQueue &queue) -> StatusCode {
+ auto queue_plain = queue();
+ auto event = cl_event{};
+ auto status = clblasXsymm(static_cast<clblasOrder>(args.layout),
+ static_cast<clblasSide>(args.side),
+ static_cast<clblasUplo>(args.triangle),
+ args.m, args.n,
+ args.alpha,
+ a_mat(), args.a_offset, args.a_ld,
+ b_mat(), args.b_offset, args.b_ld,
+ args.beta,
+ c_mat(), args.c_offset, args.c_ld,
+ 1, &queue_plain, 0, nullptr, &event);
+ return static_cast<StatusCode>(status);
+ };
+
+ // Selects the platform and device on which to test (command-line options)
+ auto help = std::string{"Options given/available:\n"};
+ const auto platform_id = GetArgument(argc, argv, help, kArgPlatform, size_t{0});
+ const auto device_id = GetArgument(argc, argv, help, kArgDevice, size_t{0});
+ if (!silent) { fprintf(stdout, "\n* %s\n", help.c_str()); }
+
+ // Initializes the other arguments relevant for this routine
+ auto args = Arguments<T>{};
+ const auto options = std::vector<std::string>{kArgM, kArgN, kArgLayout,
+ kArgSide, kArgTriangle,
+ kArgALeadDim, kArgBLeadDim, kArgCLeadDim,
+ kArgAOffset, kArgBOffset, kArgCOffset};
+
+ // Creates a tester
+ TestABC<T> tester{platform_id, device_id, name, options, clblast_lambda, clblas_lambda};
+
+ // Loops over the test-cases from a data-layout point of view
+ for (auto &layout: {Layout::kRowMajor, Layout::kColMajor}) {
+ args.layout = layout;
+ for (auto &side: {Side::kLeft, Side::kRight}) {
+ args.side = side;
+ for (auto &triangle: {Triangle::kUpper, Triangle::kLower}) {
+ args.triangle = triangle;
+ const auto case_name = ToString(layout)+" "+ToString(side)+" "+ToString(triangle);
+
+ // 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::XsymmTest<float>(argc, argv, false, "SSYMM");
+ clblast::XsymmTest<double>(argc, argv, true, "DSYMM");
+ //clblast::XsymmTest<float2>(argc, argv, true, "CSYMM");
+ //clblast::XsymmTest<double2>(argc, argv, true, "ZSYMM");
+ return 0;
+}
+
+// =================================================================================================