summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric Nugteren <web@cedricnugteren.nl>2017-10-09 18:30:19 +0200
committerCedric Nugteren <web@cedricnugteren.nl>2017-10-09 18:30:19 +0200
commite8f1de0265900db42b8dd097245a765ce7f699b5 (patch)
tree8ec37ba3555bab601995b509e256ac3cbfc2754f
parentdf3c9f4a8ab9e82ccc4add15b04da5c1b6172b72 (diff)
Made the half-precision header OpenCL-independent
-rw-r--r--include/clblast_half.h12
1 files changed, 3 insertions, 9 deletions
diff --git a/include/clblast_half.h b/include/clblast_half.h
index 3d77fdd9..b8de8537 100644
--- a/include/clblast_half.h
+++ b/include/clblast_half.h
@@ -18,13 +18,6 @@
#ifndef CLBLAST_HALF_H_
#define CLBLAST_HALF_H_
-// Includes the normal OpenCL C header
-#if defined(__APPLE__) || defined(__MACOSX)
- #include <OpenCL/opencl.h>
-#else
- #include <CL/opencl.h>
-#endif
-
// MSVC 2013 doesn't fully support C99
#ifdef _MSC_VER
#define inline __inline
@@ -34,6 +27,7 @@
// The host data-type for half-precision floating-point (16-bit) is based on the `cl_half` OpenCL
// type, which is a typedef for unsigned short.
+typedef unsigned short half;
// 32-bit union for conversions
typedef union ConversionBits_ {
@@ -46,7 +40,7 @@ typedef union ConversionBits_ {
// Converts a IEEE-compliant single-precision value to half-precision floating-point. This function
// applies simple truncation (round toward zero, but with overflows set to infinity) as rounding
// mode.
-inline cl_half FloatToHalf(const float value) {
+inline half FloatToHalf(const float value) {
static const unsigned short base_table[512] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
@@ -107,7 +101,7 @@ inline cl_half FloatToHalf(const float value) {
}
// Converts a half-precision value to IEEE-compliant single-precision floating-point
-inline float HalfToFloat(const cl_half value) {
+inline float HalfToFloat(const half value) {
static const unsigned int mantissa_table[2048] = {
0x00000000, 0x33800000, 0x34000000, 0x34400000, 0x34800000, 0x34A00000, 0x34C00000, 0x34E00000, 0x35000000, 0x35100000, 0x35200000, 0x35300000, 0x35400000, 0x35500000, 0x35600000, 0x35700000,
0x35800000, 0x35880000, 0x35900000, 0x35980000, 0x35A00000, 0x35A80000, 0x35B00000, 0x35B80000, 0x35C00000, 0x35C80000, 0x35D00000, 0x35D80000, 0x35E00000, 0x35E80000, 0x35F00000, 0x35F80000,