diff options
-rw-r--r-- | CMakeLists.txt | 3 | ||||
-rw-r--r-- | README.md | 8 | ||||
-rw-r--r-- | include/internal/routines/level2/xgerc.h | 46 | ||||
-rw-r--r-- | include/internal/routines/level2/xgeru.h | 46 | ||||
-rw-r--r-- | scripts/generator/generator.py | 4 | ||||
-rw-r--r-- | src/clblast.cc | 54 | ||||
-rw-r--r-- | src/kernels/level2/xger.opencl | 6 | ||||
-rw-r--r-- | src/routines/level1/xdotu.cc | 1 | ||||
-rw-r--r-- | src/routines/level2/xger.cc | 4 | ||||
-rw-r--r-- | src/routines/level2/xgerc.cc | 53 | ||||
-rw-r--r-- | src/routines/level2/xgeru.cc | 52 | ||||
-rw-r--r-- | test/routines/level2/xgerc.h | 131 | ||||
-rw-r--r-- | test/routines/level2/xgeru.h | 131 |
13 files changed, 515 insertions, 24 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 8e3313d9..342b72e5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -111,7 +111,8 @@ set(KERNELS copy pad transpose padtranspose xaxpy xdot xger xgemm xgemv) set(SAMPLE_PROGRAMS_CPP sgemm) set(SAMPLE_PROGRAMS_C sgemm) set(LEVEL1_ROUTINES xswap xscal xcopy xaxpy xdot xdotu xdotc) -set(LEVEL2_ROUTINES xgemv xgbmv xhemv xhbmv xhpmv xsymv xsbmv xspmv xtrmv xtbmv xtpmv xger) +set(LEVEL2_ROUTINES xgemv xgbmv xhemv xhbmv xhpmv xsymv xsbmv xspmv xtrmv xtbmv xtpmv + xger xgeru xgerc) set(LEVEL3_ROUTINES xgemm xsymm xhemm xsyrk xherk xsyr2k xher2k xtrmm) set(ROUTINES ${LEVEL1_ROUTINES} ${LEVEL2_ROUTINES} ${LEVEL3_ROUTINES}) set(PRECISIONS 32 64 3232 6464) @@ -155,7 +155,7 @@ These graphs can be generated automatically on your own device. First, compile C Supported routines ------------- -CLBlast is in active development but already supports the majority of BLAS routines. The currently supported routines are marked with '✔' in the following tables: +CLBlast is in active development but already supports almost all the BLAS routines. The currently supported routines are marked with '✔' in the following tables: | Level-1 | S | D | C | Z | Notes | | ---------|---|---|---|---|---------| @@ -191,9 +191,9 @@ CLBlast is in active development but already supports the majority of BLAS routi | xTRSV | | | | | | | xTBSV | | | | | | | xTPSV | | | | | | -| xGER | | | - | - | | -| xGERU | - | - | | | | -| xGERC | - | - | | | | +| xGER | ✔ | ✔ | - | - | | +| xGERU | - | - | ✔ | ✔ | | +| xGERC | - | - | ✔ | ✔ | | | xHER | - | - | | | | | xHPR | - | - | | | | | xHER2 | - | - | | | | diff --git a/include/internal/routines/level2/xgerc.h b/include/internal/routines/level2/xgerc.h new file mode 100644 index 00000000..8e515a14 --- /dev/null +++ b/include/internal/routines/level2/xgerc.h @@ -0,0 +1,46 @@ + +// ================================================================================================= +// 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 Xgerc routine. The precision is implemented using a template argument. +// +// ================================================================================================= + +#ifndef CLBLAST_ROUTINES_XGERC_H_ +#define CLBLAST_ROUTINES_XGERC_H_ + +#include "internal/routines/level2/xger.h" + +namespace clblast { +// ================================================================================================= + +// See comment at top of file for a description of the class +template <typename T> +class Xgerc: public Xger<T> { + public: + + // Uses the regular Xger routine + using Xger<T>::DoGer; + + // Constructor + Xgerc(Queue &queue, Event &event, const std::string &name = "GERC"); + + // Templated-precision implementation of the routine + StatusCode DoGerc(const Layout layout, + const size_t m, const size_t n, + const T alpha, + const Buffer<T> &x_buffer, const size_t x_offset, const size_t x_inc, + const Buffer<T> &y_buffer, const size_t y_offset, const size_t y_inc, + const Buffer<T> &a_buffer, const size_t a_offset, const size_t a_ld); +}; + +// ================================================================================================= +} // namespace clblast + +// CLBLAST_ROUTINES_XGERC_H_ +#endif diff --git a/include/internal/routines/level2/xgeru.h b/include/internal/routines/level2/xgeru.h new file mode 100644 index 00000000..ec485c37 --- /dev/null +++ b/include/internal/routines/level2/xgeru.h @@ -0,0 +1,46 @@ + +// ================================================================================================= +// 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 Xgeru routine. The precision is implemented using a template argument. +// +// ================================================================================================= + +#ifndef CLBLAST_ROUTINES_XGERU_H_ +#define CLBLAST_ROUTINES_XGERU_H_ + +#include "internal/routines/level2/xger.h" + +namespace clblast { +// ================================================================================================= + +// See comment at top of file for a description of the class +template <typename T> +class Xgeru: public Xger<T> { + public: + + // Uses the regular Xger routine + using Xger<T>::DoGer; + + // Constructor + Xgeru(Queue &queue, Event &event, const std::string &name = "GERU"); + + // Templated-precision implementation of the routine + StatusCode DoGeru(const Layout layout, + const size_t m, const size_t n, + const T alpha, + const Buffer<T> &x_buffer, const size_t x_offset, const size_t x_inc, + const Buffer<T> &y_buffer, const size_t y_offset, const size_t y_inc, + const Buffer<T> &a_buffer, const size_t a_offset, const size_t a_ld); +}; + +// ================================================================================================= +} // namespace clblast + +// CLBLAST_ROUTINES_XGERU_H_ +#endif diff --git a/scripts/generator/generator.py b/scripts/generator/generator.py index 6304f112..93ff8680 100644 --- a/scripts/generator/generator.py +++ b/scripts/generator/generator.py @@ -79,8 +79,8 @@ routines = [ Routine(False, "2a", "tpsv", T, [S,D,C,Z], ["n"], ["layout","triangle","a_transpose","diagonal"], ["ap"], ["x"], [], False, "Solves a packed triangular system of equations"), # Level 2: matrix update Routine(True, "2b", "ger", T, [S,D], ["m","n"], ["layout"], ["x","y"], ["a"], ["alpha"], False, "General rank-1 matrix update"), - Routine(False, "2b", "geru", T, [C,Z], ["m","n"], ["layout"], ["x","y"], ["a"], ["alpha"], False, "General rank-1 complex matrix update"), - Routine(False, "2b", "gerc", T, [C,Z], ["m","n"], ["layout"], ["x","y"], ["a"], ["alpha"], False, "General rank-1 complex conjugated matrix update"), + Routine(True, "2b", "geru", T, [C,Z], ["m","n"], ["layout"], ["x","y"], ["a"], ["alpha"], False, "General rank-1 complex matrix update"), + Routine(True, "2b", "gerc", T, [C,Z], ["m","n"], ["layout"], ["x","y"], ["a"], ["alpha"], False, "General rank-1 complex conjugated matrix update"), Routine(False, "2b", "her", Tc, [Css,Zdd], ["n"], ["layout","triangle"], ["x"], ["a"], ["alpha"], False, "Hermitian rank-1 matrix update"), Routine(False, "2b", "hpr", Tc, [Css,Zdd], ["n"], ["layout","triangle"], ["x"], ["ap"], ["alpha"], False, "Hermitian packed rank-1 matrix update"), Routine(False, "2b", "her2", T, [C,Z], ["n"], ["layout","triangle"], ["x","y"], ["a"], ["alpha"], False, "Hermitian rank-2 matrix update"), diff --git a/src/clblast.cc b/src/clblast.cc index aed3f141..47f2c59d 100644 --- a/src/clblast.cc +++ b/src/clblast.cc @@ -39,6 +39,8 @@ #include "internal/routines/level2/xtbmv.h" #include "internal/routines/level2/xtpmv.h" #include "internal/routines/level2/xger.h" +#include "internal/routines/level2/xgeru.h" +#include "internal/routines/level2/xgerc.h" // BLAS level-3 includes #include "internal/routines/level3/xgemm.h" @@ -872,14 +874,24 @@ template StatusCode Ger<double>(const Layout, // General rank-1 complex matrix update: CGERU/ZGERU template <typename T> -StatusCode Geru(const Layout, - const size_t, const size_t, - const T, - const cl_mem, const size_t, const size_t, - const cl_mem, const size_t, const size_t, - cl_mem, const size_t, const size_t, - cl_command_queue*, cl_event*) { - return StatusCode::kNotImplemented; +StatusCode Geru(const Layout layout, + const size_t m, const size_t n, + const T alpha, + const cl_mem x_buffer, const size_t x_offset, const size_t x_inc, + const cl_mem y_buffer, const size_t y_offset, const size_t y_inc, + cl_mem a_buffer, const size_t a_offset, const size_t a_ld, + cl_command_queue* queue, cl_event* event) { + auto queue_cpp = Queue(*queue); + auto event_cpp = Event(*event); + auto routine = Xgeru<T>(queue_cpp, event_cpp); + auto status = routine.SetUp(); + if (status != StatusCode::kSuccess) { return status; } + return routine.DoGeru(layout, + m, n, + alpha, + Buffer<T>(x_buffer), x_offset, x_inc, + Buffer<T>(y_buffer), y_offset, y_inc, + Buffer<T>(a_buffer), a_offset, a_ld); } template StatusCode Geru<float2>(const Layout, const size_t, const size_t, @@ -898,14 +910,24 @@ template StatusCode Geru<double2>(const Layout, // General rank-1 complex conjugated matrix update: CGERC/ZGERC template <typename T> -StatusCode Gerc(const Layout, - const size_t, const size_t, - const T, - const cl_mem, const size_t, const size_t, - const cl_mem, const size_t, const size_t, - cl_mem, const size_t, const size_t, - cl_command_queue*, cl_event*) { - return StatusCode::kNotImplemented; +StatusCode Gerc(const Layout layout, + const size_t m, const size_t n, + const T alpha, + const cl_mem x_buffer, const size_t x_offset, const size_t x_inc, + const cl_mem y_buffer, const size_t y_offset, const size_t y_inc, + cl_mem a_buffer, const size_t a_offset, const size_t a_ld, + cl_command_queue* queue, cl_event* event) { + auto queue_cpp = Queue(*queue); + auto event_cpp = Event(*event); + auto routine = Xgerc<T>(queue_cpp, event_cpp); + auto status = routine.SetUp(); + if (status != StatusCode::kSuccess) { return status; } + return routine.DoGerc(layout, + m, n, + alpha, + Buffer<T>(x_buffer), x_offset, x_inc, + Buffer<T>(y_buffer), y_offset, y_inc, + Buffer<T>(a_buffer), a_offset, a_ld); } template StatusCode Gerc<float2>(const Layout, const size_t, const size_t, diff --git a/src/kernels/level2/xger.opencl b/src/kernels/level2/xger.opencl index aa765b6c..c1cddea1 100644 --- a/src/kernels/level2/xger.opencl +++ b/src/kernels/level2/xger.opencl @@ -62,6 +62,9 @@ __kernel void Xger(const int max_one, const int max_two, const real alpha, const int id1 = w*get_global_size(0) + get_global_id(0); if (id1 < max_one) { yvalues[w] = ygm[id1*y_inc + y_offset]; + #if defined(ROUTINE_GERC) + COMPLEX_CONJUGATE(yvalues[w]); + #endif } } @@ -110,6 +113,9 @@ __kernel void Xger(const int max_one, const int max_two, const real alpha, const int id2 = w*get_global_size(1) + get_global_id(1); if (id2 < max_two) { yvalues[w] = ygm[id2*y_inc + y_offset]; + #if defined(ROUTINE_GERC) + COMPLEX_CONJUGATE(yvalues[w]); + #endif } } diff --git a/src/routines/level1/xdotu.cc b/src/routines/level1/xdotu.cc index 0b1bd2a8..28d9b730 100644 --- a/src/routines/level1/xdotu.cc +++ b/src/routines/level1/xdotu.cc @@ -14,7 +14,6 @@ #include "internal/routines/level1/xdotu.h" #include <string> -#include <vector> namespace clblast { // ================================================================================================= diff --git a/src/routines/level2/xger.cc b/src/routines/level2/xger.cc index c3a24264..55fa26d4 100644 --- a/src/routines/level2/xger.cc +++ b/src/routines/level2/xger.cc @@ -22,6 +22,8 @@ namespace clblast { // Specific implementations to get the memory-type based on a template argument template <> const Precision Xger<float>::precision_ = Precision::kSingle; template <> const Precision Xger<double>::precision_ = Precision::kDouble; +template <> const Precision Xger<float2>::precision_ = Precision::kComplexSingle; +template <> const Precision Xger<double2>::precision_ = Precision::kComplexDouble; // ================================================================================================= @@ -102,6 +104,8 @@ StatusCode Xger<T>::DoGer(const Layout layout, // Compiles the templated class template class Xger<float>; template class Xger<double>; +template class Xger<float2>; +template class Xger<double2>; // ================================================================================================= } // namespace clblast diff --git a/src/routines/level2/xgerc.cc b/src/routines/level2/xgerc.cc new file mode 100644 index 00000000..09408898 --- /dev/null +++ b/src/routines/level2/xgerc.cc @@ -0,0 +1,53 @@ + +// ================================================================================================= +// 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 Xgerc class (see the header for information about the class). +// +// ================================================================================================= + +#include "internal/routines/level2/xgerc.h" + +#include <string> + +namespace clblast { +// ================================================================================================= + +// Constructor: forwards to base class constructor +template <typename T> +Xgerc<T>::Xgerc(Queue &queue, Event &event, const std::string &name): + Xger<T>(queue, event, name) { +} + +// ================================================================================================= + +// The main routine +template <typename T> +StatusCode Xgerc<T>::DoGerc(const Layout layout, + const size_t m, const size_t n, + const T alpha, + const Buffer<T> &x_buffer, const size_t x_offset, const size_t x_inc, + const Buffer<T> &y_buffer, const size_t y_offset, const size_t y_inc, + const Buffer<T> &a_buffer, const size_t a_offset, const size_t a_ld) { + + // Regular Ger operation on complex data, plus conjugation in the kernel guarded by the + // ROUTINE_GERC guard. + return DoGer(layout, m, n, alpha, + x_buffer, x_offset, x_inc, + y_buffer, y_offset, y_inc, + a_buffer, a_offset, a_ld); +} + +// ================================================================================================= + +// Compiles the templated class +template class Xgerc<float2>; +template class Xgerc<double2>; + +// ================================================================================================= +} // namespace clblast diff --git a/src/routines/level2/xgeru.cc b/src/routines/level2/xgeru.cc new file mode 100644 index 00000000..36fd9d0a --- /dev/null +++ b/src/routines/level2/xgeru.cc @@ -0,0 +1,52 @@ + +// ================================================================================================= +// 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 Xgeru class (see the header for information about the class). +// +// ================================================================================================= + +#include "internal/routines/level2/xgeru.h" + +#include <string> + +namespace clblast { +// ================================================================================================= + +// Constructor: forwards to base class constructor +template <typename T> +Xgeru<T>::Xgeru(Queue &queue, Event &event, const std::string &name): + Xger<T>(queue, event, name) { +} + +// ================================================================================================= + +// The main routine +template <typename T> +StatusCode Xgeru<T>::DoGeru(const Layout layout, + const size_t m, const size_t n, + const T alpha, + const Buffer<T> &x_buffer, const size_t x_offset, const size_t x_inc, + const Buffer<T> &y_buffer, const size_t y_offset, const size_t y_inc, + const Buffer<T> &a_buffer, const size_t a_offset, const size_t a_ld) { + + // Regular Ger operation on complex data + return DoGer(layout, m, n, alpha, + x_buffer, x_offset, x_inc, + y_buffer, y_offset, y_inc, + a_buffer, a_offset, a_ld); +} + +// ================================================================================================= + +// Compiles the templated class +template class Xgeru<float2>; +template class Xgeru<double2>; + +// ================================================================================================= +} // namespace clblast diff --git a/test/routines/level2/xgerc.h b/test/routines/level2/xgerc.h new file mode 100644 index 00000000..77258d92 --- /dev/null +++ b/test/routines/level2/xgerc.h @@ -0,0 +1,131 @@ + +// ================================================================================================= +// 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 a class with static methods to describe the Xgerc routine. Examples of +// such 'descriptions' are how to calculate the size a of buffer or how to run the routine. These +// static methods are used by the correctness tester and the performance tester. +// +// ================================================================================================= + +#ifndef CLBLAST_TEST_ROUTINES_XGERC_H_ +#define CLBLAST_TEST_ROUTINES_XGERC_H_ + +#include <vector> +#include <string> + +#include "wrapper_clblas.h" + +namespace clblast { +// ================================================================================================= + +// See comment at top of file for a description of the class +template <typename T> +class TestXgerc { + public: + + // The BLAS level: 1, 2, or 3 + static size_t BLASLevel() { return 2; } + + // The list of arguments relevant for this routine + static std::vector<std::string> GetOptions() { + return {kArgM, kArgN, + kArgLayout, + kArgALeadDim, kArgXInc, kArgYInc, + kArgAOffset, kArgXOffset, kArgYOffset, + kArgAlpha}; + } + + // Describes how to obtain the sizes of the buffers + static size_t GetSizeX(const Arguments<T> &args) { + return args.m * args.x_inc + args.x_offset; + } + static size_t GetSizeY(const Arguments<T> &args) { + return args.n * args.y_inc + args.y_offset; + } + static size_t GetSizeA(const Arguments<T> &args) { + auto a_rotated = (args.layout == Layout::kRowMajor); + auto a_two = (a_rotated) ? args.m : args.n; + return a_two * args.a_ld + args.a_offset; + } + + // Describes how to set the sizes of all the buffers + static void SetSizes(Arguments<T> &args) { + args.a_size = GetSizeA(args); + args.x_size = GetSizeX(args); + args.y_size = GetSizeY(args); + } + + // Describes what the default values of the leading dimensions of the matrices are + static size_t DefaultLDA(const Arguments<T> &args) { return args.n; } + static size_t DefaultLDB(const Arguments<T> &) { return 1; } // N/A for this routine + static size_t DefaultLDC(const Arguments<T> &) { return 1; } // N/A for this routine + + // Describes which transpose options are relevant for this routine + using Transposes = std::vector<Transpose>; + static Transposes GetATransposes(const Transposes &) { return {}; } // N/A for this routine + static Transposes GetBTransposes(const Transposes &) { return {}; } // N/A for this routine + + // Describes how to run the CLBlast routine + static StatusCode RunRoutine(const Arguments<T> &args, const Buffers<T> &buffers, Queue &queue) { + auto queue_plain = queue(); + auto event = cl_event{}; + auto status = Gerc(args.layout, + args.m, args.n, args.alpha, + buffers.x_vec(), args.x_offset, args.x_inc, + buffers.y_vec(), args.y_offset, args.y_inc, + buffers.a_mat(), args.a_offset, args.a_ld, + &queue_plain, &event); + clWaitForEvents(1, &event); + return status; + } + + // Describes how to run the clBLAS routine (for correctness/performance comparison) + static StatusCode RunReference(const Arguments<T> &args, const Buffers<T> &buffers, Queue &queue) { + auto queue_plain = queue(); + auto event = cl_event{}; + auto status = clblasXgerc(static_cast<clblasOrder>(args.layout), + args.m, args.n, args.alpha, + buffers.x_vec(), args.x_offset, args.x_inc, + buffers.y_vec(), args.y_offset, args.y_inc, + buffers.a_mat(), args.a_offset, args.a_ld, + 1, &queue_plain, 0, nullptr, &event); + clWaitForEvents(1, &event); + return static_cast<StatusCode>(status); + } + + // Describes how to download the results of the computation (more importantly: which buffer) + static std::vector<T> DownloadResult(const Arguments<T> &args, Buffers<T> &buffers, Queue &queue) { + std::vector<T> result(args.a_size, static_cast<T>(0)); + buffers.a_mat.Read(queue, args.a_size, result); + return result; + } + + // Describes how to compute the indices of the result buffer + static size_t ResultID1(const Arguments<T> &args) { return args.m; } + static size_t ResultID2(const Arguments<T> &args) { return args.n; } + static size_t GetResultIndex(const Arguments<T> &args, const size_t id1, const size_t id2) { + return (args.layout == Layout::kRowMajor) ? + id1*args.a_ld + id2 + args.a_offset: + id2*args.a_ld + id1 + args.a_offset; + } + + // Describes how to compute performance metrics + static size_t GetFlops(const Arguments<T> &args) { + return 2 * args.m * args.n; + } + static size_t GetBytes(const Arguments<T> &args) { + return (2*args.m*args.n + args.m + args.n) * sizeof(T); + } +}; + +// ================================================================================================= +} // namespace clblast + +// CLBLAST_TEST_ROUTINES_XGERC_H_ +#endif diff --git a/test/routines/level2/xgeru.h b/test/routines/level2/xgeru.h new file mode 100644 index 00000000..e5f5f235 --- /dev/null +++ b/test/routines/level2/xgeru.h @@ -0,0 +1,131 @@ + +// ================================================================================================= +// 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 a class with static methods to describe the Xgeru routine. Examples of +// such 'descriptions' are how to calculate the size a of buffer or how to run the routine. These +// static methods are used by the correctness tester and the performance tester. +// +// ================================================================================================= + +#ifndef CLBLAST_TEST_ROUTINES_XGERU_H_ +#define CLBLAST_TEST_ROUTINES_XGERU_H_ + +#include <vector> +#include <string> + +#include "wrapper_clblas.h" + +namespace clblast { +// ================================================================================================= + +// See comment at top of file for a description of the class +template <typename T> +class TestXgeru { + public: + + // The BLAS level: 1, 2, or 3 + static size_t BLASLevel() { return 2; } + + // The list of arguments relevant for this routine + static std::vector<std::string> GetOptions() { + return {kArgM, kArgN, + kArgLayout, + kArgALeadDim, kArgXInc, kArgYInc, + kArgAOffset, kArgXOffset, kArgYOffset, + kArgAlpha}; + } + + // Describes how to obtain the sizes of the buffers + static size_t GetSizeX(const Arguments<T> &args) { + return args.m * args.x_inc + args.x_offset; + } + static size_t GetSizeY(const Arguments<T> &args) { + return args.n * args.y_inc + args.y_offset; + } + static size_t GetSizeA(const Arguments<T> &args) { + auto a_rotated = (args.layout == Layout::kRowMajor); + auto a_two = (a_rotated) ? args.m : args.n; + return a_two * args.a_ld + args.a_offset; + } + + // Describes how to set the sizes of all the buffers + static void SetSizes(Arguments<T> &args) { + args.a_size = GetSizeA(args); + args.x_size = GetSizeX(args); + args.y_size = GetSizeY(args); + } + + // Describes what the default values of the leading dimensions of the matrices are + static size_t DefaultLDA(const Arguments<T> &args) { return args.n; } + static size_t DefaultLDB(const Arguments<T> &) { return 1; } // N/A for this routine + static size_t DefaultLDC(const Arguments<T> &) { return 1; } // N/A for this routine + + // Describes which transpose options are relevant for this routine + using Transposes = std::vector<Transpose>; + static Transposes GetATransposes(const Transposes &) { return {}; } // N/A for this routine + static Transposes GetBTransposes(const Transposes &) { return {}; } // N/A for this routine + + // Describes how to run the CLBlast routine + static StatusCode RunRoutine(const Arguments<T> &args, const Buffers<T> &buffers, Queue &queue) { + auto queue_plain = queue(); + auto event = cl_event{}; + auto status = Geru(args.layout, + args.m, args.n, args.alpha, + buffers.x_vec(), args.x_offset, args.x_inc, + buffers.y_vec(), args.y_offset, args.y_inc, + buffers.a_mat(), args.a_offset, args.a_ld, + &queue_plain, &event); + clWaitForEvents(1, &event); + return status; + } + + // Describes how to run the clBLAS routine (for correctness/performance comparison) + static StatusCode RunReference(const Arguments<T> &args, const Buffers<T> &buffers, Queue &queue) { + auto queue_plain = queue(); + auto event = cl_event{}; + auto status = clblasXgeru(static_cast<clblasOrder>(args.layout), + args.m, args.n, args.alpha, + buffers.x_vec(), args.x_offset, args.x_inc, + buffers.y_vec(), args.y_offset, args.y_inc, + buffers.a_mat(), args.a_offset, args.a_ld, + 1, &queue_plain, 0, nullptr, &event); + clWaitForEvents(1, &event); + return static_cast<StatusCode>(status); + } + + // Describes how to download the results of the computation (more importantly: which buffer) + static std::vector<T> DownloadResult(const Arguments<T> &args, Buffers<T> &buffers, Queue &queue) { + std::vector<T> result(args.a_size, static_cast<T>(0)); + buffers.a_mat.Read(queue, args.a_size, result); + return result; + } + + // Describes how to compute the indices of the result buffer + static size_t ResultID1(const Arguments<T> &args) { return args.m; } + static size_t ResultID2(const Arguments<T> &args) { return args.n; } + static size_t GetResultIndex(const Arguments<T> &args, const size_t id1, const size_t id2) { + return (args.layout == Layout::kRowMajor) ? + id1*args.a_ld + id2 + args.a_offset: + id2*args.a_ld + id1 + args.a_offset; + } + + // Describes how to compute performance metrics + static size_t GetFlops(const Arguments<T> &args) { + return 2 * args.m * args.n; + } + static size_t GetBytes(const Arguments<T> &args) { + return (2*args.m*args.n + args.m + args.n) * sizeof(T); + } +}; + +// ================================================================================================= +} // namespace clblast + +// CLBLAST_TEST_ROUTINES_XGERU_H_ +#endif |