<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Mar 2, 2015 at 9:05 AM, 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"><div class="HOEnZb"><div class="h5">On Thu, Feb 26, 2015 at 11:48:41AM -0600, Aaron Watry wrote:<br>
> On Thu, Feb 26, 2015 at 10:59 AM, Tom Stellard <<a href="mailto:tom@stellard.net">tom@stellard.net</a>> wrote:<br>
><br>
> > On Thu, Feb 26, 2015 at 10:16:48AM -0600, Aaron Watry wrote:<br>
> > > On Wed, Feb 25, 2015 at 3:20 PM, Tom Stellard <<a href="mailto:thomas.stellard@amd.com">thomas.stellard@amd.com</a>><br>
> > > wrote:<br>
> > ><br>
> > > > ---<br>
> > > >  generic/include/clc/clc.h           |  1 +<br>
> > > >  generic/include/clc/common/step.h   | 25 +++++++++++++++++<br>
> > > >  generic/include/clc/common/step.inc | 28 +++++++++++++++++++<br>
> > > >  generic/lib/SOURCES                 |  1 +<br>
> > > >  generic/lib/clcmacro.h              | 23 ++++++++++++++++<br>
> > > >  generic/lib/common/<a href="http://step.cl" target="_blank">step.cl</a>          | 54<br>
> > > > +++++++++++++++++++++++++++++++++++++<br>
> > > >  6 files changed, 132 insertions(+)<br>
> > > >  create mode 100644 generic/include/clc/common/step.h<br>
> > > >  create mode 100644 generic/include/clc/common/step.inc<br>
> > > >  create mode 100644 generic/lib/common/<a href="http://step.cl" target="_blank">step.cl</a><br>
> > > ><br>
> > > > diff --git a/generic/include/clc/clc.h b/generic/include/clc/clc.h<br>
> > > > index e1f888b..cee1614 100644<br>
> > > > --- a/generic/include/clc/clc.h<br>
> > > > +++ b/generic/include/clc/clc.h<br>
> > > > @@ -110,6 +110,7 @@<br>
> > > >  #include <clc/common/radians.h><br>
> > > >  #include <clc/common/sign.h><br>
> > > >  #include <clc/common/smoothstep.h><br>
> > > > +#include <clc/common/step.h><br>
> > > ><br>
> > > >  /* 6.11.5 Geometric Functions */<br>
> > > >  #include <clc/geometric/cross.h><br>
> > > > diff --git a/generic/include/clc/common/step.h<br>
> > > > b/generic/include/clc/common/step.h<br>
> > > > new file mode 100644<br>
> > > > index 0000000..9c0bee4<br>
> > > > --- /dev/null<br>
> > > > +++ b/generic/include/clc/common/step.h<br>
> > > > @@ -0,0 +1,25 @@<br>
> > > > +/*<br>
> > > > + * Copyright (c) 2014,2015 Advanced Micro Devices, Inc.<br>
> > > > + *<br>
> > > > + * Permission is hereby granted, free of charge, to any person<br>
> > obtaining<br>
> > > > a copy<br>
> > > > + * of this software and associated documentation files (the<br>
> > "Software"),<br>
> > > > to deal<br>
> > > > + * in the Software without restriction, including without limitation<br>
> > the<br>
> > > > rights<br>
> > > > + * to use, copy, modify, merge, publish, distribute, sublicense,<br>
> > and/or<br>
> > > > sell<br>
> > > > + * copies of the Software, and to permit persons to whom the Software<br>
> > is<br>
> > > > + * furnished to do so, subject to the following conditions:<br>
> > > > + *<br>
> > > > + * The above copyright notice and this permission notice shall be<br>
> > > > included in<br>
> > > > + * all copies or substantial portions of the Software.<br>
> > > > + *<br>
> > > > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,<br>
> > > > EXPRESS OR<br>
> > > > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF<br>
> > > > MERCHANTABILITY,<br>
> > > > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT<br>
> > > > SHALL THE<br>
> > > > + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR<br>
> > OTHER<br>
> > > > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,<br>
> > > > ARISING FROM,<br>
> > > > + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER<br>
> > DEALINGS<br>
> > > > IN<br>
> > > > + * THE SOFTWARE.<br>
> > > > + */<br>
> > > > +<br>
> > > > +#define __CLC_BODY <clc/common/step.inc><br>
> > > > +#include <clc/math/gentype.inc><br>
> > > > +#undef __CLC_BODY<br>
> > > > diff --git a/generic/include/clc/common/step.inc<br>
> > > > b/generic/include/clc/common/step.inc<br>
> > > > new file mode 100644<br>
> > > > index 0000000..f606b7c<br>
> > > > --- /dev/null<br>
> > > > +++ b/generic/include/clc/common/step.inc<br>
> > > > @@ -0,0 +1,28 @@<br>
> > > > +/*<br>
> > > > + * Copyright (c) 2014,2015 Advanced Micro Devices, Inc.<br>
> > > > + *<br>
> > > > + * Permission is hereby granted, free of charge, to any person<br>
> > obtaining<br>
> > > > a copy<br>
> > > > + * of this software and associated documentation files (the<br>
> > "Software"),<br>
> > > > to deal<br>
> > > > + * in the Software without restriction, including without limitation<br>
> > the<br>
> > > > rights<br>
> > > > + * to use, copy, modify, merge, publish, distribute, sublicense,<br>
> > and/or<br>
> > > > sell<br>
> > > > + * copies of the Software, and to permit persons to whom the Software<br>
> > is<br>
> > > > + * furnished to do so, subject to the following conditions:<br>
> > > > + *<br>
> > > > + * The above copyright notice and this permission notice shall be<br>
> > > > included in<br>
> > > > + * all copies or substantial portions of the Software.<br>
> > > > + *<br>
> > > > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,<br>
> > > > EXPRESS OR<br>
> > > > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF<br>
> > > > MERCHANTABILITY,<br>
> > > > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT<br>
> > > > SHALL THE<br>
> > > > + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR<br>
> > OTHER<br>
> > > > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,<br>
> > > > ARISING FROM,<br>
> > > > + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER<br>
> > DEALINGS<br>
> > > > IN<br>
> > > > + * THE SOFTWARE.<br>
> > > > + */<br>
> > > > +<br>
> > > > +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE step(__CLC_GENTYPE edge,<br>
> > > > __CLC_GENTYPE x);<br>
> > > > +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE step(float edge, __CLC_GENTYPE<br>
> > x);<br>
> > > > +<br>
> > > > +#ifdef cl_khr_fp64<br>
> > > > +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE step(double edge, __CLC_GENTYPE<br>
> > x);<br>
> > > > +#endif<br>
> > > > diff --git a/generic/lib/SOURCES b/generic/lib/SOURCES<br>
> > > > index aaedada..a7b2fa2 100644<br>
> > > > --- a/generic/lib/SOURCES<br>
> > > > +++ b/generic/lib/SOURCES<br>
> > > > @@ -31,6 +31,7 @@ common/<a href="http://degrees.cl" target="_blank">degrees.cl</a><br>
> > > >  common/<a href="http://radians.cl" target="_blank">radians.cl</a><br>
> > > >  common/<a href="http://sign.cl" target="_blank">sign.cl</a><br>
> > > >  common/<a href="http://smoothstep.cl" target="_blank">smoothstep.cl</a><br>
> > > > +common/<a href="http://step.cl" target="_blank">step.cl</a><br>
> > > >  geometric/<a href="http://cross.cl" target="_blank">cross.cl</a><br>
> > > >  geometric/<a href="http://dot.cl" target="_blank">dot.cl</a><br>
> > > >  geometric/<a href="http://length.cl" target="_blank">length.cl</a><br>
> > > > diff --git a/generic/lib/clcmacro.h b/generic/lib/clcmacro.h<br>
> > > > index 39636c9..346adf2 100644<br>
> > > > --- a/generic/lib/clcmacro.h<br>
> > > > +++ b/generic/lib/clcmacro.h<br>
> > > > @@ -41,6 +41,29 @@<br>
> > > >      return (RET_TYPE##16)(FUNCTION(x.lo, y.lo), FUNCTION(x.hi,<br>
> > y.hi)); \<br>
> > > >    }<br>
> > > ><br>
> > > > +#define _CLC_V_S_V_VECTORIZE(DECLSPEC, RET_TYPE, FUNCTION, ARG1_TYPE,<br>
> > > > ARG2_TYPE) \<br>
> > > > +  DECLSPEC RET_TYPE##2 FUNCTION(ARG1_TYPE x, ARG2_TYPE##2 y) { \<br>
> > > > +    return (RET_TYPE##2)(FUNCTION(x, y.lo), FUNCTION(x, y.hi)); \<br>
> > > > +  } \<br>
> > > > +\<br>
> > > > +  DECLSPEC RET_TYPE##3 FUNCTION(ARG1_TYPE x, ARG2_TYPE##3 y) { \<br>
> > > > +    return (RET_TYPE##3)(FUNCTION(x, y.x), FUNCTION(x, y.y), \<br>
> > > > +                         FUNCTION(x, y.z)); \<br>
> > > > +  } \<br>
> > > > +\<br>
> > > > +  DECLSPEC RET_TYPE##4 FUNCTION(ARG1_TYPE x, ARG2_TYPE##4 y) { \<br>
> > > > +    return (RET_TYPE##4)(FUNCTION(x, y.lo), FUNCTION(x, y.hi)); \<br>
> > > > +  } \<br>
> > > > +\<br>
> > > > +  DECLSPEC RET_TYPE##8 FUNCTION(ARG1_TYPE x, ARG2_TYPE##8 y) { \<br>
> > > > +    return (RET_TYPE##8)(FUNCTION(x, y.lo), FUNCTION(x, y.hi)); \<br>
> > > > +  } \<br>
> > > > +\<br>
> > > > +  DECLSPEC RET_TYPE##16 FUNCTION(ARG1_TYPE x, ARG2_TYPE##16 y) { \<br>
> > > > +    return (RET_TYPE##16)(FUNCTION(x, y.lo), FUNCTION(x, y.hi)); \<br>
> > > > +  } \<br>
> > > > +\<br>
> > > > +<br>
> > > >  #define _CLC_TERNARY_VECTORIZE(DECLSPEC, RET_TYPE, FUNCTION,<br>
> > ARG1_TYPE,<br>
> > > > ARG2_TYPE, ARG3_TYPE) \<br>
> > > >    DECLSPEC RET_TYPE##2 FUNCTION(ARG1_TYPE##2 x, ARG2_TYPE##2 y,<br>
> > > > ARG3_TYPE##2 z) { \<br>
> > > >      return (RET_TYPE##2)(FUNCTION(x.x, y.x, z.x), FUNCTION(x.y, y.y,<br>
> > > > z.y)); \<br>
> > > > diff --git a/generic/lib/common/<a href="http://step.cl" target="_blank">step.cl</a> b/generic/lib/common/<a href="http://step.cl" target="_blank">step.cl</a><br>
> > > > new file mode 100644<br>
> > > > index 0000000..4b022f1<br>
> > > > --- /dev/null<br>
> > > > +++ b/generic/lib/common/<a href="http://step.cl" target="_blank">step.cl</a><br>
> > > > @@ -0,0 +1,54 @@<br>
> > > > +/*<br>
> > > > + * Copyright (c) 2014,2015 Advanced Micro Devices, Inc.<br>
> > > > + *<br>
> > > > + * Permission is hereby granted, free of charge, to any person<br>
> > obtaining<br>
> > > > a copy<br>
> > > > + * of this software and associated documentation files (the<br>
> > "Software"),<br>
> > > > to deal<br>
> > > > + * in the Software without restriction, including without limitation<br>
> > the<br>
> > > > rights<br>
> > > > + * to use, copy, modify, merge, publish, distribute, sublicense,<br>
> > and/or<br>
> > > > sell<br>
> > > > + * copies of the Software, and to permit persons to whom the Software<br>
> > is<br>
> > > > + * furnished to do so, subject to the following conditions:<br>
> > > > + *<br>
> > > > + * The above copyright notice and this permission notice shall be<br>
> > > > included in<br>
> > > > + * all copies or substantial portions of the Software.<br>
> > > > + *<br>
> > > > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,<br>
> > > > EXPRESS OR<br>
> > > > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF<br>
> > > > MERCHANTABILITY,<br>
> > > > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT<br>
> > > > SHALL THE<br>
> > > > + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR<br>
> > OTHER<br>
> > > > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,<br>
> > > > ARISING FROM,<br>
> > > > + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER<br>
> > DEALINGS<br>
> > > > IN<br>
> > > > + * THE SOFTWARE.<br>
> > > > + */<br>
> > > > +<br>
> > > > +#include <clc/clc.h><br>
> > > > +<br>
> > > > +#include "../clcmacro.h"<br>
> > > > +<br>
> > > > +_CLC_OVERLOAD _CLC_DEF float step(float edge, float x) {<br>
> > > > +  return x < edge ? 0.0f : 1.0f;<br>
> > > > +}<br>
> > > > +<br>
> > > > +_CLC_BINARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, float, step, float,<br>
> > float);<br>
> > > > +<br>
> > > > +_CLC_V_S_V_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, float, step, float,<br>
> > float);<br>
> > > > +<br>
> > > > +#ifdef cl_khr_fp64<br>
> > > > +#pragma OPENCL EXTENSION cl_khr_fp64 : enable<br>
> > > > +<br>
> > > > +#define STEP_DEF(edge_type, x_type) \<br>
> > > > +  _CLC_OVERLOAD _CLC_DEF x_type step(edge_type edge, x_type x) { \<br>
> > > > +    return x < edge ? 0.0 : 1.0; \<br>
> > > > + }<br>
> > > > +<br>
> > > > +STEP_DEF(double, double);<br>
> > > > +<br>
> > > > +_CLC_BINARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, double, step, double,<br>
> > > > double);<br>
> > > > +_CLC_V_S_V_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, double, step, double,<br>
> > > > double);<br>
> > > > +<br>
> > > ><br>
> > > +STEP_DEF(float, double);<br>
> > > > +STEP_DEF(double, float);<br>
> > > > +<br>
> > > > +_CLC_V_S_V_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, double, step, float,<br>
> > double);<br>
> > > > +_CLC_V_S_V_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, float, step, double,<br>
> > float);<br>
> > > > +<br>
> > > ><br>
> > > This patch looks good up until here.  Did you mean to define:<br>
> > > step(float edge, double x) and step(double edge, float x)<br>
> > ><br>
> > > I don't see those variants in the spec, but all I've checked is the 1.x<br>
> > > quick reference cards and the CLC 2.0 spec section 6.13.4.<br>
> > ><br>
> ><br>
> > Both the 1.0 and 1.1 man pages have:<br>
> ><br>
> > gentype step (float edge, gentype x)<br>
> > gentype step (double edge, gentype x)<br>
> ><br>
> > My interpretation is that since gentype can be either float or double,<br>
> > the mixed variants are required.<br>
> ><br>
> > -Tom<br>
> ><br>
><br>
> I got most of the way through writing something about how because step is<br>
> defined separately in CL1.1 sections 6.11.4 and 9.3.3 and therefore they<br>
> weren't actually overlapping, but then I reread the section introduction,<br>
> which states:<br>
><br>
> "The built-in common functions defined in table 6.12 (also listed below)<br>
> are extended to include<br>
> appropriate versions of functions that take double, and double{2|3|4|8|16}<br>
> as<br>
> arguments and return values. gentype now also includes double, double2,<br>
> double3,<br>
> double4, double8 and double16."<br>
><br>
> The key words being "gentype NOW ALSO INCLUDES", which means that the float<br>
> values are actually included, and the additional variants should be<br>
> allowed.  My bad.<br>
><br>
> I'm fine with this as it stands.<br>
><br>
> Do we need to re-check the clamp, min, max, mix, and smoothstep functions<br>
> for similar gotchas? Or are those correct already?  Most of the test suites<br>
> that I have access to are pretty lacking in double tests and the hardware<br>
> that I'm sitting in front ATM of doesn't even support doubles.<br>
><br>
<br>
</div></div>I can take a look at this.<br>
<br>
For this current series if I add a note about conformance test passing are these<br>
OK to commit?<br>
<br></blockquote><div><br></div><div>Yeah, go ahead.  I'm fine with the implementations as they currently stand. Any of the other builtins that might be missing prototypes for specific argument types can be handled in a follow-up if needed.<br><br></div><div>--Aaron<br></div><div><br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Thanks,<br>
Tom<br>
<div class="HOEnZb"><div class="h5"><br></div></div></blockquote><div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">
> --Aaron<br>
><br>
><br>
> > > With the mixed float/double variants removed:<br>
> > > Reviewed-by: Aaron Watry <<a href="mailto:awatry@gmail.com">awatry@gmail.com</a>><br>
> > ><br>
> > ><br>
> > ><br>
> > > > +#endif<br>
> > > > --<br>
> > > > 2.0.4<br>
> > > ><br>
> > > ><br>
> > > > _______________________________________________<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>
> ><br>
> > > _______________________________________________<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>
> ><br>
</div></div></blockquote></div><br></div></div>