<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>"Tim Shen" <timshen@google.com><br><b>To: </b>"Hal Finkel" <hfinkel@anl.gov><br><b>Cc: </b>resistor@mac.com, "Fiona Glaser" <escha@apple.com>, "Stephen Canon" <scanon@apple.com>, "Eric Christopher" <echristo@gmail.com>, llvm-dev@lists.llvm.org<br><b>Sent: </b>Monday, October 3, 2016 1:27:12 PM<br><b>Subject: </b>Re: [PPC, APFloat] Add full PPCDoubleDouble to APFloat<br><br><div dir="ltr"><div class="gmail_quote"><div>Hi Hal,</div><div dir="ltr"><br></div><div dir="ltr">On Sun, Oct 2, 2016 at 7:43 PM Hal Finkel <<a href="mailto:hfinkel@anl.gov" target="_blank">hfinkel@anl.gov</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Hi Tim,<br class="gmail_msg">
<br class="gmail_msg">
How, in general, are you thinking about doing this? I ask because, as you clearly know, the double-double format is formed by the sum of two double-precision numbers, and the various arithmetic operations are formed mostly in terms of double-precision arithmetic on the elements of the pairs. As a result, I suspect we really just want to store the two double-precision numbers, and essentially delegate to APFloat IEEEdouble in the implementation of the various operations.<br class="gmail_msg">
<br class="gmail_msg">
As such, one option might be that, when PPCDoubleDouble fltSemantics are selected, the exponent and sign are ignored, and we just store the data for the two double-precision floating-point numbers in the significand. We might even do this directly, by making the significand something like this:<br class="gmail_msg">
<br class="gmail_msg">
union Significand {<br class="gmail_msg">
integerPart part;<br class="gmail_msg">
integerPart *parts;<br class="gmail_msg">
APFloat *fltparts; // used for PPCDoubleDouble<br class="gmail_msg">
} significand;<br class="gmail_msg"></blockquote><div><br></div><div id="DWT8421">We can do this, but my concern is "what's next?". What do we do to significandParts()? It doesn't make sense to return an array of integerParts for PPCDoubleDouble. Do we examine every call site of significandParts(), and assert/dispatch on fltSemantics?</div></div></div></blockquote>Indeed, this is why I was asking if you had an idea of how you were going to implement the arithmetic operations. It would be somewhat unfortunate if all of the functions essentially had the form of:<br><br>add(APFoat &RHS) {<br> if (semantic == PPCDoubleDouble)<br> return addPPCDoubleDouble(RHS);<br><br> ...<br>}<br><br>but it might be the best option nonetheless (I can't think of anything better).<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 dir="ltr"><div class="gmail_quote"><div> Do we want to build an abstraction between APFloat and the underlying data representation? For example:</div><div><br></div><div>class APFloatPayload {</div><div> union Significand { integerPart part; integerPart *parts; } significand;</div><div> int exponent;</div><div><br></div><div>public:<br></div><div> // *Significand() operations.</div><div>};</div><div><br></div><div>class APFloat {</div><div> fltSemantics *semantics;<br></div><div><div> fltCategory category;</div></div><div> APFloatPayload first;</div><div> Optional<APFloatPayload> second; // for PPCDoubleDouble</div><div id="DWT8422">};</div></div></div></blockquote>There might be some tradeoff here between performance and maintainability. APFloat already isn't *fast*, so I'm not super worried about introducing some extra checks inside the functions, but I'm more worried about increasing the size of the APFloat object itself, because we might have *a lot* of these in memory at once. As a result, I'd prefer a solution that did not increase the size of the base APFloat object (because then everyone pays a price for this and most people won't use it).<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 dir="ltr"><div class="gmail_quote"><div></div><div> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<br class="gmail_msg">
Thanks again,<br class="gmail_msg">
Hal<br class="gmail_msg">
<br class="gmail_msg">
<hr id="zwchr"><br class="gmail_msg">
> From: "Tim Shen" <<a href="mailto:timshen@google.com" class="gmail_msg" target="_blank">timshen@google.com</a>><br class="gmail_msg">
> To: <a href="mailto:llvm-dev@lists.llvm.org" class="gmail_msg" target="_blank">llvm-dev@lists.llvm.org</a><br class="gmail_msg">
> Cc: <a href="mailto:resistor@mac.com" class="gmail_msg" target="_blank">resistor@mac.com</a>, "Hal Finkel" <<a href="mailto:hfinkel@anl.gov" class="gmail_msg" target="_blank">hfinkel@anl.gov</a>>, "Fiona Glaser" <<a href="mailto:escha@apple.com" class="gmail_msg" target="_blank">escha@apple.com</a>>, "Stephen Canon"<br class="gmail_msg">
> <<a href="mailto:scanon@apple.com" class="gmail_msg" target="_blank">scanon@apple.com</a>>, "Eric Christopher" <<a href="mailto:echristo@gmail.com" class="gmail_msg" target="_blank">echristo@gmail.com</a>><br class="gmail_msg">
> Sent: Friday, September 30, 2016 4:43:12 PM<br class="gmail_msg">
> Subject: [PPC, APFloat] Add full PPCDoubleDouble to APFloat<br class="gmail_msg">
><br class="gmail_msg">
><br class="gmail_msg">
><br class="gmail_msg">
><br class="gmail_msg">
> I have found some internal test failures due to the wrong constant<br class="gmail_msg">
> folding on ppc_fp128.<br class="gmail_msg">
><br class="gmail_msg">
><br class="gmail_msg">
> As documented in APFloat::PPCDoubleDouble, APFloat doesn't support<br class="gmail_msg">
> PowerPC double-double correctly <<br class="gmail_msg">
> <a href="https://github.com/llvm-mirror/llvm/blob/492acdd450bcdf9837494d6da029ed064f14fc33/lib/Support/APFloat.cpp#L74" rel="noreferrer" class="gmail_msg" target="_blank">https://github.com/llvm-mirror/llvm/blob/492acdd450bcdf9837494d6da029ed064f14fc33/lib/Support/APFloat.cpp#L74</a><br class="gmail_msg">
> >.<br class="gmail_msg">
><br class="gmail_msg">
><br class="gmail_msg">
> To support this, we need to add a second tuple of (sign, exponent,<br class="gmail_msg">
> significand) to APFloat. I wonder where should I start to change, so<br class="gmail_msg">
> that it's less hacky? I certainly expect refactoring to come. :)<br class="gmail_msg">
><br class="gmail_msg">
><br class="gmail_msg">
> Thanks!<br class="gmail_msg">
<br class="gmail_msg">
--<br class="gmail_msg">
Hal Finkel<br class="gmail_msg">
Lead, Compiler Technology and Programming Languages<br class="gmail_msg">
Leadership Computing Facility<br class="gmail_msg">
Argonne National Laboratory<br class="gmail_msg">
</blockquote></div></div>
</blockquote><br><br><br>-- <br><div><span name="x"></span>Hal Finkel<br>Lead, Compiler Technology and Programming Languages<br>Leadership Computing Facility<br>Argonne National Laboratory<span name="x"></span><br></div></div></body></html>