[Libclc-dev] [PATCH] Fix definition of INFINITY and add NAN/HUGE_VAL[F]

Aaron Watry awatry at gmail.com
Wed Jun 11 16:45:24 PDT 2014


I thought that originally, but the comment in clc_nextafter.cl gave me pause:

// This file provides OpenCL C implementations of nextafter for targets that
// don't support the clang builtin.

I wasn't sure if that was just implying a lack of support for the
nextafter built-in, or which were also missing additional built-in
functions. Tom wrote this code, so if he's ok with using the nanf/nan
built-in functions, then I'm fine with that.  I believe that the
commit message implies that this is related to whether libm is present
for the target, so that would seem to imply that we can fix this file
while we're here.

--Aaron

On Wed, Jun 11, 2014 at 6:37 PM, Jeroen Ketema <j.ketema at imperial.ac.uk> wrote:
>
> Shouldn’t FLT_NAN/DBL_NAN be removed?
>
> Jeroen
>
> On 12 Jun 2014, at 00:34, Aaron Watry <awatry at gmail.com> wrote:
>
>> v2: use __builtin_inff() and also add nan/huge_val definitions
>>
>> Signed-off-by: Aaron Watry <awatry at gmail.com>
>> ---
>> generic/include/clc/float/definitions.h | 6 ++++++
>> generic/lib/gen_convert.py              | 2 --
>> 2 files changed, 6 insertions(+), 2 deletions(-)
>>
>> diff --git a/generic/include/clc/float/definitions.h b/generic/include/clc/float/definitions.h
>> index af54fdf..c286bb9 100644
>> --- a/generic/include/clc/float/definitions.h
>> +++ b/generic/include/clc/float/definitions.h
>> @@ -1,3 +1,7 @@
>> +#define INFINITY __builtin_inff()
>> +#define NAN __builtin_nanf()
>> +#define HUGE_VALF __builtin_huge_valf()
>> +
>> #define FLT_DIG         6
>> #define FLT_MANT_DIG    24
>> #define FLT_MAX_10_EXP  +38
>> @@ -17,6 +21,8 @@
>>
>> #ifdef cl_khr_fp64
>>
>> +#define HUGE_VAL __builtin_huge_val()
>> +
>> #define DBL_DIG         15
>> #define DBL_MANT_DIG    53
>> #define DBL_MAX_10_EXP  +308
>> diff --git a/generic/lib/gen_convert.py b/generic/lib/gen_convert.py
>> index 8e54f0c..f91a89a 100644
>> --- a/generic/lib/gen_convert.py
>> +++ b/generic/lib/gen_convert.py
>> @@ -144,8 +144,6 @@ print("""/* !!!! AUTOGENERATED FILE generated by convert_type.py !!!!!
>> #pragma OPENCL EXTENSION cl_khr_fp64 : enable
>> #endif
>>
>> -#define INFINITY 1.0f / 0.0f
>> -
>> """)
>>
>> #
>> --
>> 1.9.1
>>
>>
>> _______________________________________________
>> Libclc-dev mailing list
>> Libclc-dev at pcc.me.uk
>> http://www.pcc.me.uk/cgi-bin/mailman/listinfo/libclc-dev
>




More information about the Libclc-dev mailing list