Merge lp:~schnetter/pocl/main into lp:~pocl/pocl/trunk

Proposed by Erik Schnetter
Status: Merged
Merged at revision: 66
Proposed branch: lp:~schnetter/pocl/main
Merge into: lp:~pocl/pocl/trunk
Diff against target: 503 lines (+177/-66)
20 files modified
include/_kernel.h (+26/-4)
lib/kernel/acospi.cl (+4/-0)
lib/kernel/asinpi.cl (+4/-0)
lib/kernel/atan2pi.cl (+4/-0)
lib/kernel/atanpi.cl (+4/-0)
lib/kernel/cospi.cl (+4/-1)
lib/kernel/degrees.cl (+5/-1)
lib/kernel/exp10.cl (+4/-0)
lib/kernel/fdim.cl (+1/-1)
lib/kernel/fract.cl (+5/-0)
lib/kernel/radians.cl (+5/-1)
lib/kernel/rsqrt.cl (+1/-1)
lib/kernel/signbit.cl (+1/-1)
lib/kernel/sinpi.cl (+4/-0)
lib/kernel/smoothstep.cl (+2/-2)
lib/kernel/step.cl (+2/-2)
lib/kernel/tanpi.cl (+4/-0)
lib/kernel/tce/Makefile.am (+0/-52)
lib/kernel/templates.h (+42/-0)
lib/kernel/x86_64/signbit.cl (+55/-0)
To merge this branch: bzr merge lp:~schnetter/pocl/main
Reviewer Review Type Date Requested Status
Carlos Sánchez de La Lama Approve
Review via email: mp+81349@code.launchpad.net
To post a comment you must log in.
lp:~schnetter/pocl/main updated
77. By Erik Schnetter

Add missing lib/kernel/tce that got lost in the merge

Revision history for this message
Carlos Sánchez de La Lama (csanchezdll) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'include/_kernel.h'
--- include/_kernel.h 2011-11-03 18:58:00 +0000
+++ include/_kernel.h 2011-11-05 00:27:24 +0000
@@ -48,9 +48,6 @@
48#define cl_khr_fp6448#define cl_khr_fp64
49#define cl_khr_int6449#define cl_khr_int64
5050
51/* Shouldn't the compiler define this? */
52//#define __SSE4_1__
53
54#endif51#endif
5552
56/* Enable double precision. This should really only be done when53/* Enable double precision. This should really only be done when
@@ -928,6 +925,7 @@
928#define M_SQRT2_F 1.41421356237309504880168872421f925#define M_SQRT2_F 1.41421356237309504880168872421f
929#define M_SQRT1_2_F 0.707106781186547524400844362105f926#define M_SQRT1_2_F 0.707106781186547524400844362105f
930927
928#ifdef cl_khr_fp64
931#define HUGE_VAL __builtin_huge_val()929#define HUGE_VAL __builtin_huge_val()
932930
933#define DBL_DIG 15931#define DBL_DIG 15
@@ -953,6 +951,7 @@
953#define M_2_SQRTPI 1.12837916709551257389615890312951#define M_2_SQRTPI 1.12837916709551257389615890312
954#define M_SQRT2 1.41421356237309504880168872421952#define M_SQRT2 1.41421356237309504880168872421
955#define M_SQRT1_2 0.707106781186547524400844362105953#define M_SQRT1_2 0.707106781186547524400844362105
954#endif
956955
957956
958957
959/* Math Functions */958/* Math Functions */
@@ -1344,6 +1343,29 @@
1344 int16 _cl_overloadable NAME(float16 );1343 int16 _cl_overloadable NAME(float16 );
1345#endif1344#endif
1346#ifdef cl_khr_fp641345#ifdef cl_khr_fp64
1346#define _CL_DECLARE_FUNC_K_V(NAME) \
1347 int _cl_overloadable NAME(float ); \
1348 int2 _cl_overloadable NAME(float2 ); \
1349 int3 _cl_overloadable NAME(float3 ); \
1350 int4 _cl_overloadable NAME(float4 ); \
1351 int8 _cl_overloadable NAME(float8 ); \
1352 int16 _cl_overloadable NAME(float16 ); \
1353 int _cl_overloadable NAME(double ); \
1354 long2 _cl_overloadable NAME(double2 ); \
1355 long3 _cl_overloadable NAME(double3 ); \
1356 long4 _cl_overloadable NAME(double4 ); \
1357 long8 _cl_overloadable NAME(double8 ); \
1358 long16 _cl_overloadable NAME(double16);
1359#else
1360#define _CL_DECLARE_FUNC_K_V(NAME) \
1361 int _cl_overloadable NAME(float ); \
1362 int2 _cl_overloadable NAME(float2 ); \
1363 int3 _cl_overloadable NAME(float3 ); \
1364 int4 _cl_overloadable NAME(float4 ); \
1365 int8 _cl_overloadable NAME(float8 ); \
1366 int16 _cl_overloadable NAME(float16 );
1367#endif
1368#ifdef cl_khr_fp64
1347#define _CL_DECLARE_FUNC_S_V(NAME) \1369#define _CL_DECLARE_FUNC_S_V(NAME) \
1348 float _cl_overloadable NAME(float ); \1370 float _cl_overloadable NAME(float ); \
1349 float _cl_overloadable NAME(float2 ); \1371 float _cl_overloadable NAME(float2 ); \
@@ -2242,7 +2264,7 @@
2242_CL_DECLARE_FUNC_J_VV(isnormal)2264_CL_DECLARE_FUNC_J_VV(isnormal)
2243_CL_DECLARE_FUNC_J_VV(isordered)2265_CL_DECLARE_FUNC_J_VV(isordered)
2244_CL_DECLARE_FUNC_J_VV(isunordered)2266_CL_DECLARE_FUNC_J_VV(isunordered)
2245_CL_DECLARE_FUNC_J_V(signbit)2267_CL_DECLARE_FUNC_K_V(signbit)
2246_CL_DECLARE_FUNC_I_IG(any)2268_CL_DECLARE_FUNC_I_IG(any)
2247_CL_DECLARE_FUNC_I_IG(all)2269_CL_DECLARE_FUNC_I_IG(all)
2248_CL_DECLARE_FUNC_G_GGG(bitselect)2270_CL_DECLARE_FUNC_G_GGG(bitselect)
22492271
=== modified file 'lib/kernel/acospi.cl'
--- lib/kernel/acospi.cl 2011-10-26 03:01:29 +0000
+++ lib/kernel/acospi.cl 2011-11-05 00:27:24 +0000
@@ -23,4 +23,8 @@
2323
24#include "templates.h"24#include "templates.h"
2525
26#ifdef cl_khr_fp64
26DEFINE_EXPR_V_V(acospi, acos(a)/(stype)M_PI)27DEFINE_EXPR_V_V(acospi, acos(a)/(stype)M_PI)
28#else
29DEFINE_EXPR_V_V(acospi, acos(a)/M_PI_F)
30#endif
2731
=== modified file 'lib/kernel/asinpi.cl'
--- lib/kernel/asinpi.cl 2011-10-26 03:01:29 +0000
+++ lib/kernel/asinpi.cl 2011-11-05 00:27:24 +0000
@@ -23,4 +23,8 @@
2323
24#include "templates.h"24#include "templates.h"
2525
26#ifdef cl_khr_fp64
26DEFINE_EXPR_V_V(asinpi, asin(a)/(stype)M_PI)27DEFINE_EXPR_V_V(asinpi, asin(a)/(stype)M_PI)
28#else
29DEFINE_EXPR_V_V(asinpi, asin(a)/M_PI_F)
30#endif
2731
=== modified file 'lib/kernel/atan2pi.cl'
--- lib/kernel/atan2pi.cl 2011-10-26 03:01:29 +0000
+++ lib/kernel/atan2pi.cl 2011-11-05 00:27:24 +0000
@@ -23,4 +23,8 @@
2323
24#include "templates.h"24#include "templates.h"
2525
26#ifdef cl_khr_fp64
26DEFINE_EXPR_V_VV(atan2pi, atan2(a, b)/(stype)M_PI)27DEFINE_EXPR_V_VV(atan2pi, atan2(a, b)/(stype)M_PI)
28#else
29DEFINE_EXPR_V_VV(atan2pi, atan2(a, b)/M_PI_F)
30#endif
2731
=== modified file 'lib/kernel/atanpi.cl'
--- lib/kernel/atanpi.cl 2011-10-26 03:01:29 +0000
+++ lib/kernel/atanpi.cl 2011-11-05 00:27:24 +0000
@@ -23,4 +23,8 @@
2323
24#include "templates.h"24#include "templates.h"
2525
26#ifdef cl_khr_fp64
26DEFINE_EXPR_V_V(atanpi, atan(a)/(stype)M_PI)27DEFINE_EXPR_V_V(atanpi, atan(a)/(stype)M_PI)
28#else
29DEFINE_EXPR_V_V(atanpi, atan(a)/M_PI_F)
30#endif
2731
=== modified file 'lib/kernel/cospi.cl'
--- lib/kernel/cospi.cl 2011-10-26 03:01:29 +0000
+++ lib/kernel/cospi.cl 2011-11-05 00:27:24 +0000
@@ -23,5 +23,8 @@
2323
24#include "templates.h"24#include "templates.h"
2525
26#undef cospi26#ifdef cl_khr_fp64
27DEFINE_EXPR_V_V(cospi, cos((stype)M_PI*a))27DEFINE_EXPR_V_V(cospi, cos((stype)M_PI*a))
28#else
29DEFINE_EXPR_V_V(cospi, cos(M_PI_F*a))
30#endif
2831
=== modified file 'lib/kernel/degrees.cl'
--- lib/kernel/degrees.cl 2011-10-26 21:01:40 +0000
+++ lib/kernel/degrees.cl 2011-11-05 00:27:24 +0000
@@ -23,4 +23,8 @@
2323
24#include "templates.h"24#include "templates.h"
2525
26DEFINE_EXPR_V_V(degrees, (stype)(180.0 / M_PI) * a)26#ifdef cl_khr_fp64
27DEFINE_EXPR_V_V(degrees, (stype)(180 / M_PI) * a)
28#else
29DEFINE_EXPR_V_V(degrees, (180 / M_PI_F) * a)
30#endif
2731
=== modified file 'lib/kernel/exp10.cl'
--- lib/kernel/exp10.cl 2011-10-26 03:01:29 +0000
+++ lib/kernel/exp10.cl 2011-11-05 00:27:24 +0000
@@ -23,4 +23,8 @@
2323
24#include "templates.h"24#include "templates.h"
2525
26#ifdef cl_khr_fp64
26DEFINE_EXPR_V_V(exp10, exp((stype)M_LN10*a))27DEFINE_EXPR_V_V(exp10, exp((stype)M_LN10*a))
28#else
29DEFINE_EXPR_V_V(exp10, exp(M_LN10_F*a))
30#endif
2731
=== modified file 'lib/kernel/fdim.cl'
--- lib/kernel/fdim.cl 2011-10-26 03:01:29 +0000
+++ lib/kernel/fdim.cl 2011-11-05 00:27:24 +0000
@@ -23,4 +23,4 @@
2323
24#include "templates.h"24#include "templates.h"
2525
26DEFINE_EXPR_V_VV(fdim, fmax(a-b, (stype)0.0))26DEFINE_EXPR_V_VV(fdim, fmax(a-b, (stype)0))
2727
=== modified file 'lib/kernel/fract.cl'
--- lib/kernel/fract.cl 2011-10-26 03:01:29 +0000
+++ lib/kernel/fract.cl 2011-11-05 00:27:24 +0000
@@ -23,4 +23,9 @@
2323
24#include "templates.h"24#include "templates.h"
2525
26
27#ifdef cl_khr_fp64
26DEFINE_EXPR_V_VPV(fract, fmin(a - floor(a), (vtype)(stype)(sizeof(stype)==4 ? 0x1.fffffep-1f : 0x1.fffffffffffffp-1)))28DEFINE_EXPR_V_VPV(fract, fmin(a - floor(a), (vtype)(stype)(sizeof(stype)==4 ? 0x1.fffffep-1f : 0x1.fffffffffffffp-1)))
29#else
30DEFINE_EXPR_V_VPV(fract, fmin(a - floor(a), (vtype)(stype)0x1.fffffep-1f))
31#endif
2732
=== modified file 'lib/kernel/radians.cl'
--- lib/kernel/radians.cl 2011-10-26 21:01:40 +0000
+++ lib/kernel/radians.cl 2011-11-05 00:27:24 +0000
@@ -23,4 +23,8 @@
2323
24#include "templates.h"24#include "templates.h"
2525
26DEFINE_EXPR_V_V(radians, (stype)(M_PI / 180.0) * a)26#ifdef cl_khr_fp64
27DEFINE_EXPR_V_V(radians, (stype)(M_PI / 180) * a)
28#else
29DEFINE_EXPR_V_V(radians, (M_PI_F / 180) * a)
30#endif
2731
=== modified file 'lib/kernel/rsqrt.cl'
--- lib/kernel/rsqrt.cl 2011-10-26 03:01:29 +0000
+++ lib/kernel/rsqrt.cl 2011-11-05 00:27:24 +0000
@@ -23,4 +23,4 @@
2323
24#include "templates.h"24#include "templates.h"
2525
26DEFINE_EXPR_V_V(rsqrt, (stype)1.0/sqrt(a))26DEFINE_EXPR_V_V(rsqrt, (stype)1/sqrt(a))
2727
=== modified file 'lib/kernel/signbit.cl'
--- lib/kernel/signbit.cl 2011-10-27 01:35:56 +0000
+++ lib/kernel/signbit.cl 2011-11-05 00:27:24 +0000
@@ -23,4 +23,4 @@
2323
24#include "templates.h"24#include "templates.h"
2525
26DEFINE_BUILTIN_J_V(signbit)26DEFINE_BUILTIN_K_V(signbit)
2727
=== modified file 'lib/kernel/sinpi.cl'
--- lib/kernel/sinpi.cl 2011-10-26 03:01:29 +0000
+++ lib/kernel/sinpi.cl 2011-11-05 00:27:24 +0000
@@ -23,4 +23,8 @@
2323
24#include "templates.h"24#include "templates.h"
2525
26#ifdef cl_khr_fp64
26DEFINE_EXPR_V_V(sinpi, sin((stype)M_PI*a))27DEFINE_EXPR_V_V(sinpi, sin((stype)M_PI*a))
28#else
29DEFINE_EXPR_V_V(sinpi, sin(M_PI_F*a))
30#endif
2731
=== modified file 'lib/kernel/smoothstep.cl'
--- lib/kernel/smoothstep.cl 2011-10-27 00:18:42 +0000
+++ lib/kernel/smoothstep.cl 2011-11-05 00:27:24 +0000
@@ -25,7 +25,7 @@
2525
26DEFINE_EXPR_V_VVV(smoothstep,26DEFINE_EXPR_V_VVV(smoothstep,
27 ({27 ({
28 vtype t = clamp((c - a) / (b - a), (stype)0.0, (stype)1.0);28 vtype t = clamp((c - a) / (b - a), (stype)0, (stype)1);
29 t * t * mad((vtype)-2.0, t, (vtype)3.0);29 t * t * mad((vtype)-2, t, (vtype)3);
30 }))30 }))
31DEFINE_EXPR_V_SSV(smoothstep, smoothstep((vtype)a, (vtype)b, c))31DEFINE_EXPR_V_SSV(smoothstep, smoothstep((vtype)a, (vtype)b, c))
3232
=== modified file 'lib/kernel/step.cl'
--- lib/kernel/step.cl 2011-10-27 00:18:42 +0000
+++ lib/kernel/step.cl 2011-11-05 00:27:24 +0000
@@ -27,8 +27,8 @@
27// DEFINE_EXPR_V_VV(step, b < a ? (vtype)0.0 : (vtype)1.0)27// DEFINE_EXPR_V_VV(step, b < a ? (vtype)0.0 : (vtype)1.0)
28DEFINE_EXPR_V_VV(step,28DEFINE_EXPR_V_VV(step,
29 ({29 ({
30 vtype zero = 0.0;30 vtype zero = 0;
31 vtype one = 1.0;31 vtype one = 1;
32 jtype result = b < a ? *(jtype*)&zero : *(jtype*)&one;32 jtype result = b < a ? *(jtype*)&zero : *(jtype*)&one;
33 *(vtype*)&result;33 *(vtype*)&result;
34 }))34 }))
3535
=== modified file 'lib/kernel/tanpi.cl'
--- lib/kernel/tanpi.cl 2011-10-26 03:01:29 +0000
+++ lib/kernel/tanpi.cl 2011-11-05 00:27:24 +0000
@@ -23,4 +23,8 @@
2323
24#include "templates.h"24#include "templates.h"
2525
26#ifdef cl_khr_fp64
26DEFINE_EXPR_V_V(tanpi, tan((stype)M_PI*a))27DEFINE_EXPR_V_V(tanpi, tan((stype)M_PI*a))
28#else
29DEFINE_EXPR_V_V(tanpi, tan(M_PI_F*a))
30#endif
2731
=== added directory 'lib/kernel/tce'
=== removed directory 'lib/kernel/tce'
=== added file 'lib/kernel/tce/Makefile.am'
--- lib/kernel/tce/Makefile.am 1970-01-01 00:00:00 +0000
+++ lib/kernel/tce/Makefile.am 2011-11-05 00:27:24 +0000
@@ -0,0 +1,52 @@
1# Process this file with automake to produce Makefile.in (in this,
2# and all subdirectories).
3# Makefile.am for pocl/lib/kernel/tce.
4#
5# The TCE (http://tce.cs.tut.fi) target.
6#
7# Copyright (c) 2011 Universidad Rey Juan Carlos
8#
9# Permission is hereby granted, free of charge, to any person obtaining a copy
10# of this software and associated documentation files (the "Software"), to deal
11# in the Software without restriction, including without limitation the rights
12# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13# copies of the Software, and to permit persons to whom the Software is
14# furnished to do so, subject to the following conditions:
15#
16# The above copyright notice and this permission notice shall be included in
17# all copies or substantial portions of the Software.
18#
19# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25# THE SOFTWARE.
26
27targetpkglibdir = $(pkglibdir)/tce
28targetpkglib_LIBRARIES = libkernel.a
29
30vpath %.cl @srcdir@/..
31vpath %.c @srcdir@/..
32vpath %.ll @srcdir@/..
33
34include ../sources.mk
35
36libkernel_a_LIBADD = barrier.o
37EXTRA_DIST = barrier.ll
38
39RANLIB = `@LLVM_CONFIG@ --bindir`/llvm-ranlib
40AR = `@LLVM_CONFIG@ --bindir`/llvm-ar
41
42.cl.o:
43 $(CLANG) $(AM_CPPFLAGS) $(CLANGFLAGS) -ccc-host-triple tce-tut-llvm -c -emit-llvm -include $(top_srcdir)/include/_kernel.h -o $@ $<
44
45.c.o:
46 $(CLANG) $(AM_CPPFLAGS) $(CLANGFLAGS) -ccc-host-triple tce-tut-llvm -c -emit-llvm -include $(top_srcdir)/include/_kernel.h -o $@ $<
47
48barrier.o: barrier.ll
49 $(LLVM_AS) -o $@ $<
50
51$(libkernel_a_SOURCES:.c=.o): $(top_srcdir)/include/_kernel.h ../templates.h
52$(libkernel_a_SOURCES:.cl=.o): $(top_srcdir)/include/_kernel.h ../templates.h
053
=== removed file 'lib/kernel/tce/Makefile.am'
--- lib/kernel/tce/Makefile.am 2011-11-03 18:58:00 +0000
+++ lib/kernel/tce/Makefile.am 1970-01-01 00:00:00 +0000
@@ -1,52 +0,0 @@
1# Process this file with automake to produce Makefile.in (in this,
2# and all subdirectories).
3# Makefile.am for pocl/lib/kernel/tce.
4#
5# The TCE (http://tce.cs.tut.fi) target.
6#
7# Copyright (c) 2011 Universidad Rey Juan Carlos
8#
9# Permission is hereby granted, free of charge, to any person obtaining a copy
10# of this software and associated documentation files (the "Software"), to deal
11# in the Software without restriction, including without limitation the rights
12# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13# copies of the Software, and to permit persons to whom the Software is
14# furnished to do so, subject to the following conditions:
15#
16# The above copyright notice and this permission notice shall be included in
17# all copies or substantial portions of the Software.
18#
19# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25# THE SOFTWARE.
26
27targetpkglibdir = $(pkglibdir)/tce
28targetpkglib_LIBRARIES = libkernel.a
29
30vpath %.cl @srcdir@/..
31vpath %.c @srcdir@/..
32vpath %.ll @srcdir@/..
33
34include ../sources.mk
35
36libkernel_a_LIBADD = barrier.o
37EXTRA_DIST = barrier.ll
38
39RANLIB = `@LLVM_CONFIG@ --bindir`/llvm-ranlib
40AR = `@LLVM_CONFIG@ --bindir`/llvm-ar
41
42.cl.o:
43 $(CLANG) $(AM_CPPFLAGS) $(CLANGFLAGS) -ccc-host-triple tce-tut-llvm -c -emit-llvm -include $(top_srcdir)/include/_kernel.h -o $@ $<
44
45.c.o:
46 $(CLANG) $(AM_CPPFLAGS) $(CLANGFLAGS) -ccc-host-triple tce-tut-llvm -c -emit-llvm -include $(top_srcdir)/include/_kernel.h -o $@ $<
47
48barrier.o: barrier.ll
49 $(LLVM_AS) -o $@ $<
50
51$(libkernel_a_SOURCES:.c=.o): $(top_srcdir)/include/_kernel.h ../templates.h
52$(libkernel_a_SOURCES:.cl=.o): $(top_srcdir)/include/_kernel.h ../templates.h
530
=== modified file 'lib/kernel/templates.h'
--- lib/kernel/templates.h 2011-11-01 16:33:17 +0000
+++ lib/kernel/templates.h 2011-11-05 00:27:24 +0000
@@ -359,6 +359,48 @@
359 IMPLEMENT_BUILTIN_J_V(NAME, int16, float16 , lo, hi)359 IMPLEMENT_BUILTIN_J_V(NAME, int16, float16 , lo, hi)
360#endif360#endif
361361
362#define IMPLEMENT_BUILTIN_K_V(NAME, JTYPE, VTYPE, LO, HI) \
363 JTYPE __attribute__ ((overloadable)) \
364 NAME(VTYPE a) \
365 { \
366 return (JTYPE)(NAME(a.LO), NAME(a.HI)); \
367 }
368#ifdef cl_khr_fp64
369#define DEFINE_BUILTIN_K_V(NAME) \
370 int __attribute__ ((overloadable)) \
371 NAME(float a) \
372 { \
373 return __builtin_##NAME##f(a); \
374 } \
375 int __attribute__ ((overloadable)) \
376 NAME(double a) \
377 { \
378 return __builtin_##NAME(a); \
379 } \
380 IMPLEMENT_BUILTIN_K_V(NAME, int2 , float2 , lo, hi) \
381 IMPLEMENT_BUILTIN_K_V(NAME, int3 , float3 , lo, s2) \
382 IMPLEMENT_BUILTIN_K_V(NAME, int4 , float4 , lo, hi) \
383 IMPLEMENT_BUILTIN_K_V(NAME, int8 , float8 , lo, hi) \
384 IMPLEMENT_BUILTIN_K_V(NAME, int16 , float16 , lo, hi) \
385 IMPLEMENT_BUILTIN_K_V(NAME, long2 , double2 , lo, hi) \
386 IMPLEMENT_BUILTIN_K_V(NAME, long3 , double3 , lo, s2) \
387 IMPLEMENT_BUILTIN_K_V(NAME, long4 , double4 , lo, hi) \
388 IMPLEMENT_BUILTIN_K_V(NAME, long8 , double8 , lo, hi) \
389 IMPLEMENT_BUILTIN_K_V(NAME, long16, double16, lo, hi)
390#else
391#define DEFINE_BUILTIN_K_V(NAME) \
392 int __attribute__ ((overloadable)) \
393 NAME(float a) \
394 { \
395 return __builtin_##NAME##f(a); \
396 } \
397 IMPLEMENT_BUILTIN_K_V(NAME, int2 , float2 , lo, hi) \
398 IMPLEMENT_BUILTIN_K_V(NAME, int3 , float3 , lo, s2) \
399 IMPLEMENT_BUILTIN_K_V(NAME, int4 , float4 , lo, hi) \
400 IMPLEMENT_BUILTIN_K_V(NAME, int8 , float8 , lo, hi) \
401 IMPLEMENT_BUILTIN_K_V(NAME, int16, float16 , lo, hi)
402#endif
403
362#define IMPLEMENT_EXPR_V_V(NAME, EXPR, VTYPE, STYPE) \404#define IMPLEMENT_EXPR_V_V(NAME, EXPR, VTYPE, STYPE) \
363 VTYPE __attribute__ ((overloadable)) \405 VTYPE __attribute__ ((overloadable)) \
364 NAME(VTYPE a, VTYPE b) \406 NAME(VTYPE a, VTYPE b) \
365407
=== added file 'lib/kernel/x86_64/signbit.cl'
--- lib/kernel/x86_64/signbit.cl 1970-01-01 00:00:00 +0000
+++ lib/kernel/x86_64/signbit.cl 2011-11-05 00:27:24 +0000
@@ -0,0 +1,55 @@
1/* OpenCL built-in library: signbit()
2
3 Copyright (c) 2011 Universidad Rey Juan Carlos
4
5 Permission is hereby granted, free of charge, to any person obtaining a copy
6 of this software and associated documentation files (the "Software"), to deal
7 in the Software without restriction, including without limitation the rights
8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 copies of the Software, and to permit persons to whom the Software is
10 furnished to do so, subject to the following conditions:
11
12 The above copyright notice and this permission notice shall be included in
13 all copies or substantial portions of the Software.
14
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 FITNESS FOR A PARTICULAR PURPOSE AND NONORDEREDRINGEMENT. IN NO EVENT SHALL THE
18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 THE SOFTWARE.
22*/
23
24#define IMPLEMENT_SIGNBIT_BUILTIN_FLOAT __builtin_signbitf(a)
25#define IMPLEMENT_SIGNBIT_BUILTIN_DOUBLE __builtin_signbit(a)
26#define IMPLEMENT_SIGNBIT_DIRECT \
27 ({ \
28 int bits = CHAR_BIT * sizeof(stype); \
29 *(jtype*)&a >> (jtype)(bits-1); \
30 })
31
32#define IMPLEMENT_DIRECT(NAME, VTYPE, STYPE, JTYPE, EXPR) \
33 JTYPE _cl_overloadable NAME(VTYPE a) \
34 { \
35 typedef VTYPE vtype; \
36 typedef STYPE stype; \
37 typedef JTYPE jtype; \
38 return EXPR; \
39 }
40
41
42
43IMPLEMENT_DIRECT(signbit, float , float, int , IMPLEMENT_SIGNBIT_BUILTIN_FLOAT)
44IMPLEMENT_DIRECT(signbit, float2 , float, int2 , IMPLEMENT_SIGNBIT_DIRECT)
45IMPLEMENT_DIRECT(signbit, float3 , float, int3 , IMPLEMENT_SIGNBIT_DIRECT)
46IMPLEMENT_DIRECT(signbit, float4 , float, int4 , IMPLEMENT_SIGNBIT_DIRECT)
47IMPLEMENT_DIRECT(signbit, float8 , float, int8 , IMPLEMENT_SIGNBIT_DIRECT)
48IMPLEMENT_DIRECT(signbit, float16, float, int16, IMPLEMENT_SIGNBIT_DIRECT)
49
50IMPLEMENT_DIRECT(signbit, double , double, int , IMPLEMENT_SIGNBIT_BUILTIN_DOUBLE)
51IMPLEMENT_DIRECT(signbit, double2 , double, long2 , IMPLEMENT_SIGNBIT_DIRECT)
52IMPLEMENT_DIRECT(signbit, double3 , double, long3 , IMPLEMENT_SIGNBIT_DIRECT)
53IMPLEMENT_DIRECT(signbit, double4 , double, long4 , IMPLEMENT_SIGNBIT_DIRECT)
54IMPLEMENT_DIRECT(signbit, double8 , double, long8 , IMPLEMENT_SIGNBIT_DIRECT)
55IMPLEMENT_DIRECT(signbit, double16, double, long16, IMPLEMENT_SIGNBIT_DIRECT)