[Beignet] [PATCH 1/2] Enable cospi, cbrt, tan

Homer Hsing homer.xing at intel.com
Wed May 8 19:12:11 PDT 2013


rename 'native_powr' to 'native_pow'
'native_exp' uses 'M_E_F'
delete 'powr' because it is same as 'native_pow'
also enable 'cospi', 'cbrt', 'tan'

Signed-off-by: Homer Hsing <homer.xing at intel.com>
---
 backend/src/ocl_stdlib.h | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/backend/src/ocl_stdlib.h b/backend/src/ocl_stdlib.h
index 4c0d39c..233fe10 100644
--- a/backend/src/ocl_stdlib.h
+++ b/backend/src/ocl_stdlib.h
@@ -395,6 +395,9 @@ PURE CONST float __gen_ocl_rnde(float x);
 PURE CONST float __gen_ocl_rndu(float x);
 PURE CONST float __gen_ocl_rndd(float x);
 INLINE OVERLOADABLE float native_cos(float x) { return __gen_ocl_cos(x); }
+INLINE OVERLOADABLE float native_cospi(float x) {
+  return native_cos(x * M_PI_F);
+}
 INLINE OVERLOADABLE float native_sin(float x) { return __gen_ocl_sin(x); }
 INLINE OVERLOADABLE float native_sqrt(float x) { return __gen_ocl_sqrt(x); }
 INLINE OVERLOADABLE float native_rsqrt(float x) { return __gen_ocl_rsqrt(x); }
@@ -405,14 +408,15 @@ INLINE OVERLOADABLE float native_log(float x) {
 INLINE OVERLOADABLE float native_log10(float x) {
   return native_log2(x) * 0.3010299956f;
 }
-INLINE OVERLOADABLE float native_powr(float x, float y) { return __gen_ocl_pow(x,y); }
+INLINE OVERLOADABLE float native_pow(float x, float y) { return __gen_ocl_pow(x,y); }
 INLINE OVERLOADABLE float native_recip(float x) { return __gen_ocl_rcp(x); }
 INLINE OVERLOADABLE float native_tan(float x) {
   return native_sin(x) / native_cos(x);
 }
-#define E 2.71828182845904523536f
-INLINE OVERLOADABLE float native_exp(float x) { return native_powr(E, x); }
-#undef E
+INLINE OVERLOADABLE float native_exp(float x) { return native_pow(M_E_F, x); }
+INLINE OVERLOADABLE float native_cbrt(float x) {
+  return native_pow(x, 0.33333333333333333333333f);
+}
 
 // XXX work-around PTX profile
 #define sqrt native_sqrt
@@ -426,13 +430,15 @@ INLINE OVERLOADABLE float __gen_ocl_internal_log(float x)   { return native_log(
 INLINE OVERLOADABLE float __gen_ocl_internal_log2(float x)  { return native_log2(x); }
 INLINE OVERLOADABLE float __gen_ocl_internal_log10(float x) { return native_log10(x); }
 INLINE OVERLOADABLE float __gen_ocl_internal_exp(float x)   { return native_exp(x); }
-INLINE OVERLOADABLE float powr(float x, float y) { return __gen_ocl_pow(x,y); }
 INLINE OVERLOADABLE float fmod(float x, float y) { return x-y*__gen_ocl_rndz(x/y); }
 
 // TODO use llvm intrinsics definitions
 #define cos native_cos
+#define cospi native_cospi
 #define sin native_sin
-#define pow powr
+#define tan native_tan
+#define pow native_pow
+#define cbrt native_cbrt
 
 INLINE OVERLOADABLE float mad(float a, float b, float c) {
   return a*b+c;
@@ -641,12 +647,14 @@ DECL_UNTYPED_RW_ALL(float)
     return dst;\
   }
 DECL_VECTOR_1OP(native_cos, float);
+DECL_VECTOR_1OP(native_cospi, float);
 DECL_VECTOR_1OP(native_sin, float);
 DECL_VECTOR_1OP(native_tan, float);
 DECL_VECTOR_1OP(native_sqrt, float);
 DECL_VECTOR_1OP(native_rsqrt, float);
 DECL_VECTOR_1OP(native_log2, float);
 DECL_VECTOR_1OP(native_recip, float);
+DECL_VECTOR_1OP(native_cbrt, float);
 DECL_VECTOR_1OP(__gen_ocl_internal_fabs, float);
 DECL_VECTOR_1OP(__gen_ocl_internal_trunc, float);
 DECL_VECTOR_1OP(__gen_ocl_internal_round, float);
@@ -687,7 +695,7 @@ DECL_VECTOR_2OP(max, float);
 DECL_VECTOR_2OP(__gen_ocl_internal_fmin, float);
 DECL_VECTOR_2OP(__gen_ocl_internal_fmax, float);
 DECL_VECTOR_2OP(fmod, float);
-DECL_VECTOR_2OP(powr, float);
+DECL_VECTOR_2OP(native_pow, float);
 #undef DECL_VECTOR_2OP
 
 #define DECL_VECTOR_3OP(NAME, TYPE) \
-- 
1.8.1.2



More information about the Beignet mailing list