[Libclc-dev] [PATCH 2/2] minmag: Implement

Jan Vesely via Libclc-dev libclc-dev at lists.llvm.org
Mon Nov 13 13:33:19 PST 2017


Signed-off-by: Jan Vesely <jan.vesely at rutgers.edu>
---
CTS resutls are the same as maxnum but correlated to fmin instead of
fmax

 generic/include/clc/clc.h         | 1 +
 generic/include/clc/math/minmag.h | 7 +++++++
 generic/lib/SOURCES               | 1 +
 generic/lib/math/minmag.cl        | 4 ++++
 generic/lib/math/minmag.inc       | 4 ++++
 5 files changed, 17 insertions(+)
 create mode 100644 generic/include/clc/math/minmag.h
 create mode 100644 generic/lib/math/minmag.cl
 create mode 100644 generic/lib/math/minmag.inc

diff --git a/generic/include/clc/clc.h b/generic/include/clc/clc.h
index fd4bbc3..348ee94 100644
--- a/generic/include/clc/clc.h
+++ b/generic/include/clc/clc.h
@@ -96,6 +96,7 @@
 #include <clc/math/logb.h>
 #include <clc/math/mad.h>
 #include <clc/math/maxmag.h>
+#include <clc/math/minmag.h>
 #include <clc/math/modf.h>
 #include <clc/math/nextafter.h>
 #include <clc/math/pow.h>
diff --git a/generic/include/clc/math/minmag.h b/generic/include/clc/math/minmag.h
new file mode 100644
index 0000000..1183ac1
--- /dev/null
+++ b/generic/include/clc/math/minmag.h
@@ -0,0 +1,7 @@
+#define __CLC_BODY <clc/math/binary_decl_tt.inc>
+#define __CLC_FUNCTION minmag
+
+#include <clc/math/gentype.inc>
+
+#undef __CLC_BODY
+#undef __CLC_FUNCTION
diff --git a/generic/lib/SOURCES b/generic/lib/SOURCES
index 7526b24..a0fda2d 100644
--- a/generic/lib/SOURCES
+++ b/generic/lib/SOURCES
@@ -131,6 +131,7 @@ math/log2.cl
 math/logb.cl
 math/mad.cl
 math/maxmag.cl
+math/minmag.cl
 math/modf.cl
 math/native_cos.cl
 math/native_divide.cl
diff --git a/generic/lib/math/minmag.cl b/generic/lib/math/minmag.cl
new file mode 100644
index 0000000..1c815fc
--- /dev/null
+++ b/generic/lib/math/minmag.cl
@@ -0,0 +1,4 @@
+#include <clc/clc.h>
+
+#define __CLC_BODY <minmag.inc>
+#include <clc/math/gentype.inc>
diff --git a/generic/lib/math/minmag.inc b/generic/lib/math/minmag.inc
new file mode 100644
index 0000000..097822c
--- /dev/null
+++ b/generic/lib/math/minmag.inc
@@ -0,0 +1,4 @@
+_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE minmag(__CLC_GENTYPE x, __CLC_GENTYPE y) {
+  const __CLC_GENTYPE res = select(y, x, isless(fabs(x), fabs(y)));
+  return select(res, fmin(x, y), isnan(x) | isnan(y) | isequal(fabs(x), fabs(y)));
+}
-- 
2.13.6



More information about the Libclc-dev mailing list