[Beignet] [PATCH 4/4] replace exp with llvm intrinsic.
xionghu.luo at intel.com
xionghu.luo at intel.com
Thu Jan 29 22:15:21 PST 2015
From: Luo Xionghu <xionghu.luo at intel.com>
translate native exp to llvm.exp2 for fast path.
Signed-off-by: Luo Xionghu <xionghu.luo at intel.com>
---
backend/src/libocl/tmpl/ocl_math.tmpl.cl | 2 +-
backend/src/llvm/llvm_gen_backend.cpp | 4 ++--
backend/src/llvm/llvm_gen_ocl_function.hxx | 1 -
3 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/backend/src/libocl/tmpl/ocl_math.tmpl.cl b/backend/src/libocl/tmpl/ocl_math.tmpl.cl
index 64f702c..be28181 100644
--- a/backend/src/libocl/tmpl/ocl_math.tmpl.cl
+++ b/backend/src/libocl/tmpl/ocl_math.tmpl.cl
@@ -29,7 +29,7 @@ CONST float __gen_ocl_cos(float x) __asm("llvm.cos" ".f32");
CONST float __gen_ocl_sqrt(float x) __asm("llvm.sqrt" ".f32");
PURE CONST float __gen_ocl_rsqrt(float x);
CONST float __gen_ocl_log(float x) __asm("llvm.log2" ".f32");
-PURE CONST float __gen_ocl_exp(float x);
+CONST float __gen_ocl_exp(float x) __asm("llvm.exp2" ".f32");
PURE CONST float __gen_ocl_pow(float x, float y);
PURE CONST float __gen_ocl_rcp(float x);
PURE CONST float __gen_ocl_rndz(float x);
diff --git a/backend/src/llvm/llvm_gen_backend.cpp b/backend/src/llvm/llvm_gen_backend.cpp
index f49a4c6..1871724 100644
--- a/backend/src/llvm/llvm_gen_backend.cpp
+++ b/backend/src/llvm/llvm_gen_backend.cpp
@@ -2802,6 +2802,7 @@ error:
case Intrinsic::sin:
case Intrinsic::cos:
case Intrinsic::log2:
+ case Intrinsic::exp2:
this->newRegister(&I);
break;
default:
@@ -2855,7 +2856,6 @@ error:
case GEN_OCL_FBH:
case GEN_OCL_FBL:
case GEN_OCL_CBIT:
- case GEN_OCL_EXP:
case GEN_OCL_POW:
case GEN_OCL_RCP:
case GEN_OCL_ABS:
@@ -3273,6 +3273,7 @@ error:
case Intrinsic::sin: this->emitUnaryCallInst(I,CS,ir::OP_SIN); break;
case Intrinsic::cos: this->emitUnaryCallInst(I,CS,ir::OP_COS); break;
case Intrinsic::log2: this->emitUnaryCallInst(I,CS,ir::OP_LOG); break;
+ case Intrinsic::exp2: this->emitUnaryCallInst(I,CS,ir::OP_EXP); break;
default: NOT_IMPLEMENTED;
}
} else {
@@ -3341,7 +3342,6 @@ error:
ctx.REGION(dst, src, x.getIntegerValue());
break;
}
- case GEN_OCL_EXP: this->emitUnaryCallInst(I,CS,ir::OP_EXP); break;
case GEN_OCL_RSQ: this->emitUnaryCallInst(I,CS,ir::OP_RSQ); break;
case GEN_OCL_RCP: this->emitUnaryCallInst(I,CS,ir::OP_RCP); break;
case GEN_OCL_FABS: this->emitUnaryCallInst(I,CS,ir::OP_ABS); break;
diff --git a/backend/src/llvm/llvm_gen_ocl_function.hxx b/backend/src/llvm/llvm_gen_ocl_function.hxx
index d68cb72..45358d0 100644
--- a/backend/src/llvm/llvm_gen_ocl_function.hxx
+++ b/backend/src/llvm/llvm_gen_ocl_function.hxx
@@ -21,7 +21,6 @@ DECL_LLVM_GEN_FUNCTION(GET_WORK_DIM, __gen_ocl_get_work_dim)
// Math function
DECL_LLVM_GEN_FUNCTION(FABS, __gen_ocl_fabs)
DECL_LLVM_GEN_FUNCTION(RSQ, __gen_ocl_rsqrt)
-DECL_LLVM_GEN_FUNCTION(EXP, __gen_ocl_exp)
DECL_LLVM_GEN_FUNCTION(POW, __gen_ocl_pow)
DECL_LLVM_GEN_FUNCTION(RCP, __gen_ocl_rcp)
DECL_LLVM_GEN_FUNCTION(RNDZ, __gen_ocl_rndz)
--
1.9.1
More information about the Beignet
mailing list