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

Song, Ruiling ruiling.song at intel.com
Thu Aug 13 19:59:56 PDT 2015



> -----Original Message-----
> From: Navare, Manasi D
> Sent: Friday, August 14, 2015 10:54 AM
> To: Song, Ruiling; beignet at lists.freedesktop.org
> Subject: RE: [PATCH] backend/src/backend: Handle -dump-opt-llvm=[PATH] in
> clCompileProgram OpenCL API
> 
> Hi Ruiling,
> 
> But that would require sending dumpLLVMFileName as an aurgument to
> buildModuleFromSources().

buildModuleFromSource() is not an exposed API to user, so I don't think this is a big problem.
I think that would be better than duplicating code. note we need to maintain that piece of code, if in future llvm change related code, we have to modify duplicated code.

> 
> 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