[Piglit] [PATCH] CL: Fix check of ULP when probing float/double results

Aaron Watry awatry at gmail.com
Sat Jun 13 12:28:22 PDT 2015


We need to actually check against the float value from the union,
instead of just doing (diff > ulp), which seems to cast the diff to
an int before checking against ulp.

Signed-off-by: Aaron Watry <awatry at gmail.com>
CC: Tom Stellard <thomas.stellard at amd.com>
CC: Jan Vesely <jan.vesely at rutgers.edu>
---
 tests/util/piglit-util-cl.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/tests/util/piglit-util-cl.c b/tests/util/piglit-util-cl.c
index 47e0c7a..6cdd718 100644
--- a/tests/util/piglit-util-cl.c
+++ b/tests/util/piglit-util-cl.c
@@ -80,7 +80,7 @@ piglit_cl_probe_floating(float value, float expect,  uint32_t ulp)
 
 	diff = fabsf(value - expect);
 
-	if(diff > ulp || isnan(value)) {
+	if (diff > t.f || isnan(value)) {
 		printf("Expecting %f (0x%x) with tolerance %f (%u ulps), but got %f (0x%x)\n",
 		       e.f, e.u, t.f, t.u, v.f, v.u);
 		return false;
@@ -108,7 +108,7 @@ piglit_cl_probe_double(double value, double expect, uint64_t ulp)
 
 	diff = fabsl(value - expect);
 
-	if(diff > ulp || isnan(value)) {
+	if (diff > t.f || isnan(value)) {
 		printf("Expecting %f (0x%lx) with tolerance %f (%lu ulps), but got %f (0x%lx)\n",
 		       e.f, e.u, t.f, t.u, v.f, v.u);
 		return false;
@@ -162,7 +162,7 @@ piglit_cl_get_platform_version(cl_platform_id platform)
 	int scanf_count;
 	int major;
 	int minor;
-	
+
 	/*
 	 * Returned format:
 	 *   OpenCL<space><major_version.minor_version><space><platform-specific information>
@@ -353,7 +353,7 @@ piglit_cl_get_info(void* fn_ptr, void* obj, cl_uint param)
 
 	if(errNo == CL_SUCCESS) {
 		param_ptr = calloc(param_size, sizeof(char));
-		
+
 		/* retrieve param */
 		if(fn_ptr == clGetPlatformInfo) {
 			errNo = clGetPlatformInfo(*(cl_platform_id*)obj, param,
@@ -463,7 +463,7 @@ piglit_cl_get_program_build_info(cl_program program, cl_device_id device,
 		.program = program,
 		.device = device
 	};
-	
+
 	return piglit_cl_get_info(clGetProgramBuildInfo, &args, param);
 }
 
@@ -479,7 +479,7 @@ piglit_cl_get_kernel_work_group_info(cl_kernel kernel, cl_device_id device,
 		.kernel = kernel,
 		.device = device
 	};
-	
+
 	return piglit_cl_get_info(clGetKernelWorkGroupInfo, &args, param);
 }
 
@@ -620,7 +620,7 @@ piglit_cl_get_device_ids(cl_platform_id platform_id, cl_device_type device_type,
 				        piglit_cl_get_error_name(errNo));
 				return 0;
 			}
-		
+
 			/* get device list */
 			if(device_ids != NULL && num_device_ids > 0) {
 				*device_ids = malloc(num_device_ids * sizeof(cl_device_id));
@@ -761,7 +761,7 @@ piglit_cl_build_program_with_source_extended(piglit_cl_context context,
 		        piglit_cl_get_error_name(errNo));
 		return NULL;
 	}
-	
+
 	errNo = clBuildProgram(program,
 	                       context->num_devices,
 	                       context->device_ids,
@@ -788,7 +788,7 @@ piglit_cl_build_program_with_source_extended(piglit_cl_context context,
 			char* log = piglit_cl_get_program_build_info(program,
 			                                             context->device_ids[i],
 			                                             CL_PROGRAM_BUILD_LOG);
-			
+
 			printf("Build log for device %s:\n -------- \n%s\n -------- \n",
 			       device_name,
 			       log);
@@ -848,11 +848,11 @@ piglit_cl_build_program_with_binary_extended(piglit_cl_context context,
 		for(i = 0; i < context->num_devices; i++) {
 			char* device_name = piglit_cl_get_device_info(context->device_ids[i],
 			                                              CL_DEVICE_NAME);
-			
+
 			printf("Error for %s: %s\n",
 			       device_name,
 			       piglit_cl_get_error_name(binary_status[i]));
-			
+
 			free(device_name);
 		}
 
@@ -860,7 +860,7 @@ piglit_cl_build_program_with_binary_extended(piglit_cl_context context,
 		return NULL;
 	}
 	free(binary_status);
-	
+
 	errNo = clBuildProgram(program,
 	                       context->num_devices,
 	                       context->device_ids,
@@ -884,11 +884,11 @@ piglit_cl_build_program_with_binary_extended(piglit_cl_context context,
 			char* log = piglit_cl_get_program_build_info(program,
 			                                             context->device_ids[i],
 			                                             CL_PROGRAM_BUILD_LOG);
-			
+
 			printf("Build log for device %s:\n -------- \n%s\n -------- \n",
 			       device_name,
 			       log);
-			
+
 			free(device_name);
 			free(log);
 		}
-- 
2.1.4



More information about the Piglit mailing list