[Libclc-dev] [PATCH v2 1/1] math: Don't use llvm instrinsic for native_log

Aaron Watry via Libclc-dev libclc-dev at lists.llvm.org
Mon Oct 9 18:18:44 PDT 2017


On Sun, Oct 8, 2017 at 1:20 PM, Jan Vesely <jan.vesely at rutgers.edu> wrote:
> On Sun, 2017-10-08 at 12:48 +0000, Aaron Watry wrote:
>> On Fri, Oct 6, 2017, 10:37 AM Jan Vesely via Libclc-dev <
>> libclc-dev at lists.llvm.org> wrote:
>>
>> > On Wed, 2017-09-27 at 18:34 -0400, Jan Vesely wrote:
>> > > AMDGPU targets don't have insturction for it,
>> > > so it'll be expanded to C * log2 anyway.
>> > >
>> > > v2: use native_log2 instead of the more precise sw implementation
>> > >
>> > > Signed-off-by: Jan Vesely <jan.vesely at rutgers.edu>
>> >
>> > ping. this is currently crashing.
>> > even after https://reviews.llvm.org/D29942 lands, we'll need this for
>> > older llvm versions.
>> >
>>
>> Even with this, 'pow' crashes out llvm on me at the moment on my SI card.
>> I've got family in town today yet ,but tonight or tomorrow I should have
>> time to rebuild my stack and try again.
>
> hi, I'm not sure what 'this' refers to. I assume it's D29942 since
> native_log patch is not related to pow. Note that D29942 only addresses
> f32 and f16 types, f64 still crashes. You'll need my other ('math:
> Don't use llvm intrinsic for pow') patch to fix that.
>
> I assume Matt would prefer to keep the default to use intrinsic, and
> the expansion is not quite correct (it does not handle 0 or negative
> input, in fact it's better suited for powr).
> I'll be posting another version of that patch as well. I just have too
> many patches in flight atm.

Yeah, sorry.  This email was a massive brain-fart on my part. Too much
stuff going on at home this last week, and I haven't had time to keep
up on emails.

In the case of native_* functions, any result that doesn't crash is a
valid result, so in this case, I'm fine with your proposed function
expansion.

--Aaron

>
> Jan
>
>>
>> --Aaron
>>
>> >
>> > Jan
>> >
>> > > ---
>> > >  generic/lib/math/native_log.cl  | 5 -----
>> > >  generic/lib/math/native_log.inc | 2 +-
>> > >  2 files changed, 1 insertion(+), 6 deletions(-)
>> > >
>> > > diff --git a/generic/lib/math/native_log.cl b/generic/lib/math/
>> >
>> > native_log.cl
>> > > index f64f012..f8ba08f 100644
>> > > --- a/generic/lib/math/native_log.cl
>> > > +++ b/generic/lib/math/native_log.cl
>> > > @@ -22,11 +22,6 @@
>> > >
>> > >  #include <clc/clc.h>
>> > >
>> > > -#define __CLC_FUNCTION __clc_native_log
>> > > -#define __CLC_INTRINSIC "llvm.log"
>> > > -#undef cl_khr_fp64
>> > > -#include <clc/math/unary_intrin.inc>
>> > > -
>> > >  #define __CLC_BODY <native_log.inc>
>> > >  #define __FLOAT_ONLY
>> > >  #include <clc/math/gentype.inc>
>> > > diff --git a/generic/lib/math/native_log.inc
>> >
>> > b/generic/lib/math/native_log.inc
>> > > index cb4db3f..d4950c2 100644
>> > > --- a/generic/lib/math/native_log.inc
>> > > +++ b/generic/lib/math/native_log.inc
>> > > @@ -21,5 +21,5 @@
>> > >   */
>> > >
>> > >  _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE native_log(__CLC_GENTYPE val) {
>> > > -  return __clc_native_log(val);
>> > > +  return native_log2(val) * (1.0f / M_LOG2E_F);
>> > >  }
>> >
>> > _______________________________________________
>> > Libclc-dev mailing list
>> > Libclc-dev at lists.llvm.org
>> > http://lists.llvm.org/cgi-bin/mailman/listinfo/libclc-dev
>> >
>
> --
> Jan Vesely <jan.vesely at rutgers.edu>


More information about the Libclc-dev mailing list