[Libclc-dev] [PATCH 01/15] atomic: define extension functions for existing atomic implementations

Aaron Watry awatry at gmail.com
Tue Sep 9 16:24:34 PDT 2014


We were missing the local versions of the atom_* before

Signed-off-by: Aaron Watry <awatry at gmail.com>
---
 generic/include/clc/cl_khr_local_int32_base_atomics/atom_add.h | 2 ++
 generic/include/clc/cl_khr_local_int32_base_atomics/atom_dec.h | 2 ++
 generic/include/clc/cl_khr_local_int32_base_atomics/atom_inc.h | 2 ++
 generic/include/clc/cl_khr_local_int32_base_atomics/atom_sub.h | 2 ++
 generic/include/clc/clc.h                                      | 6 ++++++
 generic/lib/SOURCES                                            | 4 ++++
 generic/lib/cl_khr_local_int32_base_atomics/atom_add.cl        | 9 +++++++++
 generic/lib/cl_khr_local_int32_base_atomics/atom_dec.cl        | 9 +++++++++
 generic/lib/cl_khr_local_int32_base_atomics/atom_inc.cl        | 9 +++++++++
 generic/lib/cl_khr_local_int32_base_atomics/atom_sub.cl        | 9 +++++++++
 10 files changed, 54 insertions(+)
 create mode 100644 generic/include/clc/cl_khr_local_int32_base_atomics/atom_add.h
 create mode 100644 generic/include/clc/cl_khr_local_int32_base_atomics/atom_dec.h
 create mode 100644 generic/include/clc/cl_khr_local_int32_base_atomics/atom_inc.h
 create mode 100644 generic/include/clc/cl_khr_local_int32_base_atomics/atom_sub.h
 create mode 100644 generic/lib/cl_khr_local_int32_base_atomics/atom_add.cl
 create mode 100644 generic/lib/cl_khr_local_int32_base_atomics/atom_dec.cl
 create mode 100644 generic/lib/cl_khr_local_int32_base_atomics/atom_inc.cl
 create mode 100644 generic/lib/cl_khr_local_int32_base_atomics/atom_sub.cl

diff --git a/generic/include/clc/cl_khr_local_int32_base_atomics/atom_add.h b/generic/include/clc/cl_khr_local_int32_base_atomics/atom_add.h
new file mode 100644
index 0000000..096d011
--- /dev/null
+++ b/generic/include/clc/cl_khr_local_int32_base_atomics/atom_add.h
@@ -0,0 +1,2 @@
+_CLC_OVERLOAD _CLC_DECL int atom_add(local int *p, int val);
+_CLC_OVERLOAD _CLC_DECL unsigned int atom_add(local unsigned int *p, unsigned int val);
diff --git a/generic/include/clc/cl_khr_local_int32_base_atomics/atom_dec.h b/generic/include/clc/cl_khr_local_int32_base_atomics/atom_dec.h
new file mode 100644
index 0000000..e74d8fc
--- /dev/null
+++ b/generic/include/clc/cl_khr_local_int32_base_atomics/atom_dec.h
@@ -0,0 +1,2 @@
+_CLC_OVERLOAD _CLC_DECL int atom_dec(local int *p);
+_CLC_OVERLOAD _CLC_DECL unsigned int atom_dec(local unsigned int *p);
diff --git a/generic/include/clc/cl_khr_local_int32_base_atomics/atom_inc.h b/generic/include/clc/cl_khr_local_int32_base_atomics/atom_inc.h
new file mode 100644
index 0000000..718f1f2
--- /dev/null
+++ b/generic/include/clc/cl_khr_local_int32_base_atomics/atom_inc.h
@@ -0,0 +1,2 @@
+_CLC_OVERLOAD _CLC_DECL int atom_inc(local int *p);
+_CLC_OVERLOAD _CLC_DECL unsigned int atom_inc(local unsigned int *p);
diff --git a/generic/include/clc/cl_khr_local_int32_base_atomics/atom_sub.h b/generic/include/clc/cl_khr_local_int32_base_atomics/atom_sub.h
new file mode 100644
index 0000000..6363780
--- /dev/null
+++ b/generic/include/clc/cl_khr_local_int32_base_atomics/atom_sub.h
@@ -0,0 +1,2 @@
+_CLC_OVERLOAD _CLC_DECL int atom_sub(local int *p, int val);
+_CLC_OVERLOAD _CLC_DECL unsigned int atom_sub(local unsigned int *p, unsigned int val);
diff --git a/generic/include/clc/clc.h b/generic/include/clc/clc.h
index 94557a1..875496c 100644
--- a/generic/include/clc/clc.h
+++ b/generic/include/clc/clc.h
@@ -152,6 +152,12 @@
 #include <clc/cl_khr_global_int32_base_atomics/atom_inc.h>
 #include <clc/cl_khr_global_int32_base_atomics/atom_sub.h>
 
+#include <clc/cl_khr_local_int32_base_atomics/atom_add.h>
+#include <clc/cl_khr_local_int32_base_atomics/atom_dec.h>
+#include <clc/cl_khr_local_int32_base_atomics/atom_inc.h>
+#include <clc/cl_khr_local_int32_base_atomics/atom_sub.h>
+
+
 /* libclc internal defintions */
 #ifdef __CLC_INTERNAL
 #include <math/clc_nextafter.h>
diff --git a/generic/lib/SOURCES b/generic/lib/SOURCES
index 45e12aa..6777f6c 100644
--- a/generic/lib/SOURCES
+++ b/generic/lib/SOURCES
@@ -4,6 +4,10 @@ cl_khr_global_int32_base_atomics/atom_add.cl
 cl_khr_global_int32_base_atomics/atom_dec.cl
 cl_khr_global_int32_base_atomics/atom_inc.cl
 cl_khr_global_int32_base_atomics/atom_sub.cl
+cl_khr_local_int32_base_atomics/atom_add.cl
+cl_khr_local_int32_base_atomics/atom_dec.cl
+cl_khr_local_int32_base_atomics/atom_inc.cl
+cl_khr_local_int32_base_atomics/atom_sub.cl
 convert.cl
 common/sign.cl
 geometric/cross.cl
diff --git a/generic/lib/cl_khr_local_int32_base_atomics/atom_add.cl b/generic/lib/cl_khr_local_int32_base_atomics/atom_add.cl
new file mode 100644
index 0000000..a5dea18
--- /dev/null
+++ b/generic/lib/cl_khr_local_int32_base_atomics/atom_add.cl
@@ -0,0 +1,9 @@
+#include <clc/clc.h>
+
+#define IMPL(TYPE) \
+_CLC_OVERLOAD _CLC_DEF TYPE atom_add(local TYPE *p, TYPE val) { \
+  return atomic_add(p, val); \
+}
+
+IMPL(int)
+IMPL(unsigned int)
diff --git a/generic/lib/cl_khr_local_int32_base_atomics/atom_dec.cl b/generic/lib/cl_khr_local_int32_base_atomics/atom_dec.cl
new file mode 100644
index 0000000..d22c333
--- /dev/null
+++ b/generic/lib/cl_khr_local_int32_base_atomics/atom_dec.cl
@@ -0,0 +1,9 @@
+#include <clc/clc.h>
+
+#define IMPL(TYPE) \
+_CLC_OVERLOAD _CLC_DEF TYPE atom_dec(local TYPE *p) { \
+  return atom_sub(p, 1); \
+}
+
+IMPL(int)
+IMPL(unsigned int)
diff --git a/generic/lib/cl_khr_local_int32_base_atomics/atom_inc.cl b/generic/lib/cl_khr_local_int32_base_atomics/atom_inc.cl
new file mode 100644
index 0000000..4ba0d06
--- /dev/null
+++ b/generic/lib/cl_khr_local_int32_base_atomics/atom_inc.cl
@@ -0,0 +1,9 @@
+#include <clc/clc.h>
+
+#define IMPL(TYPE) \
+_CLC_OVERLOAD _CLC_DEF TYPE atom_inc(local TYPE *p) { \
+  return atom_add(p, 1); \
+}
+
+IMPL(int)
+IMPL(unsigned int)
diff --git a/generic/lib/cl_khr_local_int32_base_atomics/atom_sub.cl b/generic/lib/cl_khr_local_int32_base_atomics/atom_sub.cl
new file mode 100644
index 0000000..c96696a
--- /dev/null
+++ b/generic/lib/cl_khr_local_int32_base_atomics/atom_sub.cl
@@ -0,0 +1,9 @@
+#include <clc/clc.h>
+
+#define IMPL(TYPE) \
+_CLC_OVERLOAD _CLC_DEF TYPE atom_sub(local TYPE *p, TYPE val) { \
+  return atomic_sub(p, val); \
+}
+
+IMPL(int)
+IMPL(unsigned int)
-- 
1.9.1





More information about the Libclc-dev mailing list