[Piglit] [PATCH 2/7] piglit-cl-util: Add a helper for getting the alignment of vector types
Tom Stellard
tom at stellard.net
Mon Sep 30 07:47:41 PDT 2013
From: Tom Stellard <thomas.stellard at amd.com>
---
tests/cl/program/program-tester.c | 2 +-
tests/util/piglit-util-cl.c | 13 +++++++++++++
tests/util/piglit-util-cl.h | 6 ++++++
3 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/tests/cl/program/program-tester.c b/tests/cl/program/program-tester.c
index 1524db0..0071c2e 100644
--- a/tests/cl/program/program-tester.c
+++ b/tests/cl/program/program-tester.c
@@ -969,7 +969,7 @@ get_test_arg(const char* src, struct test* test, bool arg_in)
char* type_size_str;
regex_get_str(&type_size_str, type, "[[:digit:]]+", 0, REG_NEWLINE);
test_arg.vec_elements = get_int(type_size_str);
- test_arg.vec_mem_elements = test_arg.vec_elements != 3 ? test_arg.vec_elements : 4; // test if we have type3
+ test_arg.vec_mem_elements = piglit_cl_get_num_mem_elements(test_arg.vec_elements);
free(type_size_str);
} else {
test_arg.vec_elements = 1;
diff --git a/tests/util/piglit-util-cl.c b/tests/util/piglit-util-cl.c
index 5b4267f..85c7a5d 100644
--- a/tests/util/piglit-util-cl.c
+++ b/tests/util/piglit-util-cl.c
@@ -25,6 +25,19 @@
#include "piglit-util-cl.h"
+unsigned
+piglit_cl_get_num_mem_elements(unsigned num_elements)
+{
+ /* The OpenCL spec requires that vec3 types use the same alignement
+ * as vec4 types.
+ */
+ if (num_elements == 3) {
+ return 4;
+ } else {
+ return num_elements;
+ }
+}
+
bool
piglit_cl_probe_integer(int64_t value, int64_t expect, uint64_t tolerance)
{
diff --git a/tests/util/piglit-util-cl.h b/tests/util/piglit-util-cl.h
index 90d0cd2..c017495 100644
--- a/tests/util/piglit-util-cl.h
+++ b/tests/util/piglit-util-cl.h
@@ -44,6 +44,12 @@
extern "C" {
#endif
+/**
+ * \returns The number of elements this vector type has when stored in memory.
+ * The value returned the alignment in memory of the vector in units of
+ * vector elements.
+ */
+unsigned piglit_cl_get_num_mem_elements(unsigned num_elements);
/* Runtime independent */
--
1.7.11.4
More information about the Piglit
mailing list