[Libclc-dev] [PATCH 2/2] Implement isinf builtin

Jan Vesely jan.vesely at rutgers.edu
Wed Sep 3 08:09:40 PDT 2014


On Wed, 2014-09-03 at 05:17 -0700, Tom Stellard wrote:
> On Tue, Sep 02, 2014 at 04:36:48PM -0500, Aaron Watry wrote:
> > The good news:  It's almost identical to a WIP patch that I hadn't
> > sent into the list yet (besides the usage of
> > <clc/relational/floatn.inc> in my version).
> > 
> > The bad news:  It results in the following for both EG and SI for me:
> > 
> > LLVM triggered Diagnostic Handler: unsupported call to function fabsf
> > in test_1_isinf_float
> > Segmentation fault (core dumped)
> > 
> 
> This should be fixed with this clang patch:
> 
> http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20140901/114007.html

with that patch is passes the piglit on my TURKS

LGTM

do you plan to add the remaining ops that have buitin implementation
(isfinite, islessgreater, isnormal, unordered)?

jan

> 
> -Tom
> 
> > Curiously, the fabs() tests that I just wrote seem to be ok (which
> > uses the llvm.fabs intrinsic)
> > 
> > kernel and bitcode of builtin-float-isinf-1.0.generated.cl (just the
> > scalar float test) is attached just in case it helps.
> > 
> > --Aaron
> > 
> > 
> > On Tue, Sep 2, 2014 at 2:12 PM, Tom Stellard <thomas.stellard at amd.com> wrote:
> > > ---
> > >  generic/include/clc/clc.h              |  1 +
> > >  generic/include/clc/relational/isinf.h | 21 +++++++++++++++++++++
> > >  generic/lib/SOURCES                    |  1 +
> > >  generic/lib/relational/isinf.cl        | 18 ++++++++++++++++++
> > >  4 files changed, 41 insertions(+)
> > >  create mode 100644 generic/include/clc/relational/isinf.h
> > >  create mode 100644 generic/lib/relational/isinf.cl
> > >
> > > diff --git a/generic/include/clc/clc.h b/generic/include/clc/clc.h
> > > index 12114fe..490893b 100644
> > > --- a/generic/include/clc/clc.h
> > > +++ b/generic/include/clc/clc.h
> > > @@ -117,6 +117,7 @@
> > >  #include <clc/relational/isequal.h>
> > >  #include <clc/relational/isgreater.h>
> > >  #include <clc/relational/isgreaterequal.h>
> > > +#include <clc/relational/isinf.h>
> > >  #include <clc/relational/isless.h>
> > >  #include <clc/relational/islessequal.h>
> > >  #include <clc/relational/isnan.h>
> > > diff --git a/generic/include/clc/relational/isinf.h b/generic/include/clc/relational/isinf.h
> > > new file mode 100644
> > > index 0000000..869f0c8
> > > --- /dev/null
> > > +++ b/generic/include/clc/relational/isinf.h
> > > @@ -0,0 +1,21 @@
> > > +
> > > +#define _CLC_ISINF_DECL(RET_TYPE, ARG_TYPE) \
> > > +  _CLC_OVERLOAD _CLC_DECL RET_TYPE isinf(ARG_TYPE);
> > > +
> > > +#define _CLC_VECTOR_ISINF_DECL(RET_TYPE, ARG_TYPE) \
> > > +  _CLC_ISINF_DECL(RET_TYPE##2, ARG_TYPE##2) \
> > > +  _CLC_ISINF_DECL(RET_TYPE##3, ARG_TYPE##3) \
> > > +  _CLC_ISINF_DECL(RET_TYPE##4, ARG_TYPE##4) \
> > > +  _CLC_ISINF_DECL(RET_TYPE##8, ARG_TYPE##8) \
> > > +  _CLC_ISINF_DECL(RET_TYPE##16, ARG_TYPE##16)
> > > +
> > > +_CLC_ISINF_DECL(int, float)
> > > +_CLC_VECTOR_ISINF_DECL(int, float)
> > > +
> > > +#ifdef cl_khr_fp64
> > > +_CLC_ISINF_DECL(int, double)
> > > +_CLC_VECTOR_ISINF_DECL(long, double)
> > > +#endif
> > > +
> > > +#undef _CLC_ISINF_DECL
> > > +#undef _CLC_VECTOR_ISINF_DECL
> > > diff --git a/generic/lib/SOURCES b/generic/lib/SOURCES
> > > index ced53f3..8eaaa61 100644
> > > --- a/generic/lib/SOURCES
> > > +++ b/generic/lib/SOURCES
> > > @@ -52,6 +52,7 @@ relational/any.cl
> > >  relational/isequal.cl
> > >  relational/isgreater.cl
> > >  relational/isgreaterequal.cl
> > > +relational/isinf.cl
> > >  relational/isless.cl
> > >  relational/islessequal.cl
> > >  relational/isnan.cl
> > > diff --git a/generic/lib/relational/isinf.cl b/generic/lib/relational/isinf.cl
> > > new file mode 100644
> > > index 0000000..1452d91
> > > --- /dev/null
> > > +++ b/generic/lib/relational/isinf.cl
> > > @@ -0,0 +1,18 @@
> > > +#include <clc/clc.h>
> > > +#include "relational.h"
> > > +
> > > +_CLC_DEFINE_RELATIONAL_UNARY(int, isinf, __builtin_isinf, float)
> > > +
> > > +#ifdef cl_khr_fp64
> > > +
> > > +#pragma OPENCL EXTENSION cl_khr_fp64 : enable
> > > +
> > > +// The scalar version of isinf(double) returns an int, but the vector versions
> > > +// return long.
> > > +_CLC_DEF _CLC_OVERLOAD int isinf(double x) {
> > > +  return __builtin_isinf(x);
> > > +}
> > > +
> > > +_CLC_DEFINE_RELATIONAL_UNARY_VEC_ALL(long, isinf, double)
> > > +
> > > +#endif
> > > --
> > > 1.8.5.5
> > >
> > >
> > > _______________________________________________
> > > 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

-- 
Jan Vesely <jan.vesely at rutgers.edu>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://lists.llvm.org/pipermail/libclc-dev/attachments/20140903/2ae4da76/attachment.sig>


More information about the Libclc-dev mailing list