[Beignet] [PATCH 2/2] Test 14 built-in functions

Homer Hsing homer.xing at intel.com
Tue May 14 23:33:16 PDT 2013


Test sincos, asin, asinpi, acos, acospi, atan, atanpi, atan2,
     atan2pi, copysign, erf, erfc, maxmag, minmag.

Signed-off-by: Homer Hsing <homer.xing at intel.com>
---
 kernels/compiler_math.cl     | 7 +++++++
 kernels/compiler_math_2op.cl | 5 +++++
 utests/compiler_math.cpp     | 7 +++++++
 utests/compiler_math_2op.cpp | 6 ++++++
 4 files changed, 25 insertions(+)

diff --git a/kernels/compiler_math.cl b/kernels/compiler_math.cl
index f325595..c6db004 100644
--- a/kernels/compiler_math.cl
+++ b/kernels/compiler_math.cl
@@ -26,6 +26,13 @@ __kernel void compiler_math(__global float *dst, __global float *src) {
     case 21: dst[i] = asinh(x); break;
     case 22: dst[i] = acosh(x); break;
     case 23: dst[i] = atanh(x); break;
+    case 24: dst[i] = asin(x); break;
+    case 25: dst[i] = acos(x); break;
+    case 26: dst[i] = atan(x); break;
+    case 27: dst[i] = asinpi(x); break;
+    case 28: dst[i] = acospi(x); break;
+    case 29: dst[i] = atanpi(x); break;
+    case 30: dst[i] = erf(x); break;
     default: dst[i] = 1.f; break;
   };
 }
diff --git a/kernels/compiler_math_2op.cl b/kernels/compiler_math_2op.cl
index 3a3eac3..5ccb2c2 100644
--- a/kernels/compiler_math_2op.cl
+++ b/kernels/compiler_math_2op.cl
@@ -11,6 +11,11 @@ kernel void compiler_math_2op(global float *dst, global float *src1, global floa
     case 5: dst[i] = pown(x, (int)y); break;
     case 6: dst[i] = remainder(x, y); break;
     case 7: dst[i] = rootn(x, (int)(y+1)); break;
+    case 8: dst[i] = atan2(y, x); break;
+    case 9: dst[i] = atan2pi(y, x); break;
+    case 10: dst[i] = copysign(x, y); break;
+    case 11: dst[i] = maxmag(x, y); break;
+    case 12: dst[i] = minmag(x, y); break;
     default: dst[i] = 1.f; break;
   };
 }
diff --git a/utests/compiler_math.cpp b/utests/compiler_math.cpp
index 8799b8e..d597f2e 100644
--- a/utests/compiler_math.cpp
+++ b/utests/compiler_math.cpp
@@ -31,6 +31,13 @@ static void cpu_compiler_math(float *dst, float *src, int i)
     case 21: dst[i] = asinhf(x); break;
     case 22: dst[i] = acoshf(x); break;
     case 23: dst[i] = atanhf(x); break;
+    case 24: dst[i] = asinf(x); break;
+    case 25: dst[i] = acosf(x); break;
+    case 26: dst[i] = atanf(x); break;
+    case 27: dst[i] = asinf(x) / PI; break;
+    case 28: dst[i] = acosf(x) / PI; break;
+    case 29: dst[i] = atanf(x) / PI; break;
+    case 30: dst[i] = erff(x); break;
     default: dst[i] = 1.f; break;
   };
 }
diff --git a/utests/compiler_math_2op.cpp b/utests/compiler_math_2op.cpp
index 4a5c18c..004eb59 100644
--- a/utests/compiler_math_2op.cpp
+++ b/utests/compiler_math_2op.cpp
@@ -5,6 +5,7 @@
 static void cpu_compiler_math(float *dst, float *src1, float *src2, int i)
 {
   const float x = src1[i], y = src2[i];
+  const float PI = 3.141592653589793f;
   switch (i) {
     case 0: dst[i] = x / y; break;
     case 1: dst[i] = x > y ? x - y : 0; break;
@@ -14,6 +15,11 @@ static void cpu_compiler_math(float *dst, float *src1, float *src2, int i)
     case 5: dst[i] = powf(x, (int)y); break;
     case 6: dst[i] = x - roundf(x/y)*y; break;
     case 7: dst[i] = powf(x, 1.f/(int)(y+1)); break;
+    case 8: dst[i] = atanf(y / x); break;
+    case 9: dst[i] = atanf(y / x) / PI; break;
+    case 10: dst[i] = x * y < 0 ? -x : x; break;
+    case 11: dst[i] = fabsf(x) > fabsf(y) ? x : fabsf(y) > fabsf(x) ? y : fmaxf(x, y); break;
+    case 12: dst[i] = fabsf(x) < fabsf(y) ? x : fabsf(y) < fabsf(x) ? y : fminf(x, y); break;
     default: dst[i] = 1.f; break;
   };
 }
-- 
1.8.1.2



More information about the Beignet mailing list