<div dir="ltr">Hello Ruiling,<div><br></div><div>Manasi will be taking over this patch for me. Thanks for your review!</div><div><br></div><div>Laura</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jul 29, 2015 at 12:19 AM, Song, Ruiling <span dir="ltr"><<a href="mailto:ruiling.song@intel.com" target="_blank">ruiling.song@intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div lang="EN-US" link="blue" vlink="purple">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Hi Laura,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">I see! Thanks for the info.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">The patch basically looks good, but it does not work under llvm 3.6.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Llvm 3.6 change the raw_fd_ostream constructor.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">It is defined as: raw_fd_ostream( StringRef fileName, std::error_code &EC, sys::fs::OpenFlags Flags)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">So, you need to add some logic like below to handle this:<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 6<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"> std::string err;<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"> llvm::raw_fd_ostream ostream (dumpLLVMFileName.c_str(),<u></u><u></u></span></p><span class="">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"> err, llvm::sys::fs::F_RW);<u></u><u></u></span></p>
</span><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"> if (err.empty()) {<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"> out_module->print(ostream, 0);<u></u><u></u></span></p><span class="">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"> } //Otherwise, you'll have to make do without the dump.<u></u><u></u></span></p>
</span><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">#else<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"> std::error_code err;<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"> llvm::raw_fd_ostream ostream (dumpLLVMFileName.c_str(),<u></u><u></u></span></p><span class="">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"> err, llvm::sys::fs::F_RW);<u></u><u></u></span></p>
</span><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"> if (!err) {<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"> out_module->print(ostream, 0);<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"> }<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">#endif<u></u><u></u></span></p>
<p class="MsoNormal"><a name="14ed8b0975bd5ad0__MailEndCompose"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></a></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Other parts of the patch LGTM. So could you fix it and send a new version?<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">And also please include “Signed-off-by: ” in your patch.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Thanks!<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Ruiling<u></u><u></u></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #e1e1e1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> Beignet [mailto:<a href="mailto:beignet-bounces@lists.freedesktop.org" target="_blank">beignet-bounces@lists.freedesktop.org</a>]
<b>On Behalf Of </b>Laura Ekstrand<br>
<b>Sent:</b> Wednesday, July 29, 2015 5:03 AM<br>
<b>To:</b> Song, Ruiling<br>
<b>Cc:</b> Ekstrand, Laura D; <a href="mailto:beignet@lists.freedesktop.org" target="_blank">beignet@lists.freedesktop.org</a><br>
<b>Subject:</b> Re: [Beignet] [PATCH] backend/src/backend: Handle -dump-opt-llvm=[PATH]<u></u><u></u></span></p>
</div>
</div><div><div class="h5">
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">This is to enable a feature in the Intel tool OpenCL Code Builder. It is a non-standard option.<u></u><u></u></p>
</div>
<p class="MsoNormal">Laura<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">On Tue, Jul 28, 2015 at 12:30 AM, Song, Ruiling <<a href="mailto:ruiling.song@intel.com" target="_blank">ruiling.song@intel.com</a>> wrote:<u></u><u></u></p>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal">Could you explain why this is needed?<br>
And is "dump-opt-llvm" a llvm-standard option or opencl option?<br>
<br>
Thanks!<br>
<span><span style="color:#888888">Ruiling</span></span><span style="color:#888888"><br>
</span><span>> -----Original Message-----</span><br>
<span>> From: Beignet [mailto:<a href="mailto:beignet-bounces@lists.freedesktop.org" target="_blank">beignet-bounces@lists.freedesktop.org</a>] On Behalf Of</span><br>
<span>> Laura Ekstrand</span><br>
<span>> Sent: Friday, July 10, 2015 3:04 AM</span><br>
<span>> To: <a href="mailto:beignet@lists.freedesktop.org" target="_blank">beignet@lists.freedesktop.org</a></span><br>
<span>> Cc: Ekstrand, Laura D</span><br>
<span>> Subject: [Beignet] [PATCH] backend/src/backend: Handle -dump-opt-llvm=[PATH]</span><br>
<span>></span><u></u><u></u></p>
<div>
<div>
<p class="MsoNormal">> Allows the user to request a dump of the LLVM-generated IR to the file specified<br>
> in [PATH].<br>
> ---<br>
> backend/src/backend/program.cpp | 26 +++++++++++++++++++++++---<br>
> 1 file changed, 23 insertions(+), 3 deletions(-)<br>
><br>
> diff --git a/backend/src/backend/program.cpp<br>
> b/backend/src/backend/program.cpp index e4cdeaa..b55f75a 100644<br>
> --- a/backend/src/backend/program.cpp<br>
> +++ b/backend/src/backend/program.cpp<br>
> @@ -640,6 +640,7 @@ namespace gbe {<br>
> const char *options,<br>
> const char *temp_header_path,<br>
> std::vector<std::string>& clOpt,<br>
> + std::string& dumpLLVMFileName,<br>
> std::string& clName,<br>
> int& optLevel,<br>
> size_t stringSize, @@ -719,6 +720,11 @@ namespace gbe {<br>
> clOpt.push_back("__FAST_RELAXED_MATH__=1");<br>
> }<br>
><br>
> + if(str.find("-dump-opt-llvm=") != std::string::npos) {<br>
> + dumpLLVMFileName = str.substr(str.find("=") + 1);<br>
> + continue; // Don't push this str back; ignore it.<br>
> + }<br>
> +<br>
> clOpt.push_back(str);<br>
> }<br>
> free(str);<br>
> @@ -781,8 +787,10 @@ namespace gbe {<br>
> int optLevel = 1;<br>
> std::vector<std::string> clOpt;<br>
> std::string clName;<br>
> - if (!processSourceAndOption(source, options, NULL, clOpt, clName,<br>
> - optLevel, stringSize, err, errSize))<br>
> + std::string dumpLLVMFileName;<br>
> + if (!processSourceAndOption(source, options, NULL, clOpt,<br>
> + dumpLLVMFileName, clName, optLevel,<br>
> + stringSize, err, errSize))<br>
> return NULL;<br>
><br>
> gbe_program p;<br>
> @@ -804,6 +812,16 @@ namespace gbe {<br>
> clangErrSize = *errSize;<br>
> }<br>
><br>
> + // Dump the LLVM if requested.<br>
> + if (!dumpLLVMFileName.empty()) {<br>
> + std::string err;<br>
> + llvm::raw_fd_ostream ostream (dumpLLVMFileName.c_str(),<br>
> + err, llvm::sys::fs::F_RW);<br>
> + if (err.empty()) {<br>
> + out_module->print(ostream, 0);<br>
> + } //Otherwise, you'll have to make do without the dump.<br>
> + }<br>
> +<br>
> p = gbe_program_new_from_llvm(deviceID, NULL, out_module, llvm_ctx,<br>
> stringSize,<br>
> err, errSize, optLevel);<br>
> if (err != NULL)<br>
> @@ -834,7 +852,9 @@ namespace gbe {<br>
> int optLevel = 1;<br>
> std::vector<std::string> clOpt;<br>
> std::string clName;<br>
> - if (!processSourceAndOption(source, options, temp_header_path, clOpt,<br>
> clName,<br>
> + std::string dumpLLVMFileName;<br>
> + if (!processSourceAndOption(source, options, temp_header_path, clOpt,<br>
> + dumpLLVMFileName, clName,<br>
> optLevel, stringSize, err, errSize))<br>
> return NULL;<br>
><br>
> --<br>
> 2.1.0<br>
><br>
> _______________________________________________<br>
> Beignet mailing list<br>
> <a href="mailto:Beignet@lists.freedesktop.org" target="_blank">Beignet@lists.freedesktop.org</a><br>
> <a href="http://lists.freedesktop.org/mailman/listinfo/beignet" target="_blank">
http://lists.freedesktop.org/mailman/listinfo/beignet</a><br>
_______________________________________________<br>
Beignet mailing list<br>
<a href="mailto:Beignet@lists.freedesktop.org" target="_blank">Beignet@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/beignet" target="_blank">http://lists.freedesktop.org/mailman/listinfo/beignet</a><u></u><u></u></p>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div></div></div>
</div>
</div>
</blockquote></div><br></div>