diff options
author | Cedric Nugteren <web@cedricnugteren.nl> | 2016-05-15 20:13:57 +0200 |
---|---|---|
committer | Cedric Nugteren <web@cedricnugteren.nl> | 2016-05-15 20:13:57 +0200 |
commit | 4b6bdd83a224daca05256a49fdc03c4dd4af6fc9 (patch) | |
tree | 224178b4dcc34a5b0c2e4b9030e999cca7aebac9 /include/internal/utilities.h | |
parent | 5e1b2e021f4b746a77619e0ad5ab35d9a0d4df54 (diff) |
Added header with conversions from and to half-precision floating-point
Diffstat (limited to 'include/internal/utilities.h')
-rw-r--r-- | include/internal/utilities.h | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/include/internal/utilities.h b/include/internal/utilities.h index 854b3dfe..be7a77b4 100644 --- a/include/internal/utilities.h +++ b/include/internal/utilities.h @@ -22,14 +22,12 @@ #include <complex> #include "clblast.h" +#include "clblast_half.h" #include "internal/clpp11.h" namespace clblast { // ================================================================================================= -// Host data-type for half-precision floating-point (16-bit) -using half = cl_half; - // Shorthands for complex data-types using float2 = std::complex<float>; using double2 = std::complex<double>; @@ -97,6 +95,16 @@ constexpr auto kArgNoAbbreviations = "no_abbrv"; // ================================================================================================= +// Returns a scalar with a default value +template <typename T> +T GetScalar(); + +// Returns a scalar of value 1 +template <typename T> +T ConstantOne(); + +// ================================================================================================= + // Structure containing all possible arguments for test clients, including their default values template <typename T> struct Arguments { @@ -127,8 +135,8 @@ struct Arguments { size_t nrm2_offset = 0; size_t asum_offset = 0; size_t imax_offset = 0; - T alpha = T{1.0}; - T beta = T{1.0}; + T alpha = ConstantOne<T>(); + T beta = ConstantOne<T>(); size_t x_size = 1; size_t y_size = 1; size_t a_size = 1; @@ -205,12 +213,6 @@ void PopulateVector(std::vector<T> &vector); // ================================================================================================= -// Returns a scalar with a default value -template <typename T> -T GetScalar(); - -// ================================================================================================= - // Rounding functions size_t CeilDiv(const size_t x, const size_t y); size_t Ceil(const size_t x, const size_t y); @@ -229,10 +231,6 @@ size_t GetBytes(const Precision precision); template <typename T> bool PrecisionSupported(const Device &device); -// Converts a scalar to a scalar fit as a kernel argument (e.g. half is not supported) -template <typename T> struct RealArg { using Type = T; }; -template <> struct RealArg<half> { using Type = float; }; - // ================================================================================================= } // namespace clblast |