[Beignet] [PATCH] GBE: fix bugs when handling -cl-std option.

Yang, Rong R rong.r.yang at intel.com
Wed Sep 10 23:20:15 PDT 2014


LGTM, thanks.

> -----Original Message-----
> From: Beignet [mailto:beignet-bounces at lists.freedesktop.org] On Behalf Of
> Zhigang Gong
> Sent: Thursday, September 11, 2014 9:52 AM
> To: beignet at lists.freedesktop.org
> Cc: Gong, Zhigang
> Subject: [Beignet] [PATCH] GBE: fix bugs when handling -cl-std option.
> 
> Actually, CLANG does take this option and we should not filter it out. We also
> change the default option to create PCH file to -cl-std=CL1.2. And if the user
> pass in a CL1.1 we will have to disable PCH.
> 
> Another change is that if we are CL1.2, then we should enable the cl_khr_fp64
> by default. As from CL1.2, this extension should be enabled by default.
> 
> Signed-off-by: Zhigang Gong <zhigang.gong at intel.com>
> ---
>  backend/src/backend/program.cpp   | 11 ++++++++---
>  backend/src/libocl/CMakeLists.txt |  3 +--
>  2 files changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/backend/src/backend/program.cpp
> b/backend/src/backend/program.cpp index 0aa5f14..cc76493 100644
> --- a/backend/src/backend/program.cpp
> +++ b/backend/src/backend/program.cpp
> @@ -659,7 +659,7 @@ namespace gbe {
>        const std::string unsupportedOptions("-cl-denorms-are-zero,
> -cl-strict-aliasing, -cl-opt-disable,"
>                         "-cl-no-signed-zeros,
> -cl-fp32-correctly-rounded-divide-sqrt");
> 
> -      const std::string uncompatiblePCHOptions =
> ("-cl-single-precision-constant, -cl-fast-relaxed-math");
> +      const std::string uncompatiblePCHOptions =
> + ("-cl-single-precision-constant, -cl-fast-relaxed-math,
> + -cl-std=CL1.1");
>        const std::string fastMathOption = ("-cl-fast-relaxed-math");
>        while (end != std::string::npos) {
>          end = optionStr.find(' ', start); @@ -683,7 +683,6 @@ namespace
> gbe {
>                *errSize = snprintf(err, stringSize, "Invalid build
> option: %s\n", str.c_str());
>              return false;
>            }
> -          continue;
>          }
> 
>          if (uncompatiblePCHOptions.find(str) != std::string::npos) @@
> -699,8 +698,10 @@ namespace gbe {
>        free(str);
>      }
> 
> -    if (useDefaultCLCVersion)
> +    if (useDefaultCLCVersion) {
>        clOpt.push_back("-D__OPENCL_C_VERSION__=120");
> +      clOpt.push_back("-cl-std=CL1.2");
> +    }
>      //for clCompilerProgram usage.
>      if(temp_header_path){
>        clOpt.push_back("-I");
> @@ -721,6 +722,10 @@ namespace gbe {
>      FILE *clFile = fdopen(clFd, "w");
>      FATAL_IF(clFile == NULL, "Failed to open temporary file");
> 
> +    #define ENABLE_CL_KHR_FP64_STR "#pragma OPENCL EXTENSION
> cl_khr_fp64 : enable\n"
> +    if (options && !strstr(const_cast<char *>(options), "-cl-std=CL1.1"))
> +      fwrite(ENABLE_CL_KHR_FP64_STR,
> strlen(ENABLE_CL_KHR_FP64_STR), 1,
> + clFile);
> +
>      if (!findPCH || invalidPCH) {
>        clOpt.push_back("-include");
>        clOpt.push_back("ocl.h");
> diff --git a/backend/src/libocl/CMakeLists.txt
> b/backend/src/libocl/CMakeLists.txt
> index d71f70b..f015eec 100644
> --- a/backend/src/libocl/CMakeLists.txt
> +++ b/backend/src/libocl/CMakeLists.txt
> @@ -129,8 +129,7 @@ FOREACH(M ${OCL_BASH_GENERATED_MODULES})
>  ENDFOREACH(M)
> 
> 
> -SET (CLANG_OCL_FLAGS -fno-builtin -ffp-contract=off -cl-kernel-arg-info
> -DGEN7_SAMPLER_CLAMP_BORDER_WORKAROUND)
> -
> +SET (CLANG_OCL_FLAGS -fno-builtin -ffp-contract=off -cl-kernel-arg-info
> +-DGEN7_SAMPLER_CLAMP_BORDER_WORKAROUND "-cl-std=CL1.2")
>  MACRO(ADD_CL_TO_BC_TARGET _file)
>      # CMake seems can not add pattern rule, use MACRO to replace.
>      STRING(REGEX REPLACE "${LIBOCL_BINARY_DIR}/src/\(o.*\)\\.cl"
> "${LIBOCL_BINARY_DIR}/lib/\\1.bc" output_name ${_file})
> --
> 1.8.3.2
> 
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/beignet


More information about the Beignet mailing list