[Beignet] [PATCH] Add some preprocessor macros __IMAGE_SUPPORT__ and __FAST_RELAXED_MATH__ define.

Yang Rong rong.r.yang at intel.com
Wed Oct 9 01:44:47 PDT 2013


Signed-off-by: Yang Rong <rong.r.yang at intel.com>
---
 backend/src/backend/program.cpp | 7 ++++++-
 backend/src/ocl_stdlib.tmpl.h   | 1 +
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/backend/src/backend/program.cpp b/backend/src/backend/program.cpp
index 647a958..6ba9593 100644
--- a/backend/src/backend/program.cpp
+++ b/backend/src/backend/program.cpp
@@ -449,6 +449,7 @@ namespace gbe {
     // Arguments to pass to the clang frontend
     vector<const char *> args;
     bool bOpt = true;
+    bool bFastMath = false;
 
     vector<std::string> useless; //hold substrings to avoid c_str free
     size_t start = 0, end = 0;
@@ -465,6 +466,7 @@ namespace gbe {
       if(str.size() == 0)
         continue;
       if(str == "-cl-opt-disable") bOpt = false;
+      if(str == "-cl-fast-relaxed-math") bFastMath = true;
       useless.push_back(str);
       args.push_back(str.c_str());
     }
@@ -475,7 +477,10 @@ namespace gbe {
     // XXX we haven't implement those builtin functions,
     // so disable it currently.
     args.push_back("-fno-builtin");
-    if(bOpt)  args.push_back("-O2");
+    if(bOpt)
+      args.push_back("-O3");
+    if(bFastMath)
+      args.push_back("-D __FAST_RELAXED_MATH__=1");
 #if LLVM_VERSION_MINOR <= 2
     args.push_back("-triple");
     args.push_back("nvptx");
diff --git a/backend/src/ocl_stdlib.tmpl.h b/backend/src/ocl_stdlib.tmpl.h
index 170ec70..eada9fd 100644
--- a/backend/src/ocl_stdlib.tmpl.h
+++ b/backend/src/ocl_stdlib.tmpl.h
@@ -110,6 +110,7 @@ typedef size_t __event_t;
 #define __CL_VERSION_1_0__ 100
 #define __CL_VERSION_1_1__ 110
 #define __ENDIAN_LITTLE__ 1
+#define __IMAGE_SUPPORT__ 1
 #define __kernel_exec(X, TYPE) __kernel __attribute__((work_group_size_hint(X,1,1))) \
                                         __attribute__((vec_type_hint(TYPE)))
 #define kernel_exec(X, TYPE) __kernel_exec(X, TYPE)
-- 
1.8.1.2



More information about the Beignet mailing list