<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Oct 14, 2016 at 9:35 AM, Duncan P. N. Exon Smith <span dir="ltr"><<a href="mailto:dexonsmith@apple.com" target="_blank">dexonsmith@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail-HOEnZb"><div class="gmail-h5"><br>
> On 2016-Oct-14, at 06:24, Teresa Johnson <<a href="mailto:tejohnson@google.com">tejohnson@google.com</a>> wrote:<br>
><br>
><br>
><br>
> On Thu, Oct 13, 2016 at 6:22 PM, Mehdi Amini <<a href="mailto:mehdi.amini@apple.com">mehdi.amini@apple.com</a>> wrote:<br>
><br>
>> On Oct 13, 2016, at 5:25 PM, Mehdi Amini <<a href="mailto:mehdi.amini@apple.com">mehdi.amini@apple.com</a>> wrote:<br>
>><br>
>>><br>
>>> On Oct 13, 2016, at 5:22 PM, Teresa Johnson <<a href="mailto:tejohnson@google.com">tejohnson@google.com</a>> wrote:<br>
>>><br>
>>><br>
>>><br>
>>> On Thu, Oct 13, 2016 at 5:14 PM, Mehdi Amini <<a href="mailto:mehdi.amini@apple.com">mehdi.amini@apple.com</a>> wrote:<br>
>>><br>
>>> > On Oct 13, 2016, at 5:07 PM, Teresa Johnson <<a href="mailto:tejohnson@google.com">tejohnson@google.com</a>> wrote:<br>
>>> ><br>
>>> > tejohnson added inline comments.<br>
>>> ><br>
>>> ><br>
>>> > ================<br>
>>> > Comment at: include/llvm/Support/<wbr>Threading.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>
>>> 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>
>>><br>
>>> 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<br>
>><br>
>> Fair.<br>
>> 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.<br>
>><br>
>> 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…).<br>
><br>
> Asked Duncan (he’s good at naming usually), and he suggested:<br>
><br>
> lightweight_hardware_<wbr>concurrency(); // maximum number of resource available for threading<br>
> heavyweight_hardware_<wbr>concurrency();  // number of dedicated hardware resource available for threading<br>
> hardware_concurrency(); // default to one of the other above, or in between, depending on the platform.<br>
><br>
> I like heavyweight_hardware_<wbr>concurrency. But I think it is better to keep hardware_concurrency to its current meaning, since that is in std::thread.<br>
<br>
</div></div>Agreed.  It should match std::thread::hardware_<wbr>concurrency when available.<br>
<span class="gmail-"><br>
> 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_<wbr>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.<br>
><br>
> It seems like lightweight_hardware_<wbr>concurrency is pretty much always the same as hardware_concurrency (the std::thread implementation).<br>
<br>
</span>Not guaranteed to be the same though.  std::thread::hardware_<wbr>concurrency() is an implementation-dependent hint, and doesn't necessarily even match either of the two others.<br>
<br>
(I don't have a strong opinion on what you should do, besides having hardware_concurrency match std::thread.)<br>
<div class="gmail-HOEnZb"><div class="gmail-h5"><br>
> What if for now I renamed this to heavyweight_hardware_<wbr>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.<br></div></div></blockquote><div><br></div><div>Committed rename of hardware_physical_concurrency to heavyweight_hardware_concurrency in r284390. Will leave lightweight_hardware_concurrency to when there is a need for it, since I don't have a clear idea of what it should do other than map it directly to std::thread::hardware_concurrency.</div><div><br></div><div>Teresa</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail-HOEnZb"><div class="gmail-h5">
><br>
> Teresa<br>
><br>
><br>
><br>
> —<br>
> Mehdi<br>
><br>
><br>
><br>
> --<br>
> Teresa Johnson |       Software Engineer |     <a href="mailto:tejohnson@google.com">tejohnson@google.com</a> |  <a href="tel:408-460-2413" value="+14084602413">408-460-2413</a><br>
<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="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:2px solid rgb(213,15,37)">Teresa Johnson |</td><td nowrap style="border-top:2px solid rgb(51,105,232)"> Software Engineer |</td><td nowrap style="border-top:2px solid rgb(0,153,57)"> <a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a> |</td><td nowrap style="border-top:2px solid rgb(238,178,17)"> 408-460-2413</td></tr></tbody></table></span></div>
</div></div>