<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jun 1, 2015 at 12:16 PM, Tom Stellard <span dir="ltr"><<a href="mailto:tom@stellard.net" target="_blank">tom@stellard.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Thu, May 21, 2015 at 09:20:18AM -0400, Jan Vesely wrote:<br>
> On Wed, 2015-05-13 at 03:34 +0000, Tom Stellard wrote:<br>
> > ---<br>
> >  amdgcn/lib/SOURCES      |  1 +<br>
> >  amdgcn/lib/math/<a href="http://sqrt.cl" target="_blank">sqrt.cl</a> | 59 +++++++++++++++++++++++++++++++++++++++++++++++++<br>
><br>
> I see you created new folder for amdgcn, is the implementation expected<br>
> to be different for fp64 enabled EG and NI asics?<br>
><br>
<br>
</span>No, I can move it into the r600 directory.<br></blockquote><div><br></div><div>with that change LGTM<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class="HOEnZb"><font color="#888888"><br>
-Tom<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
> >  2 files changed, 60 insertions(+)<br>
> >  create mode 100644 amdgcn/lib/SOURCES<br>
> >  create mode 100644 amdgcn/lib/math/<a href="http://sqrt.cl" target="_blank">sqrt.cl</a><br>
> ><br>
> > diff --git a/amdgcn/lib/SOURCES b/amdgcn/lib/SOURCES<br>
> > new file mode 100644<br>
> > index 0000000..64f874c<br>
> > --- /dev/null<br>
> > +++ b/amdgcn/lib/SOURCES<br>
> > @@ -0,0 +1 @@<br>
> > +math/<a href="http://sqrt.cl" target="_blank">sqrt.cl</a><br>
> > diff --git a/amdgcn/lib/math/<a href="http://sqrt.cl" target="_blank">sqrt.cl</a> b/amdgcn/lib/math/<a href="http://sqrt.cl" target="_blank">sqrt.cl</a><br>
> > new file mode 100644<br>
> > index 0000000..3e5b17c<br>
> > --- /dev/null<br>
> > +++ b/amdgcn/lib/math/<a href="http://sqrt.cl" target="_blank">sqrt.cl</a><br>
> > @@ -0,0 +1,59 @@<br>
> > +/*<br>
> > + * Copyright (c) 2015 Advanced Micro Devices, Inc.<br>
> > + *<br>
> > + * Permission is hereby granted, free of charge, to any person obtaining a copy<br>
> > + * of this software and associated documentation files (the "Software"), to deal<br>
> > + * in the Software without restriction, including without limitation the rights<br>
> > + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell<br>
> > + * copies of the Software, and to permit persons to whom the Software is<br>
> > + * furnished to do so, subject to the following conditions:<br>
> > + *<br>
> > + * The above copyright notice and this permission notice shall be included in<br>
> > + * all copies or substantial portions of the Software.<br>
> > + *<br>
> > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
> > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
> > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE<br>
> > + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br>
> > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,<br>
> > + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN<br>
> > + * THE SOFTWARE.<br>
> > + */<br>
> > +<br>
> > +#include <clc/clc.h><br>
> > +#include "../../../generic/lib/clcmacro.h"<br>
> > +#include "math/clc_sqrt.h"<br>
> > +<br>
> > +_CLC_DEFINE_UNARY_BUILTIN(float, sqrt, __clc_sqrt, float)<br>
> > +<br>
> > +#ifdef cl_khr_fp64<br>
> > +<br>
> > +#pragma OPENCL EXTENSION cl_khr_fp64 : enable<br>
> > +<br>
> > +<br>
> > +_CLC_OVERLOAD _CLC_DEF double sqrt(double x) {<br>
> > +<br>
> > +  uint vcc = x < 0x1p-767;<br>
> > +  uint exp0 = vcc ? 0x100 : 0;<br>
> > +  unsigned exp1 = vcc ? 0xffffff80 : 0;<br>
> > +<br>
> > +  double v01 = ldexp(x, exp0);<br>
> > +  double v23 = __builtin_amdgpu_rsq(v01);<br>
> > +  double v45 = v01 * v23;<br>
> > +  v23 = v23 * 0.5;<br>
> > +<br>
> > +  double v67 = fma(-v23, v45, 0.5);<br>
> > +  v45 = fma(v45, v67, v45);<br>
> > +  double v89 = fma(-v45, v45, v01);<br>
> > +  v23 = fma(v23, v67, v23);<br>
> > +  v45 = fma(v89, v23, v45);<br>
> > +  v67 = fma(-v45, v45, v01);<br>
> > +  v23 = fma(v67, v23, v45);<br>
> > +<br>
> > +  v23 = ldexp(v23, exp1);<br>
> > +  return ((x == __builtin_inf()) || (x == 0.0)) ? v01 : v23;<br>
> > +}<br>
> > +<br>
> > +_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, double, sqrt, double);<br>
> > +<br>
> > +#endif<br>
><br>
> --<br>
> Jan Vesely <<a href="mailto:jan.vesely@rutgers.edu">jan.vesely@rutgers.edu</a>><br>
<br>
<br>
<br>
</div></div><div class="HOEnZb"><div class="h5">> _______________________________________________<br>
> Libclc-dev mailing list<br>
> <a href="mailto:Libclc-dev@pcc.me.uk">Libclc-dev@pcc.me.uk</a><br>
> <a href="http://www.pcc.me.uk/cgi-bin/mailman/listinfo/libclc-dev" target="_blank">http://www.pcc.me.uk/cgi-bin/mailman/listinfo/libclc-dev</a><br>
<br>
</div></div></blockquote></div><br></div></div>