[Piglit] [PATCH 2/2] CL: Add atomic_sub/atomic_dec tests

Aaron Watry awatry at gmail.com
Wed Sep 4 15:23:26 PDT 2013


---
 .../execute/builtin/atomic/atomic_dec-local.cl     | 67 +++++++++++++++++++++
 .../execute/builtin/atomic/atomic_sub-local.cl     | 70 ++++++++++++++++++++++
 2 files changed, 137 insertions(+)
 create mode 100644 tests/cl/program/execute/builtin/atomic/atomic_dec-local.cl
 create mode 100644 tests/cl/program/execute/builtin/atomic/atomic_sub-local.cl

diff --git a/tests/cl/program/execute/builtin/atomic/atomic_dec-local.cl b/tests/cl/program/execute/builtin/atomic/atomic_dec-local.cl
new file mode 100644
index 0000000..aaa9885
--- /dev/null
+++ b/tests/cl/program/execute/builtin/atomic/atomic_dec-local.cl
@@ -0,0 +1,67 @@
+/*!
+[config]
+name: atomic_dec local
+clc_version_min: 11
+
+[test]
+name: simple int
+kernel_name: simple_int
+dimensions: 1
+global_size: 1 0 0
+local_size: 1 0 0
+arg_out: 0 buffer int[2] -2 -3
+arg_in:  1 buffer int[1] NULL
+arg_in:  2 int           -2
+
+[test]
+name: simple uint
+kernel_name: simple_uint
+dimensions: 1
+global_size: 1 0 0
+local_size:  1 0 0
+arg_out: 0 buffer uint[2] 2 1
+arg_in:  1 buffer uint[1] NULL
+arg_in:  2 uint           2
+
+[test]
+name: threads
+kernel_name: threads_int
+dimensions: 1
+global_size: 8 0 0
+local_size:  8 0 0
+arg_out: 0 buffer int[1] 8
+arg_in:  1 buffer int[1] NULL
+
+[test]
+name: threads
+kernel_name: threads_uint
+dimensions: 1
+global_size: 8 0 0
+local_size:  8 0 0
+arg_out: 0 buffer uint[1] 8
+arg_in:  1 buffer uint[1] NULL
+
+!*/
+
+#define SIMPLE_TEST(TYPE) \
+kernel void simple_##TYPE(global TYPE *out, local TYPE *mem, TYPE initial) { \
+	*mem = initial; \
+	TYPE a = atomic_dec(mem); \
+	out[0] = a; \
+	out[1] = *mem; \
+}
+
+#define THREADS_TEST(TYPE) \
+kernel void threads_##TYPE(global TYPE *out, local TYPE *mem) { \
+	*mem = 16; \
+	barrier(CLK_LOCAL_MEM_FENCE); \
+	atomic_dec(mem); \
+	barrier(CLK_LOCAL_MEM_FENCE); \
+	*out = *mem; \
+}
+
+SIMPLE_TEST(int)
+SIMPLE_TEST(uint)
+
+THREADS_TEST(int)
+THREADS_TEST(uint)
diff --git a/tests/cl/program/execute/builtin/atomic/atomic_sub-local.cl b/tests/cl/program/execute/builtin/atomic/atomic_sub-local.cl
new file mode 100644
index 0000000..30fab8f
--- /dev/null
+++ b/tests/cl/program/execute/builtin/atomic/atomic_sub-local.cl
@@ -0,0 +1,70 @@
+/*!
+[config]
+name: atomic_sub local
+clc_version_min: 11
+
+[test]
+name: simple int
+kernel_name: simple_int
+dimensions: 1
+global_size: 1 0 0
+local_size:  1 0 0
+arg_out: 0 buffer int[2] -4 -9
+arg_in:  1 buffer int[1] NULL
+arg_in:  2 int           -4
+arg_in:  3 int           5
+
+[test]
+name: simple uint
+kernel_name: simple_uint
+dimensions: 1
+global_size: 1 0 0
+local_size:  1 0 0
+arg_out: 0 buffer uint[2] 5 1
+arg_in:  1 buffer uint[1] NULL
+arg_in:  2 uint           5
+arg_in:  3 uint           4
+
+[test]
+name: threads
+kernel_name: threads_int
+dimensions: 1
+global_size: 8 0 0
+local_size:  8 0 0
+arg_out: 0 buffer int[1] 28
+arg_in:  1 buffer int[1] NULL
+
+[test]
+name: threads
+kernel_name: threads_uint
+dimensions: 1
+global_size: 8 0 0
+local_size:  8 0 0
+arg_out: 0 buffer uint[1] 28
+arg_in:  1 buffer uint[1] NULL
+
+!*/
+
+#define SIMPLE_TEST(TYPE) \
+kernel void simple_##TYPE(global TYPE *out, local TYPE *mem, TYPE initial, TYPE value) { \
+	*mem = initial; \
+	TYPE a = atomic_sub(mem, value); \
+	out[0] = a; \
+	out[1] = *mem; \
+}
+
+#define THREADS_TEST(TYPE) \
+kernel void threads_##TYPE(global TYPE *out, local TYPE *mem) { \
+	*mem = 56; \
+	barrier(CLK_LOCAL_MEM_FENCE); \
+	TYPE id = get_local_id(0); \
+	atomic_sub(mem, id); \
+	barrier(CLK_LOCAL_MEM_FENCE); \
+	*out = *mem; \
+}
+
+SIMPLE_TEST(int)
+SIMPLE_TEST(uint)
+
+THREADS_TEST(int)
+THREADS_TEST(uint)
-- 
1.8.1.2



More information about the Piglit mailing list