summaryrefslogtreecommitdiff
path: root/tests/cl/program/execute/builtin/atomic/atomic_int32_add-local.cl
diff options
context:
space:
mode:
Diffstat (limited to 'tests/cl/program/execute/builtin/atomic/atomic_int32_add-local.cl')
-rw-r--r--tests/cl/program/execute/builtin/atomic/atomic_int32_add-local.cl71
1 files changed, 71 insertions, 0 deletions
diff --git a/tests/cl/program/execute/builtin/atomic/atomic_int32_add-local.cl b/tests/cl/program/execute/builtin/atomic/atomic_int32_add-local.cl
new file mode 100644
index 000000000..1800a0fe2
--- /dev/null
+++ b/tests/cl/program/execute/builtin/atomic/atomic_int32_add-local.cl
@@ -0,0 +1,71 @@
+/*!
+[config]
+name: atom_int32_add local
+clc_version_min: 10
+require_device_extensions: cl_khr_local_int32_base_atomics
+
+[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 1
+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] 4 9
+arg_in: 1 buffer uint[1] NULL
+arg_in: 2 uint 4
+arg_in: 3 uint 5
+
+[test]
+name: threads int
+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 uint
+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 = atom_add(mem, value); \
+ out[0] = a; \
+ out[1] = *mem; \
+}
+
+#define THREADS_TEST(TYPE) \
+kernel void threads_##TYPE(global TYPE *out, local TYPE *mem) { \
+ *mem = 0; \
+ barrier(CLK_LOCAL_MEM_FENCE); \
+ TYPE id = get_local_id(0); \
+ atom_add(mem, id); \
+ barrier(CLK_LOCAL_MEM_FENCE); \
+ *out = *mem; \
+}
+
+SIMPLE_TEST(int)
+SIMPLE_TEST(uint)
+
+THREADS_TEST(int)
+THREADS_TEST(uint)