<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Mar 4, 2015 at 9:21 AM, 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:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">We need to reinterpret float/double types as uint/ulong in order to<br>
perform the bitwise operations.<br>
<br>
This has been tested with piglit, OpenCV, and the ocl conformance tests.<br>
<br>
v2:<br>
  - Use vector operations rather than splitting vectors into scalar<br>
    components.<br>
---<br>
 generic/include/clc/relational/bitselect.h   | 29 ++++++++++++++-<br>
 generic/include/clc/relational/bitselect.inc | 23 ++++++++++++<br>
 generic/lib/SOURCES                          |  1 +<br>
 generic/lib/relational/<a href="http://bitselect.cl" target="_blank">bitselect.cl</a>          | 53 ++++++++++++++++++++++++++++<br>
 generic/lib/relational/bitselect.inc         | 27 ++++++++++++++<br>
 5 files changed, 132 insertions(+), 1 deletion(-)<br>
 create mode 100644 generic/include/clc/relational/bitselect.inc<br>
 create mode 100644 generic/lib/relational/<a href="http://bitselect.cl" target="_blank">bitselect.cl</a><br>
 create mode 100644 generic/lib/relational/bitselect.inc<br>
<br>
diff --git a/generic/include/clc/relational/bitselect.h b/generic/include/clc/relational/bitselect.h<br>
index e91cbfd..0c7b2f7 100644<br>
--- a/generic/include/clc/relational/bitselect.h<br>
+++ b/generic/include/clc/relational/bitselect.h<br>
@@ -1 +1,28 @@<br>
-#define bitselect(x, y, z) ((x) ^ ((z) & ((y) ^ (x))))<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>
+#define __CLC_BODY <clc/relational/bitselect.inc><br>
+#include <clc/math/gentype.inc><br>
+#define __CLC_BODY <clc/relational/bitselect.inc><br>
+#include <clc/integer/gentype.inc><br>
+<br>
+#undef __CLC_BODY<br>
diff --git a/generic/include/clc/relational/bitselect.inc b/generic/include/clc/relational/bitselect.inc<br>
new file mode 100644<br>
index 0000000..364d649<br>
--- /dev/null<br>
+++ b/generic/include/clc/relational/bitselect.inc<br>
@@ -0,0 +1,23 @@<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>
+_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE bitselect(__CLC_GENTYPE x, __CLC_GENTYPE y, __CLC_GENTYPE z);<br>
diff --git a/generic/lib/SOURCES b/generic/lib/SOURCES<br>
index a7b2fa2..ac3d870 100644<br>
--- a/generic/lib/SOURCES<br>
+++ b/generic/lib/SOURCES<br>
@@ -80,6 +80,7 @@ math/<a href="http://sincos_helpers.cl" target="_blank">sincos_helpers.cl</a><br>
 math/<a href="http://tan.cl" target="_blank">tan.cl</a><br>
 relational/<a href="http://all.cl" target="_blank">all.cl</a><br>
 relational/<a href="http://any.cl" target="_blank">any.cl</a><br>
+relational/<a href="http://bitselect.cl" target="_blank">bitselect.cl</a><br>
 relational/<a href="http://isequal.cl" target="_blank">isequal.cl</a><br>
 relational/<a href="http://isfinite.cl" target="_blank">isfinite.cl</a><br>
 relational/<a href="http://isgreater.cl" target="_blank">isgreater.cl</a><br>
diff --git a/generic/lib/relational/<a href="http://bitselect.cl" target="_blank">bitselect.cl</a> b/generic/lib/relational/<a href="http://bitselect.cl" target="_blank">bitselect.cl</a><br>
new file mode 100644<br>
index 0000000..af4e70c<br>
--- /dev/null<br>
+++ b/generic/lib/relational/<a href="http://bitselect.cl" target="_blank">bitselect.cl</a><br>
@@ -0,0 +1,53 @@<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>
+#define __CLC_BODY <bitselect.inc><br>
+#include <clc/integer/gentype.inc><br>
+#undef __CLC_BODY<br>
+<br>
+#define FLOAT_BITSELECT(f_type, i_type, width) \<br>
+  _CLC_OVERLOAD _CLC_DEF f_type##width bitselect(f_type##width x, f_type##width y, f_type##width z) { \<br>
+  return as_##f_type##width(bitselect(as_##i_type##width(x), as_##i_type##width(y), as_##i_type##width(z))); \<br>
+}<br>
+<br>
+FLOAT_BITSELECT(float, uint, )<br>
+FLOAT_BITSELECT(float, uint, 2)<br>
+FLOAT_BITSELECT(float, uint, 3)<br>
+FLOAT_BITSELECT(float, uint, 4)<br>
+FLOAT_BITSELECT(float, uint, 8)<br>
+FLOAT_BITSELECT(float, uint, 16)<br>
+<br>
+#ifdef cl_khr_fp64<br>
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable<br>
+<br>
+FLOAT_BITSELECT(double, ulong, )<br>
+FLOAT_BITSELECT(double, ulong, 2)<br>
+FLOAT_BITSELECT(double, ulong, 3)<br>
+FLOAT_BITSELECT(double, ulong, 4)<br>
+FLOAT_BITSELECT(double, ulong, 8)<br>
+FLOAT_BITSELECT(double, ulong, 16)<br>
+<br>
+#endif<br>
diff --git a/generic/lib/relational/bitselect.inc b/generic/lib/relational/bitselect.inc<br>
new file mode 100644<br>
index 0000000..8157331<br>
--- /dev/null<br>
+++ b/generic/lib/relational/bitselect.inc<br>
@@ -0,0 +1,27 @@<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_DEF __CLC_GENTYPE bitselect(__CLC_GENTYPE x, __CLC_GENTYPE y, __CLC_GENTYPE z) {<br>
+  return ((x) ^ ((z) & ((y) ^ (x))));<br>
+}<br>
+<br>
+<br></blockquote><div><br></div><div>Remove the new blank line at EOF, and you can have:<br></div><div>Reviewed-by: Aaron Watry <<a href="mailto:awatry@gmail.com">awatry@gmail.com</a>><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>
2.0.4<br>
<br>
</font></span></blockquote></div><br></div></div>