From e993ee077b50d3a6134309d465a4174b5c749596 Mon Sep 17 00:00:00 2001 From: Cedric Nugteren Date: Sat, 4 Mar 2017 15:21:33 +0100 Subject: Added a proper data-preparation function for the TRSM tests --- test/routines/level2/xtrsv.hpp | 53 ++++++++++++++++-------------------------- 1 file changed, 20 insertions(+), 33 deletions(-) (limited to 'test/routines/level2/xtrsv.hpp') diff --git a/test/routines/level2/xtrsv.hpp b/test/routines/level2/xtrsv.hpp index fed4378a..78b9672f 100644 --- a/test/routines/level2/xtrsv.hpp +++ b/test/routines/level2/xtrsv.hpp @@ -29,36 +29,6 @@ namespace clblast { // ================================================================================================= -// Prepares the data -template -void PrepareData(const Arguments &args, Buffers &buffers, Queue &queue) { - if (args.a_ld < args.n) { return; } - if (args.a_size <= 0 || args.x_size <= 0) { return; } - - // Copies input buffers to the host - std::vector a_mat_cpu(args.a_size, static_cast(0)); - std::vector x_vec_cpu(args.x_size, static_cast(0)); - buffers.a_mat.Read(queue, args.a_size, a_mat_cpu); - buffers.x_vec.Read(queue, args.x_size, x_vec_cpu); - - // Generates 'proper' input for the TRSV routine - // TODO: Improve this, currently loosely based on clBLAS's implementation - for (auto i = size_t{0}; i < args.n; ++i) { - auto diagonal = a_mat_cpu[i*args.a_ld + i + args.a_offset]; - diagonal = AbsoluteValue(diagonal) + static_cast(args.n / size_t{4}); - for (auto j = size_t{0}; j < args.n; ++j) { - a_mat_cpu[j*args.a_ld + i + args.a_offset] /= ConstantTwo(); - } - a_mat_cpu[i*args.a_ld + i + args.a_offset] = diagonal; - x_vec_cpu[i * args.x_inc + args.x_offset] /= ConstantTwo(); - } - - // Copies input buffers back to the OpenCL device - buffers.a_mat.Write(queue, args.a_size, a_mat_cpu); - buffers.x_vec.Write(queue, args.x_size, x_vec_cpu); - return; -} - // See comment at top of file for a description of the class template class TestXtrsv { @@ -99,9 +69,28 @@ class TestXtrsv { 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 &args, Queue&, const int, std::vector &x_source, + std::vector&, std::vector &a_source, std::vector&, std::vector&, + std::vector&, std::vector&) { + if (args.a_ld < args.n) { return; } + if (args.a_size <= 0 || args.x_size <= 0) { return; } + + // Generates 'proper' input for the TRSV routine + // TODO: Improve this, currently loosely based on clBLAS's implementation + for (auto i = size_t{0}; i < args.n; ++i) { + auto diagonal = a_source[i*args.a_ld + i + args.a_offset]; + diagonal = static_cast(AbsoluteValue(diagonal)) + static_cast(args.n / size_t{4}); + for (auto j = size_t{0}; j < args.n; ++j) { + a_source[j*args.a_ld + i + args.a_offset] /= Constant(2.0); + } + a_source[i*args.a_ld + i + args.a_offset] = diagonal; + x_source[i * args.x_inc + args.x_offset] /= Constant(2.0); + } + } + // Describes how to run the CLBlast routine static StatusCode RunRoutine(const Arguments &args, Buffers &buffers, Queue &queue) { - PrepareData(args, buffers, queue); auto queue_plain = queue(); auto event = cl_event{}; auto status = Trsv(args.layout, args.triangle, args.a_transpose, args.diagonal, @@ -116,7 +105,6 @@ class TestXtrsv { // Describes how to run the clBLAS routine (for correctness/performance comparison) #ifdef CLBLAST_REF_CLBLAS static StatusCode RunReference1(const Arguments &args, Buffers &buffers, Queue &queue) { - PrepareData(args, buffers, queue); auto queue_plain = queue(); auto event = cl_event{}; auto status = clblasXtrsv(convertToCLBLAS(args.layout), @@ -135,7 +123,6 @@ class TestXtrsv { // Describes how to run the CPU BLAS routine (for correctness/performance comparison) #ifdef CLBLAST_REF_CBLAS static StatusCode RunReference2(const Arguments &args, Buffers &buffers, Queue &queue) { - PrepareData(args, buffers, queue); std::vector a_mat_cpu(args.a_size, static_cast(0)); std::vector x_vec_cpu(args.x_size, static_cast(0)); buffers.a_mat.Read(queue, args.a_size, a_mat_cpu); -- cgit v1.2.3