From 133ebfc83414c4aa0e8fce9f6f7b9d43e6774380 Mon Sep 17 00:00:00 2001 From: Cedric Nugteren Date: Sun, 19 Feb 2017 17:43:26 +0100 Subject: Added data-preparation function for the TRSV tests and special nan/inf checks in the error checking to make the tests pass --- src/utilities/utilities.cpp | 9 +++++++++ src/utilities/utilities.hpp | 4 ++++ 2 files changed, 13 insertions(+) (limited to 'src') diff --git a/src/utilities/utilities.cpp b/src/utilities/utilities.cpp index fd198c0d..b2ed2f0c 100644 --- a/src/utilities/utilities.cpp +++ b/src/utilities/utilities.cpp @@ -18,6 +18,7 @@ #include #include #include +#include namespace clblast { // ================================================================================================= @@ -118,6 +119,14 @@ double2 ConstantNegOne() { return {-1.0, 0.0}; } +// Returns the absolute value of a scalar +template T AbsoluteValue(const T value) { return std::fabs(value); } +template float AbsoluteValue(const float); +template double AbsoluteValue(const double); +template <> half AbsoluteValue(const half value) { return FloatToHalf(std::fabs(HalfToFloat(value))); } +template <> float2 AbsoluteValue(const float2 value) { return std::abs(value); } +template <> double2 AbsoluteValue(const double2 value) { return std::abs(value); } + // ================================================================================================= // Implements the string conversion using std::to_string if possible diff --git a/src/utilities/utilities.hpp b/src/utilities/utilities.hpp index 757f1b5e..2c13658b 100644 --- a/src/utilities/utilities.hpp +++ b/src/utilities/utilities.hpp @@ -114,6 +114,10 @@ T ConstantOne(); template T ConstantNegOne(); +// Returns the absolute value of a scalar +template +T AbsoluteValue(const T value); + // ================================================================================================= // Structure containing all possible arguments for test clients, including their default values -- cgit v1.2.3