[Libclc-dev] [PATCH] Move definition of INFINITY
Aaron Watry
awatry at gmail.com
Wed Jun 11 16:18:27 PDT 2014
I'll change this to _builtin_inff() and also move the definition of
FLT_NAN/DBL_NAN from the nextafter implementation to definitions.h
(using _builtin_nan[f]), rename them to their proper names and then
send a v2.
--Aaron
On Wed, Jun 11, 2014 at 6:04 PM, Matt Arsenault
<Matthew.Arsenault at amd.com> wrote:
> On 06/11/2014 03:59 PM, Matt Arsenault wrote:
>>
>> On 06/11/2014 03:54 PM, Jeroen Ketema wrote:
>>>
>>> You probably want to put parentheses around that (just in case).
>>>
>>> #define INFINITY (1.0f / 0.0f)
>>>
>>> Otherwise, looks good to me. The same should probably be done for NAN,
>>> which I think also occurs somewhere already.
>>>
>>> Jeroen
>>
>> This should be ___builtin_inf/ __builtin_inff
>>
>> I believe these will have different warning behaviour
>
>
> Yes, this changes at least -Wfloat-equal
>
>
> kernel void foo(global int* out, float x)
> {
> *out = (1.0f / 0.0f) == x; // warning: comparing floating point with ==
> or != is unsafe [-Wfloat-equal]
> }
>
> kernel void bar(global int* out, float x)
> {
> *out = __builtin_inff() == x; // No warning
>
> }
>
>
>>> On 11 Jun 2014, at 20:29, Aaron Watry <awatry at gmail.com> wrote:
>>>
>>>> We were missing a declaration of INFINITY in the clc headers and already
>>>> had one in gen_convert.py
>>>>
>>>> NOTE: This may not necessarily be the correct value of INFINITY based on
>>>> the cl_platform.h headers
>>>>
>>>> Signed-off-by: Aaron Watry <awatry at gmail.com>
>>>> ---
>>>> generic/include/clc/float/definitions.h | 2 ++
>>>> generic/lib/gen_convert.py | 2 --
>>>> 2 files changed, 2 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/generic/include/clc/float/definitions.h
>>>> b/generic/include/clc/float/definitions.h
>>>> index af54fdf..1446ad9 100644
>>>> --- a/generic/include/clc/float/definitions.h
>>>> +++ b/generic/include/clc/float/definitions.h
>>>> @@ -1,3 +1,5 @@
>>>> +#define INFINITY 1.0f / 0.0f
>>>> +
>>>> #define FLT_DIG 6
>>>> #define FLT_MANT_DIG 24
>>>> #define FLT_MAX_10_EXP +38
>>>> 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
>>>
>>>
>>> _______________________________________________
>>> Libclc-dev mailing list
>>> Libclc-dev at pcc.me.uk
>>> http://www.pcc.me.uk/cgi-bin/mailman/listinfo/libclc-dev
>>
>>
>>
>> _______________________________________________
>> 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