<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Oct 13, 2016 at 6:22 PM, Mehdi Amini <span dir="ltr"><<a href="mailto:mehdi.amini@apple.com" target="_blank">mehdi.amini@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><span class=""><br><div><blockquote type="cite"><div>On Oct 13, 2016, at 5:25 PM, Mehdi Amini <<a href="mailto:mehdi.amini@apple.com" target="_blank">mehdi.amini@apple.com</a>> wrote:</div><br class="m_600073036105851987Apple-interchange-newline"><div><blockquote type="cite" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div><br class="m_600073036105851987Apple-interchange-newline">On Oct 13, 2016, at 5:22 PM, Teresa Johnson <<a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a>> wrote:</div><br class="m_600073036105851987Apple-interchange-newline"><div><br class="m_600073036105851987Apple-interchange-newline"><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div class="gmail_quote" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">On Thu, Oct 13, 2016 at 5:14 PM, Mehdi Amini<span class="m_600073036105851987Apple-converted-space"> </span><span dir="ltr"><<a href="mailto:mehdi.amini@apple.com" target="_blank">mehdi.amini@apple.com</a>></span><span class="m_600073036105851987Apple-converted-space"> </span><wbr>wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span><br>> On Oct 13, 2016, at 5:07 PM, Teresa Johnson <<a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a>> wrote:<br>><br>> tejohnson added inline comments.<br>><br>><br>> ================<br>> Comment at: include/llvm/Support/Threading<wbr>.h:121<br>> +  /// host system, otherwise falls back to thread::hardware_concurrency()<wbr>.<br>> +  unsigned hardware_physical_concurrency(<wbr>);<br>> }<br>> ----------------<br>> mehdi_amini wrote:<br>>> I think we may want to name it `hardware_coarse_concurrency`. Because:<br>>><br>>> - This looks like expressing better what we're looking after.<br>>> - Hyperthreading is in some sense "physical concurrency", but sharing some resources.<br>>> - Other platforms may have something in between.<br>>><br>> I thought about that name after you mentioned it on the prior review thread. But I felt that saying "physical concurrency" is a better expression for what it is actually trying to give you.  I think of the hyperthreading concurrency as "logical concurrency", vs physical concurrency due to physical cores.<br><br></span>Hyperthreading is sharing some physical resources on the core, but have some other physical resources duplicated/dedicated, which is why I feel it is murky. But “good enough” as well...<br>Also, I don’t know enough the PowerPC or Sparc equivalent of hyper-threading to know how much they share/duplicate and what we would pick on these for instance.<br></blockquote><div><br></div><div>Right it is a bit murky. One reason I didn't like "coarse" is that coarse-grained parallelism relates to how closely the tasks communicate/synchronize</div></div></div></blockquote><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">Fair.</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">In my mind “coarse” relates to the “size” of the task. But a few light and long-lived task could fit a “coarse” level of granularity.</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">I don’t have anything better to qualify these tasks (“heavy” is kind of what I’m looking for, but I can’t translate this into an API name…).</div></div></blockquote><div><br></div></div></span>Asked Duncan (he’s good at naming usually), and he suggested:<div><br></div><div><div>lightweight_hardware_<wbr>concurrency(); // maximum number of resource available for threading</div></div><div><div>heavyweight_hardware_<wbr>concurrency();  // number of dedicated hardware resource available for threading</div></div><div>hardware_concurrency(); // default to one of the other above, or in between, depending on the platform.</div></div></blockquote><div><br></div><div>I like heavyweight_hardware_concurrency. But I think it is better to keep hardware_concurrency to its current meaning, since that is in std::thread. Also, it seems like you would want to pick a type of concurrency (heavy vs light) based on knowledge about the tasks being parallelized. Eg. for ThinLTO backends we know they are memory intensive, so use heavyweight_hardware_concurrency. Depending on the platform, this could map to the number of physical cores (as I did here), or for other platforms it may be better to simply use the default hardware_concurrency. </div><div><br></div><div>It seems like lightweight_hardware_concurrency is pretty much always the same as hardware_concurrency (the std::thread implementation).</div><div><br></div><div>What if for now I renamed this to heavyweight_hardware_concurrency, and then the follow on ThinLTO patch will use that for BE parallelism. We could consider adding in additional flavors if the need ever arises.</div><div><br></div><div>Teresa</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><br></div><div><br></div><div>— </div><span class="HOEnZb"><font color="#888888"><div>Mehdi</div></font></span></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><span style="font-family:Times;font-size:medium"><table cellspacing="0" cellpadding="0"><tbody><tr style="color:rgb(85,85,85);font-family:sans-serif;font-size:small"><td nowrap style="border-top-style:solid;border-top-color:rgb(213,15,37);border-top-width:2px">Teresa Johnson |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(51,105,232);border-top-width:2px"> Software Engineer |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(0,153,57);border-top-width:2px"> <a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a> |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(238,178,17);border-top-width:2px"> 408-460-2413</td></tr></tbody></table></span></div>
</div></div>