[Piglit] [PATCH 1/7] cl-program-tester: Use more appropriate member names for struct test_arg

Tom Stellard tom at stellard.net
Mon Sep 30 07:47:40 PDT 2013


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

cl_size has been renamed to vec_elements and cl_mem_size has been
renamed to vec_mem_elements.  This use of size is confusing, because
size generally means number of bytes when used to describe a type, and
in this case the value being stored was the number of elements in the
vector.
---
 tests/cl/program/program-tester.c | 48 +++++++++++++++++++--------------------
 1 file changed, 24 insertions(+), 24 deletions(-)

diff --git a/tests/cl/program/program-tester.c b/tests/cl/program/program-tester.c
index be6bc20..1524db0 100644
--- a/tests/cl/program/program-tester.c
+++ b/tests/cl/program/program-tester.c
@@ -216,8 +216,8 @@ struct test_arg {
 	enum test_arg_type type;
 
 	enum cl_type cl_type;
-	size_t cl_size; // 1 for int, 3 for int3
-	size_t cl_mem_size; // 1 for int, 4 for int3
+	size_t vec_elements; // 1 for int, 3 for int3
+	size_t vec_mem_elements; // 1 for int, 4 for int3
 	size_t length; // for buffers
 
 	/* kernel arg data */
@@ -237,8 +237,8 @@ struct test_arg create_test_arg()
 		.type = TEST_ARG_VALUE,
 
 		.cl_type = TYPE_CHAR,
-		.cl_size = 1,
-		.cl_mem_size = 1,
+		.vec_elements = 1,
+		.vec_mem_elements = 1,
 		.length = 0,
 
 		.index = 0,
@@ -868,9 +868,9 @@ get_test_arg_value(struct test_arg* test_arg, const char* value, size_t length)
 	case enum_type:                                                 \
 		get_func(value, &array, length);                            \
 		for(i = 0; i < test_arg->length; i++) {                     \
-			for(c = 0; c < test_arg->cl_size; c++) {                \
-				ra = i*test_arg->cl_size + c;                       \
-				rb = i*test_arg->cl_mem_size + c;                   \
+			for(c = 0; c < test_arg->vec_elements; c++) {                \
+				ra = i*test_arg->vec_elements + c;                       \
+				rb = i*test_arg->vec_mem_elements + c;                   \
 				((cl_type*)test_arg->value)[rb] = array[ra%length]; \
 			}                                                       \
 		}                                                           \
@@ -963,23 +963,23 @@ get_test_arg(const char* src, struct test* test, bool arg_in)
 	test_arg.index = get_int(index_str);
 	free(index_str);
 
-	/* Set type, cl_size, cl_mem_size and size (partially for buffers) */
+	/* Set type, vec_elements, vec_mem_elements and size (partially for buffers) */
 	regex_get_match_str(&type, src, pmatch, 2);
 	if(regex_match(type, "[[:digit:]]+")) {
 		char* type_size_str;
 		regex_get_str(&type_size_str, type, "[[:digit:]]+", 0, REG_NEWLINE);
-		test_arg.cl_size = get_int(type_size_str);
-		test_arg.cl_mem_size = test_arg.cl_size != 3 ? test_arg.cl_size : 4; // test if we have type3
+		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
 		free(type_size_str);
 	} else {
-		test_arg.cl_size = 1;
-		test_arg.cl_mem_size = 1;
+		test_arg.vec_elements = 1;
+		test_arg.vec_mem_elements = 1;
 	}
 
 #define IF(regex_type, enum_type, main_type)                       \
 	if(regex_match(type, REGEX_FULL_MATCH(regex_type))) {          \
 		test_arg.cl_type = enum_type;                              \
-		test_arg.size = sizeof(main_type) * test_arg.cl_mem_size;  \
+		test_arg.size = sizeof(main_type) * test_arg.vec_mem_elements;  \
 	}
 #define ELSEIF(regex_type, enum_type, main_type) \
 	else IF(regex_type, enum_type, main_type)
@@ -1020,7 +1020,7 @@ get_test_arg(const char* src, struct test* test, bool arg_in)
 		if(regex_match(value, REGEX_FULL_MATCH(REGEX_NULL))) {
 			test_arg.value = NULL;
 		} else {
-			get_test_arg_value(&test_arg, value, test_arg.cl_size);
+			get_test_arg_value(&test_arg, value, test_arg.vec_elements);
 		}
 		free(value);
 	} else if(regex_match(src, REGEX_FULL_MATCH(REGEX_ARG_BUFFER))) { // buffer
@@ -1084,7 +1084,7 @@ get_test_arg(const char* src, struct test* test, bool arg_in)
 			} else if(regex_match(value, REGEX_ARRAY)) {
 				get_test_arg_value(&test_arg,
 				                   value,
-				                   test_arg.length * test_arg.cl_size);
+				                   test_arg.length * test_arg.vec_elements);
 			}
 		}
 		free(value);
@@ -1623,12 +1623,12 @@ check_test_arg_value(struct test_arg test_arg,
 #define CASEI(enum_type, type, cl_type)                                     \
 	case enum_type:                                                         \
 		for(i = 0; i < test_arg.length; i++) {                              \
-			for(c = 0; c < test_arg.cl_size; c++) {                         \
-				rb = i*test_arg.cl_mem_size + c;                            \
+			for(c = 0; c < test_arg.vec_elements; c++) {                         \
+				rb = i*test_arg.vec_mem_elements + c;                            \
 				if(!piglit_cl_probe_integer(((cl_type*)value)[rb],          \
 				                            ((cl_type*)test_arg.value)[rb], \
 				                            test_arg.toli)) {               \
-					ra = i*test_arg.cl_size + c;                            \
+					ra = i*test_arg.vec_elements + c;                            \
 					printf("Error at %s[%zu]\n", type, ra);                 \
 					return false;                                           \
 				}                                                           \
@@ -1638,12 +1638,12 @@ check_test_arg_value(struct test_arg test_arg,
 #define CASEU(enum_type, type, cl_type)                                      \
 	case enum_type:                                                          \
 		for(i = 0; i < test_arg.length; i++) {                               \
-			for(c = 0; c < test_arg.cl_size; c++) {                          \
-				rb = i*test_arg.cl_mem_size + c;                             \
+			for(c = 0; c < test_arg.vec_elements; c++) {                          \
+				rb = i*test_arg.vec_mem_elements + c;                             \
 				if(!piglit_cl_probe_uinteger(((cl_type*)value)[rb],          \
 				                             ((cl_type*)test_arg.value)[rb], \
 				                             test_arg.tolu)) {               \
-					ra = i*test_arg.cl_size + c;                             \
+					ra = i*test_arg.vec_elements + c;                             \
 					printf("Error at %s[%zu]\n", type, ra);                  \
 					return false;                                            \
 				}                                                            \
@@ -1653,12 +1653,12 @@ check_test_arg_value(struct test_arg test_arg,
 #define CASEF(enum_type, type, cl_type)                                      \
 	case enum_type:                                                          \
 		for(i = 0; i < test_arg.length; i++) {                               \
-			for(c = 0; c < test_arg.cl_size; c++) {                          \
-				rb = i*test_arg.cl_mem_size + c;                             \
+			for(c = 0; c < test_arg.vec_elements; c++) {                          \
+				rb = i*test_arg.vec_mem_elements + c;                             \
 				if(!piglit_cl_probe_floating(((cl_type*)value)[rb],          \
 				                             ((cl_type*)test_arg.value)[rb], \
 				                             test_arg.tolf)) {               \
-					ra = i*test_arg.cl_size + c;                             \
+					ra = i*test_arg.vec_elements + c;                             \
 					printf("Error at %s[%zu]\n", type, ra);                  \
 					return false;                                            \
 				}                                                            \
-- 
1.7.11.4



More information about the Piglit mailing list