<html><head><style type='text/css'>p { margin: 0; }</style></head><body><div style='font-family: arial,helvetica,sans-serif; font-size: 10pt; color: #000000'><br><hr id="zwchr"><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px; color: rgb(0, 0, 0); font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;"><b>From: </b>"Adam Nemet" <anemet@apple.com><br><b>To: </b>"Hal Finkel" <hfinkel@anl.gov><br><b>Cc: </b>"llvm-dev (llvm-dev@lists.llvm.org)" <llvm-dev@lists.llvm.org>, "John McCall" <rjmccall@apple.com><br><b>Sent: </b>Wednesday, May 11, 2016 12:45:32 PM<br><b>Subject: </b>Re: Filter optimization remarks by the hotness of the code region<br><br>
<br class=""><div><blockquote class=""><div class="">On May 11, 2016, at 3:37 AM, Hal Finkel <<a href="mailto:hfinkel@anl.gov" class="" target="_blank">hfinkel@anl.gov</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; float: none; display: inline ! important;" class=""><hr id="zwchr"></span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class=""><blockquote style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class="">From: "Adam Nemet" <<a href="mailto:anemet@apple.com" class="" target="_blank">anemet@apple.com</a>><br class="">To: "Hal Finkel" <<a href="mailto:hfinkel@anl.gov" class="" target="_blank">hfinkel@anl.gov</a>><br class="">Cc: "llvm-dev (<a href="mailto:llvm-dev@lists.llvm.org" class="" target="_blank">llvm-dev@lists.llvm.org</a>)" <<a href="mailto:llvm-dev@lists.llvm.org" class="" target="_blank">llvm-dev@lists.llvm.org</a>><br class="">Sent: Wednesday, May 11, 2016 1:15:42 AM<br class="">Subject: Re: Filter optimization remarks by the hotness of the code region<br class=""><br class="">Hi Hal,<br class=""><br class=""><blockquote class="">On May 10, 2016, at 5:39 PM, Hal Finkel <<a href="mailto:hfinkel@anl.gov" class="" target="_blank">hfinkel@anl.gov</a>> wrote:<br class=""><br class="">Hi Adam,<br class=""><br class="">I think would be a really useful feature to have. I don't think<br class="">that the backend should be responsible for filtering, but should<br class="">pass the relative hotness information to the frontend. Given that<br class="">these diagnostics are not just going to be used for -Rpass and<br class="">friends, but also for generating reports by other tools (see the<br class="">discussion around D19678, for example), I think it is important to<br class="">allow the frontend to filter.<br class=""></blockquote><br class="">I am not sure I follow, can you please elaborate. Are you saying<br class="">that for example in the listing use case we don’t want the filtered<br class="">diagnostics? In other words it should be up to the remark handler<br class="">to decide whether it wants filtered or unfiltered remarks?<br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; float: none; display: inline ! important;" class="">We might or might not want them. The user might want to select different ratios and filters.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class=""><blockquote style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class=""><blockquote class="">The frontend, or other tool, might also want to collect information<br class="">from different compilation jobs to provide the user with an<br class="">overall ranking.<br class=""></blockquote><br class="">Strictly speaking about PGO, the different compilation jobs get the<br class="">same PGO with the aggregated profile, thus the hotness calculated<br class="">should be global. I am not sure why an extra aggregation step is<br class="">necessary.<br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; float: none; display: inline ! important;" class="">I agree. However, I think that the frontend might employ a combination of factors in deciding what information to present. We might, for example, have pick different hotness thresholds for different kinds of remarks.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; float: none; display: inline ! important;" class="">Especially since we're likely going with a design for the optimization reports where the frontend just creates some YAML files with the diagnostic information, and then a separate tool processes the files to produce reports, I think that we should give those tools the maximum about of practical flexibility. Such a tool might provide the user with non-trivial filtering options.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class=""></div></blockquote><div><br class=""></div><div>I think this all makes sense. So I guess the steps are:</div><div><br class=""></div><div>1. YAML support for the existing remarks</div><div>2. Add optional relative hotness to the opt-remark API</div><div>3. Exposed relative hotness in the YAML output</div><div><br class=""></div><div id="DWT15919">Are you working on 1 or should I get started?</div></div></blockquote>This is on my TODO list, but I've not started yet. Next few days seem unlikely too.<br><br>One thing we should now thing about is where this YAML encoding happens. It could be in the backend, or it could be in the remark handler in the frontend. If they'll be no real programmatic interaction in the frontend with the remark content (other than serializing it into YAML), it might make sense to make the YAML-serialization capability a property of the remark itself handled by its implementation in the backend.<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px; color: rgb(0, 0, 0); font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;"><div><div></div><div><br class=""></div><div id="DWT15918">There was another issue that came up while discussing this with John McCall. We could have a pretty large number of such remarks. I imagine that if the post-processing is performed by the external tool, it may be useful to effectively enable all optimization remarks (i.e. -Rpass/-Rpass-missed/-Rpass-analysis=loop-vectorize/inline/etc.). For large programs this may not be feasible and we may need to locally filter the remarks in LLVM. This however seems like a somewhat orthogonal issue that we could probably postpone for now.</div></div></blockquote>I've also thought about this, and this is certainly something we'll need to keep an eye on. It is specifically why I thought at first that we'd prefer to put the report-generation functionality into Clang. I'm happy, however, to postpone this unless and until it proves to be a problem. There's certainly a benefit to separating the functionality like this.<br><br>Thanks again,<br>Hal<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px; color: rgb(0, 0, 0); font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;"><div><div></div><div><br class=""></div><div>Thanks for your input!</div><div>Adam</div><br class=""><blockquote class=""><div class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; float: none; display: inline ! important;" class="">Thanks again,</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; float: none; display: inline ! important;" class="">Hal</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class=""><blockquote style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class=""><br class=""><blockquote class="">The default diagnostic, furthermore, does not provide enough<br class="">information to identify a code "region". I think that the pass<br class="">generating the diagnostic needs to provide the information,<br class="">however, we could certainly create some utility functions that<br class="">take a pointer to the BFI analysis and a Value* that can do the<br class="">right thing in most simple cases.<br class=""></blockquote><br class="">Good point.<br class=""><br class="">Thanks for your feedback.<br class=""><br class="">Adam<br class=""><br class=""><blockquote class=""><br class="">Thanks again,<br class="">Hal<br class=""><br class="">----- Original Message -----<br class=""><blockquote class="">From: "Adam Nemet" <<a href="mailto:anemet@apple.com" class="" target="_blank">anemet@apple.com</a>><br class="">To: "llvm-dev (<a href="mailto:llvm-dev@lists.llvm.org" class="" target="_blank">llvm-dev@lists.llvm.org</a>)" <<a href="mailto:llvm-dev@lists.llvm.org" class="" target="_blank">llvm-dev@lists.llvm.org</a>><br class="">Cc: "Hal Finkel" <<a href="mailto:hfinkel@anl.gov" class="" target="_blank">hfinkel@anl.gov</a>><br class="">Sent: Wednesday, May 4, 2016 1:12:17 PM<br class="">Subject: Filter optimization remarks by the hotness of the code<br class="">region<br class=""><br class="">This idea came up a few times recently [1][2] so I’d like start<br class="">prototyping it. To summarize, we can emit optimization remarks<br class="">using the -Rpass* options. These are currently emitted by<br class="">optimizations like vectorization[3], unrolling, inlining and since<br class="">last week loop distribution.<br class=""><br class="">For large programs however this can amount to a lot of diagnostics<br class="">output to sift through. Filtering this by the hotness of the<br class="">region<br class="">can help to focus the user on performance opportunities that are<br class="">likely to pay off.<br class=""><br class="">The approach I am thinking of taking is to install a wrapper as<br class="">the<br class="">diagnostics handler that will only forward to the original handler<br class="">if the region of code is considered hot. This will be installed<br class="">by<br class="">a new pass that will use BlockFrequencyInfo to determine the top N<br class="">hot regions.<br class=""><br class="">This is at very early stage right now. I would appreciate any<br class="">feedback.<br class=""><br class="">Thanks,<br class="">Adam<br class=""><br class="">[1]<br class=""><a href="http://lists.llvm.org/pipermail/llvm-dev/2016-April/098492.html" class="" target="_blank">http://lists.llvm.org/pipermail/llvm-dev/2016-April/098492.html</a><br class="">[2] http://lists.llvm.org/pipermail/cfe-dev/2016-April/048526.html<br class="">[3]<br class="">http://blog.llvm.org/2014/11/loop-vectorization-diagnostics-and.html<br class=""></blockquote><br class="">--<br class="">Hal Finkel<br class="">Assistant Computational Scientist<br class="">Leadership Computing Facility<br class="">Argonne National Laboratory<br class=""></blockquote><br class=""><br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; float: none; display: inline ! important;" class="">--<span class="Apple-converted-space"> </span></span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; float: none; display: inline ! important;" class="">Hal Finkel</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; float: none; display: inline ! important;" class="">Assistant Computational Scientist</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; float: none; display: inline ! important;" class="">Leadership Computing Facility</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; float: none; display: inline ! important;" class="">Argonne National Laboratory</span></div></blockquote></div><br class=""></blockquote><br><br><br>-- <br><div><span name="x"></span>Hal Finkel<br>Assistant Computational Scientist<br>Leadership Computing Facility<br>Argonne National Laboratory<span name="x"></span><br></div></div></body></html>