diff options
author | Junyan He <junyan.he@linux.intel.com> | 2014-09-10 15:39:41 +0800 |
---|---|---|
committer | Zhigang Gong <zhigang.gong@intel.com> | 2014-09-10 15:32:38 +0800 |
commit | 18d6a0611fd8d29ec9651655646d88bd88d2ef5e (patch) | |
tree | 9a31bf724d7d9b20ac78e8515226e7608b09bd6e /backend | |
parent | 7641b550a99b352207b225dd40686fe1ce7bd05c (diff) |
Fix the issue of -cl-std=CLX.X option.
The -cl-std= will specify the least version to compile
the source code providing to our API. So we need to
check it early, and return failure if our platform's
version can not meet the request. In the backend, we
just ignore this cmd line option.
Signed-off-by: Junyan He <junyan.he@linux.intel.com>
Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
Diffstat (limited to 'backend')
-rw-r--r-- | backend/src/backend/program.cpp | 17 | ||||
-rwxr-xr-x | backend/src/ocl_stdlib.tmpl.h | 4 |
2 files changed, 17 insertions, 4 deletions
diff --git a/backend/src/backend/program.cpp b/backend/src/backend/program.cpp index 20471f94..40adc1d0 100644 --- a/backend/src/backend/program.cpp +++ b/backend/src/backend/program.cpp @@ -555,6 +555,7 @@ namespace gbe { //Handle -cl-opt-disable in llvmToGen, skip here const std::string unsupportedOptions("-cl-denorms-are-zero, -cl-strict-aliasing, -cl-opt-disable," "-cl-no-signed-zeros, -cl-fp32-correctly-rounded-divide-sqrt"); + bool useDefaultCLCVersion = true; while (end != std::string::npos) { end = options.find(' ', start); std::string str = options.substr(start, end - start); @@ -564,9 +565,24 @@ namespace gbe { if(str == "-cl-fast-relaxed-math") bFastMath = true; if(unsupportedOptions.find(str) != std::string::npos) continue; + if(str.find("-cl-std=") != std::string::npos) { + useDefaultCLCVersion = false; + if (str == "-cl-std=CL1.1") + args.push_back("-D__OPENCL_C_VERSION__=110"); + else if (str == "-cl-std=CL1.2") + args.push_back("-D__OPENCL_C_VERSION__=120"); + else { + if (err && stringSize > 0 && errSize) + *errSize = snprintf(err, stringSize, "Invalid build option: %s\n", str.c_str()); + return false; + } + continue; + } useless.push_back(str); args.push_back(str.c_str()); } + if (useDefaultCLCVersion) + args.push_back("-D__OPENCL_C_VERSION__=120"); args.push_back("-mllvm"); args.push_back("-inline-threshold=200000"); #ifdef GEN7_SAMPLER_CLAMP_BORDER_WORKAROUND @@ -759,7 +775,6 @@ namespace gbe { "-cl-single-precision-constant", // "-cl-denorms-are-zero", "-cl-fast-relaxed-math", - "-cl-std=", }; const char * incompatible_defs[] = { "GET_FLOAT_WORD", diff --git a/backend/src/ocl_stdlib.tmpl.h b/backend/src/ocl_stdlib.tmpl.h index 6f05dac3..1ee90fe6 100755 --- a/backend/src/ocl_stdlib.tmpl.h +++ b/backend/src/ocl_stdlib.tmpl.h @@ -124,9 +124,7 @@ typedef size_t __event_t; #define __CL_VERSION_1_0__ 100 #define __CL_VERSION_1_1__ 110 #define __CL_VERSION_1_2__ 120 -#ifndef __OPENCL_C_VERSION -#define __OPENCL_C_VERSION__ 120 -#endif + #define __ENDIAN_LITTLE__ 1 #define __IMAGE_SUPPORT__ 1 #define __kernel_exec(X, TYPE) __kernel __attribute__((work_group_size_hint(X,1,1))) \ |