<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:宋体;
panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:"\@宋体";
panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman",serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.hoenzb
{mso-style-name:hoenzb;}
span.im
{mso-style-name:im;}
span.EmailStyle19
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.25in 1.0in 1.25in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Hi Laura,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">I see! Thanks for the info.<o:p></o:p></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.<o:p></o:p></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.<o:p></o:p></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)<o:p></o:p></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:<o:p></o:p></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<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"> std::string err;<o:p></o:p></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(),<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"> err, llvm::sys::fs::F_RW);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"> if (err.empty()) {<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"> out_module->print(ostream, 0);<o:p></o:p></span></p>
<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.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">#else<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"> std::error_code err;<o:p></o:p></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(),<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"> err, llvm::sys::fs::F_RW);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"> if (!err) {<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"> out_module->print(ostream, 0);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"> }<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">#endif<o:p></o:p></span></p>
<p class="MsoNormal"><a name="_MailEndCompose"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></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?<o:p></o:p></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.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Thanks!<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Ruiling<o:p></o:p></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:beignet-bounces@lists.freedesktop.org]
<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; beignet@lists.freedesktop.org<br>
<b>Subject:</b> Re: [Beignet] [PATCH] backend/src/backend: Handle -dump-opt-llvm=[PATH]<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></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.<o:p></o:p></p>
</div>
<p class="MsoNormal">Laura<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></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:<o:p></o:p></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 class="hoenzb"><span style="color:#888888">Ruiling</span></span><span style="color:#888888"><br>
</span><span class="im">> -----Original Message-----</span><br>
<span class="im">> From: Beignet [mailto:<a href="mailto:beignet-bounces@lists.freedesktop.org">beignet-bounces@lists.freedesktop.org</a>] On Behalf Of</span><br>
<span class="im">> Laura Ekstrand</span><br>
<span class="im">> Sent: Friday, July 10, 2015 3:04 AM</span><br>
<span class="im">> To: <a href="mailto:beignet@lists.freedesktop.org">beignet@lists.freedesktop.org</a></span><br>
<span class="im">> Cc: Ekstrand, Laura D</span><br>
<span class="im">> Subject: [Beignet] [PATCH] backend/src/backend: Handle -dump-opt-llvm=[PATH]</span><br>
<span class="im">></span><o:p></o:p></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">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">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><o:p></o:p></p>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</div>
</body>
</html>