[Beignet] [PATCH] backend/src/backend: Handle -dump-opt-llvm=[PATH] in clCompileProgram OpenCL API

Navare, Manasi D manasi.d.navare at intel.com
Thu Aug 13 19:54:05 PDT 2015


Hi Ruiling,

But that would require sending dumpLLVMFileName as an aurgument to buildModuleFromSources().

Regards
Manasi

-----Original Message-----
From: Song, Ruiling 
Sent: Thursday, August 13, 2015 7:18 PM
To: Navare, Manasi D; beignet at lists.freedesktop.org
Subject: RE: [PATCH] backend/src/backend: Handle -dump-opt-llvm=[PATH] in clCompileProgram OpenCL API



> -----Original Message-----
> From: Navare, Manasi D
> Sent: Thursday, August 13, 2015 8:59 PM
> To: beignet at lists.freedesktop.org; Song, Ruiling
> Cc: Navare, Manasi D
> Subject: [PATCH] backend/src/backend: Handle -dump-opt-llvm=[PATH] in 
> clCompileProgram OpenCL API
> 
> Allows the user to request a dump of the LLVM-generated IR to the file 
> specified in [PATH] through clCompileProgram options
> 
> Signed-off-by: Manasi Navare <manasi.d.navare at intel.com>
> ---
>  backend/src/backend/program.cpp | 21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
> 
> diff --git a/backend/src/backend/program.cpp 
> b/backend/src/backend/program.cpp index 6d539a9..1b3fc82 100644
> --- a/backend/src/backend/program.cpp
> +++ b/backend/src/backend/program.cpp
> @@ -894,6 +894,27 @@ namespace gbe {
>          err += *errSize;
>        }
Both clBuildProgram() and clCompileProgram() will call into buildModuleFromSource() So, what about putting the dumpLLVM logic into buildModuleFromSource()? so that you don't need to copy the code.
And Yejun has a fix for llvm 3.3, please also base on his change.

Thanks!
Ruiling
> +     // Dump the LLVM if requested.
> +      #if (LLVM_VERSION_MAJOR == 3) && (LLVM_VERSION_MINOR < 6)
> +      if (!dumpLLVMFileName.empty()) {
> +        std::string err;
> +        llvm::raw_fd_ostream ostream (dumpLLVMFileName.c_str(),
> +                                      err, llvm::sys::fs::F_RW);
> +        if (err.empty()) {
> +          out_module->print(ostream, 0);
> +        } //Otherwise, you'll have to make do without the dump.
> +      }
> +      #else
> +      if (!dumpLLVMFileName.empty()) {
> +        std::error_code err;
> +        llvm::raw_fd_ostream ostream (dumpLLVMFileName.c_str(),
> +                                      err, llvm::sys::fs::F_RW);
> +        if (!err) {
> +          out_module->print(ostream, 0);
> +        } //Otherwise, you'll have to make do without the dump.
> +      }
> +      #endif
> +
>        p = gbe_program_new_gen_program(deviceID, out_module, NULL);
> 
>        if (OCL_OUTPUT_BUILD_LOG && options)
> --
> 1.9.1



More information about the Beignet mailing list