summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuo Xionghu <xionghu.luo@intel.com>2015-11-26 14:00:04 +0800
committerYang Rong <rong.r.yang@intel.com>2015-12-09 11:42:58 +0800
commit4b5b444bd72b0b4a4a5b4a74253ec25355ef23d2 (patch)
tree0e50552d8a292134b74db868e1f85d7ea7302e49
parentbfa20bbcf4df90049a42fa65d6d0fc6c6ba4674c (diff)
gbe/libocl: define the gentype half_xxx math function instead of using MACRO.
these function need to be overloadable for link. Signed-off-by: Luo Xionghu <xionghu.luo@intel.com> Reviewed-by: Yang Rong <rong.r.yang@intel.com>
-rw-r--r--backend/src/libocl/script/ocl_math.def28
-rw-r--r--backend/src/libocl/tmpl/ocl_math.tmpl.cl42
-rw-r--r--backend/src/libocl/tmpl/ocl_math.tmpl.h29
3 files changed, 70 insertions, 29 deletions
diff --git a/backend/src/libocl/script/ocl_math.def b/backend/src/libocl/script/ocl_math.def
index 9c65af7b..b5c1e475 100644
--- a/backend/src/libocl/script/ocl_math.def
+++ b/backend/src/libocl/script/ocl_math.def
@@ -177,17 +177,17 @@ gentype native_tan (gentype x)
##half_native_math
-#gentype half_cos (gentype x)
-#gentype half_divide (gentype x, gentype y)
-#gentype half_exp (gentype x)
-#gentype half_exp2 (gentype x)
-#gentype half_exp10 (gentype x)
-#gentype half_log (gentype x)
-#gentype half_log2 (gentype x)
-#gentype half_log10 (gentype x)
-#gentype half_powr (gentype x, gentype y)
-#gentype half_recip (gentype x)
-#gentype half_rsqrt (gentype x)
-#gentype half_sin (gentype x)
-#gentype half_sqrt (gentype x)
-#gentype half_tan (gentype x)
+gentype half_cos (gentype x)
+gentype half_divide (gentype x, gentype y)
+gentype half_exp (gentype x)
+gentype half_exp2 (gentype x)
+gentype half_exp10 (gentype x)
+gentype half_log (gentype x)
+gentype half_log2 (gentype x)
+gentype half_log10 (gentype x)
+gentype half_powr (gentype x, gentype y)
+gentype half_recip (gentype x)
+gentype half_rsqrt (gentype x)
+gentype half_sin (gentype x)
+gentype half_sqrt (gentype x)
+gentype half_tan (gentype x)
diff --git a/backend/src/libocl/tmpl/ocl_math.tmpl.cl b/backend/src/libocl/tmpl/ocl_math.tmpl.cl
index dc0363d6..782bfd21 100644
--- a/backend/src/libocl/tmpl/ocl_math.tmpl.cl
+++ b/backend/src/libocl/tmpl/ocl_math.tmpl.cl
@@ -3608,6 +3608,48 @@ OVERLOADABLE half acos(half x) {
float _x = (float)x;
return (half)acos(_x);
}
+OVERLOADABLE float half_cos(float x) {
+ return (float)cos(x);
+}
+OVERLOADABLE float half_divide(float x, float y) {
+ return (float)native_divide(x, y);
+}
+OVERLOADABLE float half_exp(float x) {
+ return (float)native_exp(x);
+}
+OVERLOADABLE float half_exp2(float x){
+ return (float)native_exp2(x);
+}
+OVERLOADABLE float half_exp10(float x){
+ return (float)native_exp10(x);
+}
+OVERLOADABLE float half_log(float x){
+ return (float)native_log(x);
+}
+OVERLOADABLE float half_log2(float x){
+ return (float)native_log2(x);
+}
+OVERLOADABLE float half_log10(float x){
+ return (float)native_log10(x);
+}
+OVERLOADABLE float half_powr(float x, float y){
+ return (float)powr(x, y);
+}
+OVERLOADABLE float half_recip(float x){
+ return (float)native_recip(x);
+}
+OVERLOADABLE float half_rsqrt(float x){
+ return (float)native_rsqrt(x);
+}
+OVERLOADABLE float half_sin(float x){
+ return (float)sin(x);
+}
+OVERLOADABLE float half_sqrt(float x){
+ return (float)native_sqrt(x);
+}
+OVERLOADABLE float half_tan(float x){
+ return (float)tan(x);
+}
OVERLOADABLE half acospi(half x) {
float _x = (float)x;
return (half)acospi(_x);
diff --git a/backend/src/libocl/tmpl/ocl_math.tmpl.h b/backend/src/libocl/tmpl/ocl_math.tmpl.h
index 90dad1ff..0de36429 100644
--- a/backend/src/libocl/tmpl/ocl_math.tmpl.h
+++ b/backend/src/libocl/tmpl/ocl_math.tmpl.h
@@ -216,19 +216,18 @@ OVERLOADABLE half native_sin(half x);
OVERLOADABLE half native_sqrt(half x);
OVERLOADABLE half native_tan(half x);
-
// half accuracy
-#define half_cos cos
-#define half_divide native_divide
-#define half_exp native_exp
-#define half_exp2 native_exp2
-#define half_exp10 native_exp10
-#define half_log native_log
-#define half_log2 native_log2
-#define half_log10 native_log10
-#define half_powr powr
-#define half_recip native_recip
-#define half_rsqrt native_rsqrt
-#define half_sin sin
-#define half_sqrt native_sqrt
-#define half_tan tan
+OVERLOADABLE float half_cos(float x);
+OVERLOADABLE float half_divide(float x, float y);
+OVERLOADABLE float half_exp(float x);
+OVERLOADABLE float half_exp2(float x);
+OVERLOADABLE float half_exp10(float x);
+OVERLOADABLE float half_log(float x);
+OVERLOADABLE float half_log2(float x);
+OVERLOADABLE float half_log10(float x);
+OVERLOADABLE float half_powr(float x, float y);
+OVERLOADABLE float half_recip(float x);
+OVERLOADABLE float half_rsqrt(float x);
+OVERLOADABLE float half_sin(float x);
+OVERLOADABLE float half_sqrt(float x);
+OVERLOADABLE float half_tan(float x);