[Piglit] [PATCH] cl: Add tests for arrays declared on the stack (private memory)

Tom Stellard tom at stellard.net
Tue Jan 22 16:55:43 PST 2013


From: Tom Stellard <thomas.stellard at amd.com>

---
 tests/cl/program/execute/i32-stack-array.cl        | 256 +++++++++++++++++++++
 tests/cl/program/execute/multiple-stack-objects.cl |  25 ++
 tests/cl/program/execute/v3f32-stack-array.cl      |  32 +++
 tests/cl/program/execute/v3i32-stack-array.cl      |  68 ++++++
 tests/cl/program/execute/v3i32-stack.cl            |  29 +++
 tests/cl/program/execute/v4i32-stack.cl            |  31 +++
 6 files changed, 441 insertions(+)
 create mode 100644 tests/cl/program/execute/i32-stack-array.cl
 create mode 100644 tests/cl/program/execute/multiple-stack-objects.cl
 create mode 100644 tests/cl/program/execute/v3f32-stack-array.cl
 create mode 100644 tests/cl/program/execute/v3i32-stack-array.cl
 create mode 100644 tests/cl/program/execute/v3i32-stack.cl
 create mode 100644 tests/cl/program/execute/v4i32-stack.cl

diff --git a/tests/cl/program/execute/i32-stack-array.cl b/tests/cl/program/execute/i32-stack-array.cl
new file mode 100644
index 0000000..534ee13
--- /dev/null
+++ b/tests/cl/program/execute/i32-stack-array.cl
@@ -0,0 +1,256 @@
+/*!
+[config]
+name: i32 stack array read
+clc_version_min: 10
+
+dimensions: 1
+global_size: 1 0 0
+
+# We want to test with an array of 5 elements, so that on GPUs with vec4
+# registers, the array will be span two registers.
+
+##===----------------------------------------------------------------------===##
+# DIRECT WRITE / INDIRECT READ
+##===----------------------------------------------------------------------===##
+
+[test]
+kernel_name: stack_array_read
+name: i32 stack array read
+arg_out: 0 buffer int[5] 4 5 6 7 8
+arg_in:  1 buffer int[5] 0 1 2 3 4
+
+[test]
+kernel_name: stack_array_read
+name: i32 stack array read
+arg_out: 0 buffer int[5] 5 5 5 5 5
+arg_in:  1 buffer int[5] 1 1 1 1 1
+
+[test]
+kernel_name: stack_array_read
+name: i32 stack array read
+arg_out: 0 buffer int[5] 8 7 5 6 4
+arg_in:  1 buffer int[5] 4 3 1 2 0
+
+[test]
+kernel_name: stack_array_read
+name: i32 stack array read
+arg_out: 0 buffer int[5] 7 5 8 4 6
+arg_in:  1 buffer int[5] 3 1 4 0 2
+
+##===----------------------------------------------------------------------===##
+# INDIRECT WRITE / DIRECT READ
+##===----------------------------------------------------------------------===##
+
+[test]
+kernel_name: stack_array_write
+name: i32 stack array write
+arg_out: 0 buffer int[5] 4 5 6 7 8
+arg_in:  1 buffer int[5] 0 1 2 3 4
+
+##===----------------------------------------------------------------------===##
+# INDIRECT WRITE / DIRECT READ
+##===----------------------------------------------------------------------===##
+
+[test]
+kernel_name: stack_array_write_read
+name: i32 stack array read write
+arg_out: 0 buffer int[5] 4 5 6 7 8
+arg_in:  1 buffer int[10] 0 1 2 3 4 \
+                          0 1 2 3 4
+
+##===----------------------------------------------------------------------===##
+# DIRECT WRITE (IF and ELSE) / DIRECT READ
+##===----------------------------------------------------------------------===##
+[test]
+kernel_name: stack_array_write_if_else_read
+name: i32 stack array direct write (IF and ELSE)
+arg_out: 0 buffer int[5] 4 5 6 7 8
+arg_in:  1 buffer int[1] 1
+
+##===----------------------------------------------------------------------===##
+# DIRECT WRITE (IF and ELSE) / INDIRECT READ
+##===----------------------------------------------------------------------===##
+[test]
+kernel_name: stack_array_write_if_else_indirect_read
+name: i32 stack array direct write (IF and ELSE) indirect read
+arg_out: 0 buffer int[5] 4 5 6 7 8
+arg_in:  1 buffer int[6] 1 \
+                         0 1 2 3 4
+
+[test]
+kernel_name: stack_array_write_if_else_indirect_read
+name: i32 stack array direct write (IF and ELSE) indirect read
+arg_out: 0 buffer int[5] 0 0 0 0 0
+arg_in:  1 buffer int[6] 0 \
+                         0 1 2 3 4
+
+[test]
+kernel_name: stack_array_write_if_else_indirect_read
+name: i32 stack array direct write (IF and ELSE) indirect read
+arg_out: 0 buffer int[5] 8 7 6 5 4
+arg_in:  1 buffer int[6] 1 \
+                         4 3 2 1 0
+
+##===----------------------------------------------------------------------===##
+# INDIRECT WRITE (IF and ELSE) / DIRECT READ
+##===----------------------------------------------------------------------===##
+[test]
+kernel_name: stack_array_indirect_write_if_else_read
+name: i32 stack array indirect write (IF and ELSE) direct read
+arg_out: 0 buffer int[5] 4 5 6 7 8
+arg_in:  1 buffer int[6] 1 \
+                         0 1 2 3 4
+
+##===----------------------------------------------------------------------===##
+# INDIRECT WRITE (IF and ELSE) / INDIRECT READ
+##===----------------------------------------------------------------------===##
+[test]
+kernel_name: stack_array_indirect_write_if_else_indirect_read
+name: i32 stack array indirect write (IF and ELSE) indirect read
+arg_out: 0 buffer int[5] 4 5 6 7 8
+arg_in:  1 buffer int[11] 1 \
+                          0 1 2 3 4 \
+                          0 1 2 3 4
+[test]
+kernel_name: stack_array_indirect_write_if_else_indirect_read
+name: i32 stack array indirect write (IF and ELSE) indirect read
+arg_out: 0 buffer int[5] 8 7 6 5 4
+arg_in:  1 buffer int[11] 1 \
+                          0 1 2 3 4 \
+                          4 3 2 1 0
+!*/
+
+kernel void stack_array_read(global int* out, global int *in) {
+
+	int stack[5];
+	stack[0] = 4;
+	stack[1] = 5;
+	stack[2] = 6;
+	stack[3] = 7;
+	stack[4] = 8;
+	out[0] = stack[in[0]];
+	out[1] = stack[in[1]];
+	out[2] = stack[in[2]];
+	out[3] = stack[in[3]];
+	out[4] = stack[in[4]];
+}
+
+kernel void stack_array_write(global int* out, global int *in) {
+
+	int stack[5];
+	stack[in[0]] = 4;
+	stack[in[1]] = 5;
+	stack[in[2]] = 6;
+	stack[in[3]] = 7;
+	stack[in[4]] = 8;
+
+	out[0] = stack[0];
+	out[1] = stack[1];
+	out[2] = stack[2];
+	out[3] = stack[3];
+	out[4] = stack[4];
+}
+
+kernel void stack_array_write_read(global int *out, global int *in) {
+
+	int stack[5];
+	stack[in[0]] = 4;
+	stack[in[1]] = 5;
+	stack[in[2]] = 6;
+	stack[in[3]] = 7;
+	stack[in[4]] = 8;
+
+	out[0] = stack[in[5]];
+	out[1] = stack[in[6]];
+	out[2] = stack[in[7]];
+	out[3] = stack[in[8]];
+	out[4] = stack[in[9]];
+
+}
+
+kernel void stack_array_write_if_else_read(global int *out, global int *in) {
+
+	int stack[5];
+	if (in[0] == 1) {
+		stack[0] = 4;
+		stack[1] = 5;
+		stack[2] = 6;
+		stack[3] = 7;
+		stack[4] = 8;
+	} else {
+		stack[0] = stack[1] = stack[2] = stack[3] = stack[4] = 0;
+	}
+
+	out[0] = stack[0];
+	out[1] = stack[1];
+	out[2] = stack[2];
+	out[3] = stack[3];
+	out[4] = stack[4];
+}
+
+kernel void stack_array_write_if_else_indirect_read(global int *out, global int *in) {
+
+	int stack[5];
+	if (in[0] == 1) {
+		stack[0] = 4;
+		stack[1] = 5;
+		stack[2] = 6;
+		stack[3] = 7;
+		stack[4] = 8;
+	} else {
+		stack[0] = stack[1] = stack[2] = stack[3] = stack[4] = 0;
+	}
+
+	out[0] = stack[in[1]];
+	out[1] = stack[in[2]];
+	out[2] = stack[in[3]];
+	out[3] = stack[in[4]];
+	out[4] = stack[in[5]];
+}
+
+kernel void stack_array_indirect_write_if_else_read(global int *out, global int *in) {
+
+	int stack[5];
+	if (in[0] == 1) {
+		stack[in[1]] = 4;
+		stack[in[2]] = 5;
+		stack[in[3]] = 6;
+		stack[in[4]] = 7;
+		stack[in[5]] = 8;
+	} else {
+		stack[in[1]] = 9;
+		stack[in[2]] = 10;
+		stack[in[3]] = 11;
+		stack[in[4]] = 12;
+		stack[in[5]] = 13;
+	}
+
+	out[0] = stack[0];
+	out[1] = stack[1];
+	out[2] = stack[2];
+	out[3] = stack[3];
+	out[4] = stack[4];
+}
+
+kernel void stack_array_indirect_write_if_else_indirect_read(global int *out, global int *in) {
+	int stack[5];
+	if (in[0] == 1) {
+		stack[in[1]] = 4;
+		stack[in[2]] = 5;
+		stack[in[3]] = 6;
+		stack[in[4]] = 7;
+		stack[in[5]] = 8;
+	} else {
+		stack[in[1]] = 9;
+		stack[in[2]] = 10;
+		stack[in[3]] = 11;
+		stack[in[4]] = 12;
+		stack[in[5]] = 13;
+	}
+
+	out[0] = stack[in[6]];
+	out[1] = stack[in[7]];
+	out[2] = stack[in[8]];
+	out[3] = stack[in[9]];
+	out[4] = stack[in[10]];
+}
diff --git a/tests/cl/program/execute/multiple-stack-objects.cl b/tests/cl/program/execute/multiple-stack-objects.cl
new file mode 100644
index 0000000..fbf0ae3
--- /dev/null
+++ b/tests/cl/program/execute/multiple-stack-objects.cl
@@ -0,0 +1,25 @@
+/*!
+[config]
+
+[test]
+kernel_name: test
+name: multiple stack objects
+arg_out: 0 buffer int[1]   2
+arg_out: 1 buffer float[1] 2.0
+arg_in:  2 int 0
+
+!*/
+
+kernel void test(global int *out_i, global float *out_f, int index) {
+
+	int stack_i[2];
+	float stack_f[2];
+
+	stack_i[0] = 2;
+	stack_i[1] = 3;
+	stack_f[0] = 2.0f;
+	stack_f[1] = 3.0f;
+
+	out_i[0] = stack_i[index];
+	out_f[0] = stack_f[index];
+}
diff --git a/tests/cl/program/execute/v3f32-stack-array.cl b/tests/cl/program/execute/v3f32-stack-array.cl
new file mode 100644
index 0000000..c56749f
--- /dev/null
+++ b/tests/cl/program/execute/v3f32-stack-array.cl
@@ -0,0 +1,32 @@
+/*!
+[config]
+name: i32 stack array
+clc_version_min: 10
+
+kernel_name: stack_array
+dimensions: 1
+global_size: 1 0 0
+
+[test]
+name: i32 stack array
+arg_out: 0 buffer int[4] 4 5 6 7
+arg_in:  1 buffer int[4] 0 1 2 3
+
+[test]
+name: i32 stack array
+arg_out: 0 buffer int[4] 5 5 5 5
+arg_in:  1 buffer int[4] 1 1 1 1
+
+[test]
+name: i32 stack array
+arg_out: 0 buffer int[4] 7 5 6 4
+arg_in:  1 buffer int[4] 3 1 2 0
+!*/
+
+kernel void stack_array(global int* out, global int *in) {
+	int3 stack[2];
+	stack[in[0]].s0 = 4;
+	stack[in[0] + 1].s0 = 5;
+	out[0] = stack[in[0]].s0;
+	out[1] = stack[in[1]].s0;
+}
diff --git a/tests/cl/program/execute/v3i32-stack-array.cl b/tests/cl/program/execute/v3i32-stack-array.cl
new file mode 100644
index 0000000..5f1d34b
--- /dev/null
+++ b/tests/cl/program/execute/v3i32-stack-array.cl
@@ -0,0 +1,68 @@
+/*!
+[config]
+name: i32 stack array
+clc_version_min: 10
+
+dimensions: 1
+global_size: 1 0 0
+
+##===----------------------------------------------------------------------===##
+# INDIRECT READ
+##===----------------------------------------------------------------------===##
+
+[test]
+kernel_name: stack_array_indirect_read
+name: indirect read 0
+arg_out: 0 buffer int3[2] 4 5 6 7 8 9
+arg_in:  1 buffer int[2] 0 1
+
+[test]
+name: indirect read 1
+kernel_name: stack_array_indirect_read
+arg_out: 0 buffer int3[2] 7 8 9 4 5 6
+arg_in:  1 buffer int[2] 1 0
+
+##===----------------------------------------------------------------------===##
+# INDIRECT WRITE
+##===----------------------------------------------------------------------===##
+
+[test]
+name: indirect write 0
+kernel_name: stack_array_indirect_read
+arg_out: 0 buffer int3[2] 4 5 6 7 8 9
+arg_in:  1 buffer int[2] 0 1
+
+[test]
+name: indirect write 1
+kernel_name: stack_array_indirect_read
+arg_out: 0 buffer int3[2] 7 8 9 4 5 6
+arg_in:  1 buffer int[2] 1 0
+
+
+!*/
+
+kernel void stack_array_indirect_read(global int3* out, global int *in) {
+	int3 stack[2];
+	stack[0].s0 = 4;
+	stack[0].s1 = 5;
+	stack[0].s2 = 6;
+	stack[1].s0 = 7;
+	stack[1].s1 = 8;
+	stack[1].s2 = 9;
+
+	out[0] = stack[in[0]];
+	out[1] = stack[in[1]];
+}
+
+kernel void stack_array_indirect_write(global int3* out, global int *in) {
+	int3 stack[2];
+	stack[in[0]].s0 = 4;
+	stack[in[0]].s1 = 5;
+	stack[in[0]].s2 = 6;
+	stack[in[1]].s0 = 7;
+	stack[in[1]].s1 = 8;
+	stack[in[1]].s2 = 9;
+
+	out[0] = stack[0];
+	out[1] = stack[1];
+}
diff --git a/tests/cl/program/execute/v3i32-stack.cl b/tests/cl/program/execute/v3i32-stack.cl
new file mode 100644
index 0000000..7c88979
--- /dev/null
+++ b/tests/cl/program/execute/v3i32-stack.cl
@@ -0,0 +1,29 @@
+/*!
+[config]
+
+[test]
+kernel_name: direct_write_indirect_read
+name: direct write - indirect read
+arg_out: 0 buffer int3[1] 0 1 2
+arg_in:  1 int 0
+
+[test]
+kernel_name: direct_write_indirect_read
+name: direct write - indirect read
+arg_out: 0 buffer int3[1] 3 4 5
+arg_in:  1 int 1
+!*/
+
+kernel void direct_write_indirect_read(global int3 *out, int index) {
+
+	int3 stack[2];
+	stack[0].s0 = 0;
+	stack[0].s1 = 1;
+	stack[0].s2 = 2;
+
+	stack[1].s0 = 3;
+	stack[1].s1 = 4;
+	stack[1].s2 = 5;
+
+	out[0] = stack[index];
+}
diff --git a/tests/cl/program/execute/v4i32-stack.cl b/tests/cl/program/execute/v4i32-stack.cl
new file mode 100644
index 0000000..751a370
--- /dev/null
+++ b/tests/cl/program/execute/v4i32-stack.cl
@@ -0,0 +1,31 @@
+/*!
+[config]
+
+[test]
+kernel_name: direct_write_indirect_read
+name: direct write - indirect read
+arg_out: 0 buffer int4[1] 0 1 2 3
+arg_in:  1 int 0
+
+[test]
+kernel_name: direct_write_indirect_read
+name: direct write - indirect read
+arg_out: 0 buffer int4[1] 4 5 6 7
+arg_in:  1 int 1
+!*/
+
+kernel void direct_write_indirect_read(global int4 *out, int index) {
+
+	int4 stack[2];
+	stack[0].s0 = 0;
+	stack[0].s1 = 1;
+	stack[0].s2 = 2;
+	stack[0].s3 = 3;
+
+	stack[1].s0 = 4;
+	stack[1].s1 = 5;
+	stack[1].s2 = 6;
+	stack[1].s3 = 7;
+
+	out[0] = stack[index];
+}
-- 
1.7.11.4



More information about the Piglit mailing list