[Beignet] [PATCH] GBE: Fix fast-math issue under llvm 3.6.
Ruiling Song
ruiling.song at intel.com
Fri Feb 27 21:44:05 PST 2015
"__ocl_math_fastpath_flag" was directly optimized out when compiling libocl under llvm 3.6
And set its initialization value after loading libocl.
Signed-off-by: Ruiling Song <ruiling.song at intel.com>
---
backend/src/libocl/tmpl/ocl_math.tmpl.cl | 2 +-
backend/src/llvm/llvm_bitcode_link.cpp | 10 ++++------
2 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/backend/src/libocl/tmpl/ocl_math.tmpl.cl b/backend/src/libocl/tmpl/ocl_math.tmpl.cl
index aaa6cc3..2ed7b31 100644
--- a/backend/src/libocl/tmpl/ocl_math.tmpl.cl
+++ b/backend/src/libocl/tmpl/ocl_math.tmpl.cl
@@ -21,7 +21,7 @@
#include "ocl_common.h"
#include "ocl_integer.h"
-constant int __ocl_math_fastpath_flag = 1;
+extern constant int __ocl_math_fastpath_flag;
PURE CONST float __gen_ocl_fabs(float x);
CONST float __gen_ocl_sin(float x) __asm("llvm.sin" ".f32");
diff --git a/backend/src/llvm/llvm_bitcode_link.cpp b/backend/src/llvm/llvm_bitcode_link.cpp
index 61e2ea1..96f7781 100644
--- a/backend/src/llvm/llvm_bitcode_link.cpp
+++ b/backend/src/llvm/llvm_bitcode_link.cpp
@@ -73,12 +73,10 @@ namespace gbe
return NULL;
}
- if (strictMath) {
- llvm::GlobalVariable* mathFastFlag = oclLib->getGlobalVariable("__ocl_math_fastpath_flag");
- assert(mathFastFlag);
- Type* intTy = IntegerType::get(ctx, 32);
- mathFastFlag->setInitializer(ConstantInt::get(intTy, 0));
- }
+ llvm::GlobalVariable* mathFastFlag = oclLib->getGlobalVariable("__ocl_math_fastpath_flag");
+ assert(mathFastFlag);
+ Type* intTy = IntegerType::get(ctx, 32);
+ mathFastFlag->setInitializer(ConstantInt::get(intTy, strictMath ? 0 : 1));
return oclLib;
}
--
1.7.10.4
More information about the Beignet
mailing list