diff options
author | Cedric Nugteren <web@cedricnugteren.nl> | 2017-03-04 15:21:33 +0100 |
---|---|---|
committer | Cedric Nugteren <web@cedricnugteren.nl> | 2017-03-04 15:21:33 +0100 |
commit | e993ee077b50d3a6134309d465a4174b5c749596 (patch) | |
tree | b967f2702b90d8080a3e3cb41b9cbc01ab9eddc3 /test/routines/level3/xtrsm.hpp | |
parent | 3fc73851f7ed885335940eb85e53069638567323 (diff) |
Added a proper data-preparation function for the TRSM tests
Diffstat (limited to 'test/routines/level3/xtrsm.hpp')
-rw-r--r-- | test/routines/level3/xtrsm.hpp | 52 |
1 files changed, 17 insertions, 35 deletions
diff --git a/test/routines/level3/xtrsm.hpp b/test/routines/level3/xtrsm.hpp index 1ffaef35..0da4189d 100644 --- a/test/routines/level3/xtrsm.hpp +++ b/test/routines/level3/xtrsm.hpp @@ -19,6 +19,8 @@ #include <vector> #include <string> +#include "test/routines/level3/xtrsm_data.hpp" + #ifdef CLBLAST_REF_CLBLAS #include "test/wrapper_clblas.hpp" #endif @@ -29,38 +31,6 @@ namespace clblast { // ================================================================================================= -// Prepares the data -template <typename T> -void PrepareData(const Arguments<T> &args, Buffers<T> &buffers, Queue &queue) { - const auto k = (args.side == Side::kLeft) ? args.m : args.n; - if (args.a_ld < k) { return; } - if (args.a_size <= 0 || args.b_size <= 0) { return; } - - // Copies input buffers to the host - std::vector<T> a_mat_cpu(args.a_size, static_cast<T>(0)); - std::vector<T> b_mat_cpu(args.b_size, static_cast<T>(0)); - buffers.a_mat.Read(queue, args.a_size, a_mat_cpu); - buffers.b_mat.Read(queue, args.b_size, b_mat_cpu); - - // Generates 'proper' input for the TRSM routine - // TODO: Improve this - for (auto i = size_t{0}; i < k; ++i) { - for (auto j = size_t{0}; j < k; ++j) { - auto value = a_mat_cpu[j*args.a_ld + i + args.a_offset]; - value *= ConstantTwo<T>(); - if (IsCloseToZero(value)) { value += ConstantOne<T>(); } - a_mat_cpu[j*args.a_ld + i + args.a_offset] = value; - } - } - - // Copies input buffers back to the OpenCL device - buffers.a_mat.Write(queue, args.a_size, a_mat_cpu); - buffers.b_mat.Write(queue, args.b_size, b_mat_cpu); - return; -} - -// ================================================================================================= - // See comment at top of file for a description of the class template <typename T> class TestXtrsm { @@ -105,9 +75,23 @@ class TestXtrsm { static Transposes GetATransposes(const Transposes &all) { return all; } static Transposes GetBTransposes(const Transposes &) { return {}; } // N/A for this routine + // Describes how to prepare the input data + static void PrepareData(const Arguments<T> &args, Queue &queue, const int seed, + std::vector<T>&, std::vector<T>&, + std::vector<T>& a_source_, std::vector<T>& b_source_, std::vector<T>&, + std::vector<T>&, std::vector<T>&) { + const auto k = (args.side == Side::kLeft) ? args.m : args.n; + const auto b_one = (args.layout == Layout::kRowMajor) ? args.n : args.m; + if (args.a_ld < k) { return; } + if (args.b_ld < b_one) { return; } + if (args.a_size <= 0 || args.b_size <= 0) { return; } + + // TODO: This is a copy of the clBLAS random matrix generation, make it work properly + GenerateProperTrsmMatrices(args, seed, &a_source_[args.a_offset], &b_source_[args.b_offset]); + } + // Describes how to run the CLBlast routine static StatusCode RunRoutine(const Arguments<T> &args, Buffers<T> &buffers, Queue &queue) { - PrepareData(args, buffers, queue); auto queue_plain = queue(); auto event = cl_event{}; auto status = Trsm(args.layout, args.side, args.triangle, args.a_transpose, args.diagonal, @@ -122,7 +106,6 @@ class TestXtrsm { // Describes how to run the clBLAS routine (for correctness/performance comparison) #ifdef CLBLAST_REF_CLBLAS static StatusCode RunReference1(const Arguments<T> &args, Buffers<T> &buffers, Queue &queue) { - PrepareData(args, buffers, queue); auto queue_plain = queue(); auto event = cl_event{}; auto status = clblasXtrsm(convertToCLBLAS(args.layout), @@ -142,7 +125,6 @@ class TestXtrsm { // Describes how to run the CPU BLAS routine (for correctness/performance comparison) #ifdef CLBLAST_REF_CBLAS static StatusCode RunReference2(const Arguments<T> &args, Buffers<T> &buffers, Queue &queue) { - PrepareData(args, buffers, queue); std::vector<T> a_mat_cpu(args.a_size, static_cast<T>(0)); std::vector<T> b_mat_cpu(args.b_size, static_cast<T>(0)); buffers.a_mat.Read(queue, args.a_size, a_mat_cpu); |