[libclc] r236638 - Implement ldexp for R600/SI
Tom Stellard
thomas.stellard at amd.com
Wed May 6 13:53:30 PDT 2015
Author: tstellar
Date: Wed May 6 15:53:29 2015
New Revision: 236638
URL: http://llvm.org/viewvc/llvm-project?rev=236638&view=rev
Log:
Implement ldexp for R600/SI
Added:
libclc/trunk/generic/include/clc/math/ldexp.h
libclc/trunk/generic/include/clc/math/ldexp.inc
libclc/trunk/r600/lib/math/ldexp.cl
libclc/trunk/r600/lib/math/ldexp.inc
Modified:
libclc/trunk/generic/include/clc/clc.h
libclc/trunk/generic/include/clc/math/gentype.inc
libclc/trunk/r600/lib/SOURCES
Modified: libclc/trunk/generic/include/clc/clc.h
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/clc.h?rev=236638&r1=236637&r2=236638&view=diff
==============================================================================
--- libclc/trunk/generic/include/clc/clc.h (original)
+++ libclc/trunk/generic/include/clc/clc.h Wed May 6 15:53:29 2015
@@ -59,6 +59,7 @@
#include <clc/math/fract.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>
Modified: libclc/trunk/generic/include/clc/math/gentype.inc
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/gentype.inc?rev=236638&r1=236637&r2=236638&view=diff
==============================================================================
--- libclc/trunk/generic/include/clc/math/gentype.inc (original)
+++ libclc/trunk/generic/include/clc/math/gentype.inc Wed May 6 15:53:29 2015
@@ -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
Added: libclc/trunk/generic/include/clc/math/ldexp.h
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/ldexp.h?rev=236638&view=auto
==============================================================================
--- libclc/trunk/generic/include/clc/math/ldexp.h (added)
+++ libclc/trunk/generic/include/clc/math/ldexp.h Wed May 6 15:53:29 2015
@@ -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>
Added: libclc/trunk/generic/include/clc/math/ldexp.inc
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/ldexp.inc?rev=236638&view=auto
==============================================================================
--- libclc/trunk/generic/include/clc/math/ldexp.inc (added)
+++ libclc/trunk/generic/include/clc/math/ldexp.inc Wed May 6 15:53:29 2015
@@ -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
Modified: libclc/trunk/r600/lib/SOURCES
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/r600/lib/SOURCES?rev=236638&r1=236637&r2=236638&view=diff
==============================================================================
--- libclc/trunk/r600/lib/SOURCES (original)
+++ libclc/trunk/r600/lib/SOURCES Wed May 6 15:53:29 2015
@@ -1,4 +1,5 @@
atomic/atomic.cl
+math/ldexp.cl
math/nextafter.cl
workitem/get_num_groups.ll
workitem/get_group_id.ll
Added: libclc/trunk/r600/lib/math/ldexp.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/r600/lib/math/ldexp.cl?rev=236638&view=auto
==============================================================================
--- libclc/trunk/r600/lib/math/ldexp.cl (added)
+++ libclc/trunk/r600/lib/math/ldexp.cl Wed May 6 15:53:29 2015
@@ -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>
Added: libclc/trunk/r600/lib/math/ldexp.inc
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/r600/lib/math/ldexp.inc?rev=236638&view=auto
==============================================================================
--- libclc/trunk/r600/lib/math/ldexp.inc (added)
+++ libclc/trunk/r600/lib/math/ldexp.inc Wed May 6 15:53:29 2015
@@ -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
More information about the cfe-commits
mailing list