[Piglit] [PATCH 4/7] cl-program-tester: Rename test_arg::size to test_arg::size_in_mem

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


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

The value being stored in this field is actually the size of the argument if
it were to be stored in memory (for a type like int3, its size is 12 bytes,
but its size in memory is 16 bytes per the OpenCL spec).
---
 tests/cl/program/program-tester.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/tests/cl/program/program-tester.c b/tests/cl/program/program-tester.c
index 9cddd9c..ea16c81 100644
--- a/tests/cl/program/program-tester.c
+++ b/tests/cl/program/program-tester.c
@@ -210,7 +210,7 @@ struct test_arg {
 
 	/* kernel arg data */
 	cl_uint index;
-	size_t size;
+	size_t size_in_mem;
 	void* value;
 
 	/* tolerance */
@@ -230,7 +230,7 @@ struct test_arg create_test_arg()
 		.length = 0,
 
 		.index = 0,
-		.size = 0,
+		.size_in_mem = 0,
 		.value = NULL,
 
 		.toli = 0,
@@ -338,12 +338,12 @@ add_test_arg(struct test* t, struct test_arg ta, bool arg_in)
 				        ta.index);
 				return false;
 			}
-			if(ta.size != ta_other.size) {
+			if(ta.size_in_mem != ta_other.size_in_mem) {
 				fprintf(stderr,
 				        "Invalid configuration, Size of in argument (%zu) at index %d isn't the same as size of out argument (%zu)\n",
-				        arg_in ? ta.size : ta_other.size,
+				        arg_in ? ta.size_in_mem : ta_other.size_in_mem,
 				        ta.index,
-				        arg_in ? ta_other.size : ta.size);
+				        arg_in ? ta_other.size_in_mem : ta.size_in_mem);
 				return false;
 			}
 		}
@@ -843,7 +843,7 @@ get_test_arg_value(struct test_arg* test_arg, const char* value, size_t length)
 	uint64_t* uint_array = NULL;
 	double* float_array = NULL;
 
-	test_arg->value = malloc(test_arg->size);
+	test_arg->value = malloc(test_arg->size_in_mem);
 
 	/*
 	 * We fill the buffer with calculating the right offsets in the buffer (rb)
@@ -967,7 +967,7 @@ get_test_arg(const char* src, struct test* test, bool arg_in)
 #define IF(regex_type, enum_type)                       \
 	if(regex_match(type, REGEX_FULL_MATCH(regex_type))) {          \
 		test_arg.cl_type = enum_type;                              \
-		test_arg.size = piglit_cl_type_get_size(enum_type) \
+		test_arg.size_in_mem = piglit_cl_type_get_size(enum_type) \
 					* test_arg.vec_mem_elements;  \
 	}
 #define ELSEIF(regex_type, enum_type) \
@@ -1025,7 +1025,7 @@ get_test_arg(const char* src, struct test* test, bool arg_in)
 		free(array_length_str);
 
 		/* Set size */
-		test_arg.size = test_arg.size * test_arg.length;
+		test_arg.size_in_mem = test_arg.size_in_mem * test_arg.length;
 
 		/* Set tolerance */
 		tolerance_str = src+pmatch[4].rm_eo;
@@ -1051,7 +1051,7 @@ get_test_arg(const char* src, struct test* test, bool arg_in)
 			}
 		} else {
 			if(regex_match(value, REGEX_FULL_MATCH(REGEX_RANDOM))) {
-				test_arg.value = malloc(test_arg.size);
+				test_arg.value = malloc(test_arg.size_in_mem);
 				if(!arg_in) {
 					fprintf(stderr,
 					        "Invalid configuration, out argument buffer can not be random: %s\n",
@@ -1731,7 +1731,7 @@ test_kernel(const struct piglit_cl_program_test_config* config,
 		case TEST_ARG_VALUE:
 			arg_set = piglit_cl_set_kernel_arg(kernel,
 			                                   test_arg.index,
-			                                   test_arg.size,
+			                                   test_arg.size_in_mem,
 			                                   test_arg.value);
 			break;
 		case TEST_ARG_BUFFER: {
@@ -1741,12 +1741,12 @@ test_kernel(const struct piglit_cl_program_test_config* config,
 			if(test_arg.value != NULL) {
 				buffer_arg.buffer = piglit_cl_create_buffer(env->context,
 				                                            CL_MEM_READ_WRITE,
-				                                            test_arg.size);
+				                                            test_arg.size_in_mem);
 				if(   buffer_arg.buffer != NULL
 				   && piglit_cl_write_buffer(env->context->command_queues[0],
 				                             buffer_arg.buffer,
 				                             0,
-				                             test_arg.size,
+				                             test_arg.size_in_mem,
 				                             test_arg.value)
 				   && piglit_cl_set_kernel_arg(kernel,
 				                               buffer_arg.index,
@@ -1805,7 +1805,7 @@ test_kernel(const struct piglit_cl_program_test_config* config,
 			if(test_arg.value != NULL) {
 				buffer_arg.buffer = piglit_cl_create_buffer(env->context,
 				                                            CL_MEM_READ_WRITE,
-				                                            test_arg.size);
+				                                            test_arg.size_in_mem);
 				if(   buffer_arg.buffer != NULL
 				   && piglit_cl_set_kernel_arg(kernel,
 				                               buffer_arg.index,
@@ -1876,12 +1876,12 @@ test_kernel(const struct piglit_cl_program_test_config* config,
 			}
 
 			if(test_arg.value != NULL) {
-				void* read_value = malloc(test_arg.size);
+				void* read_value = malloc(test_arg.size_in_mem);
 
 				if(piglit_cl_read_buffer(env->context->command_queues[0],
 					                     buffer_arg.buffer,
 					                     0,
-					                     test_arg.size,
+					                     test_arg.size_in_mem,
 					                     read_value)) {
 					arg_valid = true;
 					if(check_test_arg_value(test_arg, read_value)) {
-- 
1.7.11.4



More information about the Piglit mailing list