<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Feb 25, 2015 at 3:20 PM, Tom Stellard <span dir="ltr"><<a href="mailto:thomas.stellard@amd.com" target="_blank">thomas.stellard@amd.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">---<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>
 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 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 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>
+#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 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 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>
+_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE step(__CLC_GENTYPE edge, __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, 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, ARG2_TYPE, ARG3_TYPE) \<br>
   DECLSPEC RET_TYPE##2 FUNCTION(ARG1_TYPE##2 x, ARG2_TYPE##2 y, ARG3_TYPE##2 z) { \<br>
     return (RET_TYPE##2)(FUNCTION(x.x, y.x, z.x), FUNCTION(x.y, y.y, 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 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>
+<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, double);<br>
+_CLC_V_S_V_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, double, step, double, double);<br>
+<br></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+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></blockquote><div><div>This patch looks good up until here.  Did you mean to define:<br></div><div>step(float edge, double x) and step(double edge, float x)<br><br></div><div>I don't see those variants in the spec, but all I've checked is the 1.x quick reference cards and the CLC 2.0 spec section 6.13.4.<br><br></div><div>With the mixed float/double variants removed:<br></div><div>Reviewed-by: Aaron Watry <<a href="mailto:awatry@gmail.com">awatry@gmail.com</a>><br></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">
+#endif<br>
<span class=""><font color="#888888">--<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>
</font></span></blockquote></div><br></div></div>