summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Watry <awatry@gmail.com>2013-04-13 11:22:52 -0500
committerTom Stellard <thomas.stellard@amd.com>2013-04-19 23:27:10 -0400
commitd2d53dc64cc5a2916f27aa4550c7775b0ab0569c (patch)
tree17f8edf9770839c6bc988c97b08749558b1c788b
parent7a3adccc75676c9aef2af9c0a401a11b3c855dd2 (diff)
libclc: implement initial version of min()
This doesn't handle the integer cases for min(vector, scalar).
-rw-r--r--generic/include/clc/clc.h1
-rw-r--r--generic/include/clc/shared/min.h5
-rw-r--r--generic/include/clc/shared/min.inc1
-rw-r--r--generic/lib/SOURCES1
-rw-r--r--generic/lib/shared/min.cl11
-rw-r--r--generic/lib/shared/min.inc3
6 files changed, 22 insertions, 0 deletions
diff --git a/generic/include/clc/clc.h b/generic/include/clc/clc.h
index 72f518a..74f1126 100644
--- a/generic/include/clc/clc.h
+++ b/generic/include/clc/clc.h
@@ -69,6 +69,7 @@
/* 6.11.2 and 6.11.3 Shared Integer/Math Functions */
#include <clc/shared/clamp.h>
#include <clc/shared/max.h>
+#include <clc/shared/min.h>
/* 6.11.5 Geometric Functions */
#include <clc/geometric/cross.h>
diff --git a/generic/include/clc/shared/min.h b/generic/include/clc/shared/min.h
new file mode 100644
index 0000000..e16b45d
--- /dev/null
+++ b/generic/include/clc/shared/min.h
@@ -0,0 +1,5 @@
+#define BODY <clc/shared/min.inc>
+#include <clc/integer/gentype.inc>
+
+#define BODY <clc/shared/min.inc>
+#include <clc/math/gentype.inc>
diff --git a/generic/include/clc/shared/min.inc b/generic/include/clc/shared/min.inc
new file mode 100644
index 0000000..3bc9880
--- /dev/null
+++ b/generic/include/clc/shared/min.inc
@@ -0,0 +1 @@
+_CLC_OVERLOAD _CLC_DECL GENTYPE min(GENTYPE a, GENTYPE b);
diff --git a/generic/lib/SOURCES b/generic/lib/SOURCES
index 7f27ec4..eac6c60 100644
--- a/generic/lib/SOURCES
+++ b/generic/lib/SOURCES
@@ -19,5 +19,6 @@ math/mad.cl
relational/any.cl
shared/clamp.cl
shared/max.cl
+shared/min.cl
workitem/get_global_id.cl
workitem/get_global_size.cl
diff --git a/generic/lib/shared/min.cl b/generic/lib/shared/min.cl
new file mode 100644
index 0000000..49481cb
--- /dev/null
+++ b/generic/lib/shared/min.cl
@@ -0,0 +1,11 @@
+#include <clc/clc.h>
+
+#define BODY <min.inc>
+#include <clc/integer/gentype.inc>
+
+#ifdef cl_khr_fp64
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+#endif
+
+#define BODY <min.inc>
+#include <clc/math/gentype.inc>
diff --git a/generic/lib/shared/min.inc b/generic/lib/shared/min.inc
new file mode 100644
index 0000000..b99bc35
--- /dev/null
+++ b/generic/lib/shared/min.inc
@@ -0,0 +1,3 @@
+_CLC_OVERLOAD _CLC_DEF GENTYPE min(GENTYPE a, GENTYPE b) {
+ return (a < b ? a : b);
+}