[Piglit] [PATCH] cl 2.0: Add to_global tests
Meng Mengmeng
mengmeng.meng at intel.com
Thu Jul 2 08:57:47 PDT 2015
cl 2.0 spec adds address space qualifier function: to_global, to_local,to_private, get_fence.
It's to_global function test.
---
tests/cl.py | 3 +
.../address_space_qualifier_to_global-2.0.cl | 65 ++++++++++++++++++++++
2 files changed, 68 insertions(+)
create mode 100644 tests/cl/program/execute/builtin/address_space_qualifier/address_space_qualifier_to_global-2.0.cl
diff --git a/tests/cl.py b/tests/cl.py
index c55d3dd..ebab384 100644
--- a/tests/cl.py
+++ b/tests/cl.py
@@ -116,6 +116,9 @@ add_program_test_dir(grouptools.join('program', 'execute'),
add_program_test_dir(grouptools.join('program', 'execute'),
os.path.join(TESTS_DIR, 'cl', 'program', 'execute',
'builtin', 'convert'))
+add_program_test_dir(grouptools.join('program', 'execute'),
+ os.path.join(TESTS_DIR, 'cl', 'program', 'execute',
+ 'builtin', 'address_space_qualifier'))
# Run generated built-in tests
add_program_test_dir(grouptools.join('program', 'execute', 'builtin'),
diff --git a/tests/cl/program/execute/builtin/address_space_qualifier/address_space_qualifier_to_global-2.0.cl b/tests/cl/program/execute/builtin/address_space_qualifier/address_space_qualifier_to_global-2.0.cl
new file mode 100644
index 0000000..814b1aa
--- /dev/null
+++ b/tests/cl/program/execute/builtin/address_space_qualifier/address_space_qualifier_to_global-2.0.cl
@@ -0,0 +1,65 @@
+/*!
+[config]
+name: Test to_global built-in on CL 2.0
+clc_version_min: 20
+dimensions: 1
+
+[test]
+name: to_global test scalar
+kernel_name: test_1_to_global
+global_size: 1 0 0
+arg_out: 0 buffer int[1] 0
+arg_in: 1 buffer int[1] 0
+
+[test]
+name: to_global test struct
+kernel_name: test_2_to_global
+global_size: 1 0 0
+arg_out: 0 buffer int[1] 0
+arg_in: 1 buffer int[1] 0
+!*/
+__kernel void test_1_to_global(__global int* out, __global int* in0){
+ __local float lfloat;
+ lfloat = 0.0;
+ char pchar = '0';
+
+ int failures = 0;
+ if (to_global(&in0[get_global_id(0)]) == NULL)
+ failures++;
+ if (to_global(&lfloat) != NULL)
+ failures++;
+ if (to_global(&pchar) != NULL)
+ failures++;
+
+ out[get_global_id(0)] = failures;
+}
+
+__kernel void test_2_to_global(__global int* out, __global int* in0){
+ __local int lint;
+ lint = 0;
+ int pint = 0;
+
+ typedef struct {
+ int * a;
+ } T;
+
+ __global T * g_struct;
+ g_struct.a = &in0[get_global_id(0)];
+
+ __local T * l_struct;
+ l_struct.a = &lint;
+
+ __private T * p_struct;
+ p_struct.a = &pint;
+
+ int failures = 0;
+ if (to_global(g_struct.a) == NULL)
+ failures++;
+ if (to_global(l_struct.a) != NULL)
+ failures++;
+ if (to_global(p_struct.a) != NULL)
+ failures++;
+
+ out[get_global_id(0)] = failures;
+}
+
--
1.9.1
More information about the Piglit
mailing list