<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Feb 26, 2015 at 10:59 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:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class=""><div class="h5">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 obtaining<br>
> > a copy<br>
> > + * of this software and associated documentation files (the "Software"),<br>
> > to deal<br>
> > + * in the Software without restriction, including without limitation the<br>
> > rights<br>
> > + * to use, copy, modify, merge, publish, distribute, sublicense, and/or<br>
> > 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<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 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 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 obtaining<br>
> > a copy<br>
> > + * of this software and associated documentation files (the "Software"),<br>
> > to deal<br>
> > + * in the Software without restriction, including without limitation the<br>
> > rights<br>
> > + * to use, copy, modify, merge, publish, distribute, sublicense, and/or<br>
> > 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<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 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 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 x);<br>
> > +<br>
> > +#ifdef cl_khr_fp64<br>
> > +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE step(double edge, __CLC_GENTYPE 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, 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, 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 obtaining<br>
> > a copy<br>
> > + * of this software and associated documentation files (the "Software"),<br>
> > to deal<br>
> > + * in the Software without restriction, including without limitation the<br>
> > rights<br>
> > + * to use, copy, modify, merge, publish, distribute, sublicense, and/or<br>
> > 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<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 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 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, float);<br>
> > +<br>
> > +_CLC_V_S_V_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, float, step, float, 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, double);<br>
> > +_CLC_V_S_V_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, float, step, double, 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>
</div></div>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>
<span class=""><font color="#888888"><br>
-Tom<br></font></span></blockquote><div><br></div>I got most of the way through writing something about how because step is defined separately in CL1.1 sections 6.11.4 and 9.3.3 and therefore they weren't actually overlapping, but then I reread the section introduction, which states:<br><br></div><div class="gmail_quote">"The built-in common functions defined in table 6.12 (also listed below) are extended to include<br>appropriate versions of functions that take double, and double{2|3|4|8|16} as<br>arguments and return values. gentype now also includes double, double2, double3,<br>double4, double8 and double16."<br><br></div><div class="gmail_quote">The key words being "gentype NOW ALSO INCLUDES", which means that the float values are actually included, and the additional variants should be allowed.  My bad.<br><br></div><div class="gmail_quote">I'm fine with this as it stands.<br><br></div><div class="gmail_quote">Do we need to re-check the clamp, min, max, mix, and smoothstep functions for similar gotchas? Or are those correct already?  Most of the test suites that I have access to are pretty lacking in double tests and the hardware that I'm sitting in front ATM of doesn't even support doubles.<br></div><div class="gmail_quote"><br></div><div class="gmail_quote">--Aaron<br></div><div class="gmail_quote"><br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class=""><font color="#888888">
</font></span><div class=""><div class="h5"><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>
</div></div></blockquote></div><br></div></div>