[Libclc-dev] [PATCH 05/15] Implement ldexp for R600/SI
Jan Vesely
jan.vesely at rutgers.edu
Wed May 6 06:34:49 PDT 2015
On Wed, 2015-04-08 at 14:49 -0400, Jan Vesely wrote:
> This patch breaks ldexp on r600 (it works OK with only 11/15).
> Manual mentions only LDEXP_64 (for r600,EG, and NI).
I have fixed this locally, no reason to delay this series.
LGTM
>
> On Tue, 2015-04-07 at 18:05 +0000, Tom Stellard wrote:
> > ---
> > generic/include/clc/clc.h | 1 +
> > generic/include/clc/math/gentype.inc | 20 +++++++++++++++++++
> > generic/include/clc/math/ldexp.h | 24 +++++++++++++++++++++++
> > generic/include/clc/math/ldexp.inc | 29 +++++++++++++++++++++++++++
> > r600/lib/SOURCES | 1 +
> > r600/lib/math/ldexp.cl | 38 ++++++++++++++++++++++++++++++++++++
> > r600/lib/math/ldexp.inc | 29 +++++++++++++++++++++++++++
> > 7 files changed, 142 insertions(+)
> > create mode 100644 generic/include/clc/math/ldexp.h
> > create mode 100644 generic/include/clc/math/ldexp.inc
> > create mode 100644 r600/lib/math/ldexp.cl
> > create mode 100644 r600/lib/math/ldexp.inc
> >
> > diff --git a/generic/include/clc/clc.h b/generic/include/clc/clc.h
> > index f3eaea2..18f7c07 100644
> > --- a/generic/include/clc/clc.h
> > +++ b/generic/include/clc/clc.h
> > @@ -59,6 +59,7 @@
> > #include <clc/math/half_rsqrt.h>
> > #include <clc/math/half_sqrt.h>
> > #include <clc/math/hypot.h>
> > +#include <clc/math/ldexp.h>
> > #include <clc/math/log.h>
> > #include <clc/math/log10.h>
> > #include <clc/math/log1p.h>
> > diff --git a/generic/include/clc/math/gentype.inc b/generic/include/clc/math/gentype.inc
> > index 9f79f6e..c82e808 100644
> > --- a/generic/include/clc/math/gentype.inc
> > +++ b/generic/include/clc/math/gentype.inc
> > @@ -8,24 +8,34 @@
> > #undef __CLC_SCALAR
> >
> > #define __CLC_GENTYPE float2
> > +#define __CLC_INTN int2
> > #include __CLC_BODY
> > #undef __CLC_GENTYPE
> > +#undef __CLC_INTN
> >
> > #define __CLC_GENTYPE float3
> > +#define __CLC_INTN int3
> > #include __CLC_BODY
> > #undef __CLC_GENTYPE
> > +#undef __CLC_INTN
> >
> > #define __CLC_GENTYPE float4
> > +#define __CLC_INTN int4
> > #include __CLC_BODY
> > #undef __CLC_GENTYPE
> > +#undef __CLC_INTN
> >
> > #define __CLC_GENTYPE float8
> > +#define __CLC_INTN int8
> > #include __CLC_BODY
> > #undef __CLC_GENTYPE
> > +#undef __CLC_INTN
> >
> > #define __CLC_GENTYPE float16
> > +#define __CLC_INTN int16
> > #include __CLC_BODY
> > #undef __CLC_GENTYPE
> > +#undef __CLC_INTN
> >
> > #undef __CLC_FPSIZE
> > #undef __CLC_SCALAR_GENTYPE
> > @@ -41,24 +51,34 @@
> > #undef __CLC_SCALAR
> >
> > #define __CLC_GENTYPE double2
> > +#define __CLC_INTN int2
> > #include __CLC_BODY
> > #undef __CLC_GENTYPE
> > +#undef __CLC_INTN
> >
> > #define __CLC_GENTYPE double3
> > +#define __CLC_INTN int3
> > #include __CLC_BODY
> > #undef __CLC_GENTYPE
> > +#undef __CLC_INTN
> >
> > #define __CLC_GENTYPE double4
> > +#define __CLC_INTN int4
> > #include __CLC_BODY
> > #undef __CLC_GENTYPE
> > +#undef __CLC_INTN
> >
> > #define __CLC_GENTYPE double8
> > +#define __CLC_INTN int8
> > #include __CLC_BODY
> > #undef __CLC_GENTYPE
> > +#undef __CLC_INTN
> >
> > #define __CLC_GENTYPE double16
> > +#define __CLC_INTN int16
> > #include __CLC_BODY
> > #undef __CLC_GENTYPE
> > +#undef __CLC_INTN
> >
> > #undef __CLC_FPSIZE
> > #undef __CLC_SCALAR_GENTYPE
> > diff --git a/generic/include/clc/math/ldexp.h b/generic/include/clc/math/ldexp.h
> > new file mode 100644
> > index 0000000..f87df88
> > --- /dev/null
> > +++ b/generic/include/clc/math/ldexp.h
> > @@ -0,0 +1,24 @@
> > +/*
> > + * Copyright (c) 2014,2015 Advanced Micro Devices, Inc.
> > + *
> > + * Permission is hereby granted, free of charge, to any person obtaining a copy
> > + * of this software and associated documentation files (the "Software"), to deal
> > + * in the Software without restriction, including without limitation the rights
> > + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> > + * copies of the Software, and to permit persons to whom the Software is
> > + * furnished to do so, subject to the following conditions:
> > + *
> > + * The above copyright notice and this permission notice shall be included in
> > + * all copies or substantial portions of the Software.
> > + *
> > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
> > + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> > + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> > + * THE SOFTWARE.
> > + */
> > +
> > +#define __CLC_BODY <clc/math/ldexp.inc>
> > +#include <clc/math/gentype.inc>
> > diff --git a/generic/include/clc/math/ldexp.inc b/generic/include/clc/math/ldexp.inc
> > new file mode 100644
> > index 0000000..67a22b2
> > --- /dev/null
> > +++ b/generic/include/clc/math/ldexp.inc
> > @@ -0,0 +1,29 @@
> > +/*
> > + * Copyright (c) 2014,2015 Advanced Micro Devices, Inc.
> > + *
> > + * Permission is hereby granted, free of charge, to any person obtaining a copy
> > + * of this software and associated documentation files (the "Software"), to deal
> > + * in the Software without restriction, including without limitation the rights
> > + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> > + * copies of the Software, and to permit persons to whom the Software is
> > + * furnished to do so, subject to the following conditions:
> > + *
> > + * The above copyright notice and this permission notice shall be included in
> > + * all copies or substantial portions of the Software.
> > + *
> > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
> > + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> > + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> > + * THE SOFTWARE.
> > + */
> > +
> > +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE ldexp(__CLC_GENTYPE x, int n);
> > +
> > +#ifndef __CLC_SCALAR
> > +
> > +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE ldexp(__CLC_GENTYPE x, __CLC_INTN n);
> > +
> > +#endif
> > diff --git a/r600/lib/SOURCES b/r600/lib/SOURCES
> > index ef23d83..0f1227e 100644
> > --- a/r600/lib/SOURCES
> > +++ b/r600/lib/SOURCES
> > @@ -1,4 +1,5 @@
> > atomic/atomic.cl
> > +math/ldexp.cl
> > math/nextafter.cl
> > workitem/get_num_groups.ll
> > workitem/get_group_id.ll
> > diff --git a/r600/lib/math/ldexp.cl b/r600/lib/math/ldexp.cl
> > new file mode 100644
> > index 0000000..6742cb9
> > --- /dev/null
> > +++ b/r600/lib/math/ldexp.cl
> > @@ -0,0 +1,38 @@
> > +/*
> > + * Copyright (c) 2014 Advanced Micro Devices, Inc.
> > + *
> > + * Permission is hereby granted, free of charge, to any person obtaining a copy
> > + * of this software and associated documentation files (the "Software"), to deal
> > + * in the Software without restriction, including without limitation the rights
> > + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> > + * copies of the Software, and to permit persons to whom the Software is
> > + * furnished to do so, subject to the following conditions:
> > + *
> > + * The above copyright notice and this permission notice shall be included in
> > + * all copies or substantial portions of the Software.
> > + *
> > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
> > + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> > + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> > + * THE SOFTWARE.
> > + */
> > +
> > +#include <clc/clc.h>
> > +
> > +#include "../../../generic/lib/clcmacro.h"
> > +
> > +// This defines all the ldexp(floatN, intN) variants.
> > +_CLC_DEFINE_BINARY_BUILTIN(float, ldexp, __builtin_amdgpu_ldexpf, float, int);
> > +
> > +#ifdef cl_khr_fp64
> > + #pragma OPENCL EXTENSION cl_khr_fp64 : enable
> > + // This defines all the ldexp(doubleN, intN) variants.
> > + _CLC_DEFINE_BINARY_BUILTIN(double, ldexp, __builtin_amdgpu_ldexp, double, int);
> > +#endif
> > +
> > +// This defines all the ldexp(GENTYPE, int);
> > +#define __CLC_BODY <ldexp.inc>
> > +#include <clc/math/gentype.inc>
> > diff --git a/r600/lib/math/ldexp.inc b/r600/lib/math/ldexp.inc
> > new file mode 100644
> > index 0000000..6e28fbb
> > --- /dev/null
> > +++ b/r600/lib/math/ldexp.inc
> > @@ -0,0 +1,29 @@
> > +/*
> > + * Copyright (c) 2014 Advanced Micro Devices, Inc.
> > + *
> > + * Permission is hereby granted, free of charge, to any person obtaining a copy
> > + * of this software and associated documentation files (the "Software"), to deal
> > + * in the Software without restriction, including without limitation the rights
> > + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> > + * copies of the Software, and to permit persons to whom the Software is
> > + * furnished to do so, subject to the following conditions:
> > + *
> > + * The above copyright notice and this permission notice shall be included in
> > + * all copies or substantial portions of the Software.
> > + *
> > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
> > + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> > + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> > + * THE SOFTWARE.
> > + */
> > +
> > +#ifndef __CLC_SCALAR
> > +
> > +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE ldexp(__CLC_GENTYPE x, int n) {
> > + return ldexp(x, (__CLC_INTN)n);
> > +}
> > +
> > +#endif
>
--
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/20150506/e3230f79/attachment.sig>
More information about the Libclc-dev
mailing list