<div dir="ltr"><div><div><div><div>Hi Jan/Tom,<br><br></div>Sorry to resurrect an ancient thread, but I was poking at the piglit CL ULP issue last night, and thought I'd try to get us closer to a solution after dropping the matter for too long.<br><br></div>I've modified your test program with what I was thinking of trying, and I wouldn't mind your feedback.<br><br></div>I realize that we still have issues with discrepancies between python-generated expected results based on cpu/rounding mode and the , but I'd at least like for us to be able to nail down the C portion before we start redefining all of our expected test results.  In the long term, we probably want to hand-select our inputs/outputs instead of trusting python, but I don't necessarily think that we should block fixing our ULP calculations on getting that done.<br><br></div><div>For now, I'm still ignoring the half-ULP possibility, and just generating a minimum/maximum allowed value based on running nextafterf(expected, POS/NEG INFINITY) in a loop for ULP iterations. Does that sound like a tenable solution?<br></div><div><br></div>--Aaron<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Jun 14, 2015 at 4:19 PM, Jan Vesely <span dir="ltr"><<a href="mailto:jan.vesely@rutgers.edu" target="_blank">jan.vesely@rutgers.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Sat, 2015-06-13 at 21:22 -0500, Aaron Watry wrote:<br>
> Meh, this still feels broken.  Give me a bit longer.<br>
<br>
</span>and it is :). I don't think this can work based on abs(expected - real),<br>
since ULP depends on the magnitude of the numbers. This information is<br>
lost after subtraction.<br>
<br>
I had an idea some time back to implement this using nextafterf in both<br>
directions and checking whether the result falls in that interval.<br>
However, there is still a problem. Some of the expected values are<br>
already rounded (I'm not sure what rounding mode is used by python by<br>
default), but unless it always rounds in one direction, we'll still get<br>
slight differences based on whether the actual value was rounded up or<br>
down.<br>
<br>
I have attached a small test program that shows the deficiencies of<br>
fabsf based approaches.<br>
<br>
regards,<br>
Jan<br>
<div class="HOEnZb"><div class="h5"><br>
><br>
> --Aaron<br>
><br>
> On Sat, Jun 13, 2015 at 2:28 PM, Aaron Watry <<a href="mailto:awatry@gmail.com">awatry@gmail.com</a>> wrote:<br>
><br>
> > We need to actually check against the float value from the union,<br>
> > instead of just doing (diff > ulp), which seems to cast the diff to<br>
> > an int before checking against ulp.<br>
> ><br>
> > Signed-off-by: Aaron Watry <<a href="mailto:awatry@gmail.com">awatry@gmail.com</a>><br>
> > CC: Tom Stellard <<a href="mailto:thomas.stellard@amd.com">thomas.stellard@amd.com</a>><br>
> > CC: Jan Vesely <<a href="mailto:jan.vesely@rutgers.edu">jan.vesely@rutgers.edu</a>><br>
> > ---<br>
> >  tests/util/piglit-util-cl.c | 28 ++++++++++++++--------------<br>
> >  1 file changed, 14 insertions(+), 14 deletions(-)<br>
> ><br>
> > diff --git a/tests/util/piglit-util-cl.c b/tests/util/piglit-util-cl.c<br>
> > index 47e0c7a..6cdd718 100644<br>
> > --- a/tests/util/piglit-util-cl.c<br>
> > +++ b/tests/util/piglit-util-cl.c<br>
> > @@ -80,7 +80,7 @@ piglit_cl_probe_floating(float value, float expect,<br>
> > uint32_t ulp)<br>
> ><br>
> >         diff = fabsf(value - expect);<br>
> ><br>
> > -       if(diff > ulp || isnan(value)) {<br>
> > +       if (diff > t.f || isnan(value)) {<br>
> >                 printf("Expecting %f (0x%x) with tolerance %f (%u ulps),<br>
> > but got %f (0x%x)\n",<br>
> >                        e.f, e.u, t.f, t.u, v.f, v.u);<br>
> >                 return false;<br>
> > @@ -108,7 +108,7 @@ piglit_cl_probe_double(double value, double expect,<br>
> > uint64_t ulp)<br>
> ><br>
> >         diff = fabsl(value - expect);<br>
> ><br>
> > -       if(diff > ulp || isnan(value)) {<br>
> > +       if (diff > t.f || isnan(value)) {<br>
> >                 printf("Expecting %f (0x%lx) with tolerance %f (%lu ulps),<br>
> > but got %f (0x%lx)\n",<br>
> >                        e.f, e.u, t.f, t.u, v.f, v.u);<br>
> >                 return false;<br>
> > @@ -162,7 +162,7 @@ piglit_cl_get_platform_version(cl_platform_id platform)<br>
> >         int scanf_count;<br>
> >         int major;<br>
> >         int minor;<br>
> > -<br>
> > +<br>
> >         /*<br>
> >          * Returned format:<br>
> >          *<br>
> >  OpenCL<space><major_version.minor_version><space><platform-specific<br>
> > information><br>
> > @@ -353,7 +353,7 @@ piglit_cl_get_info(void* fn_ptr, void* obj, cl_uint<br>
> > param)<br>
> ><br>
> >         if(errNo == CL_SUCCESS) {<br>
> >                 param_ptr = calloc(param_size, sizeof(char));<br>
> > -<br>
> > +<br>
> >                 /* retrieve param */<br>
> >                 if(fn_ptr == clGetPlatformInfo) {<br>
> >                         errNo = clGetPlatformInfo(*(cl_platform_id*)obj,<br>
> > param,<br>
> > @@ -463,7 +463,7 @@ piglit_cl_get_program_build_info(cl_program program,<br>
> > cl_device_id device,<br>
> >                 .program = program,<br>
> >                 .device = device<br>
> >         };<br>
> > -<br>
> > +<br>
> >         return piglit_cl_get_info(clGetProgramBuildInfo, &args, param);<br>
> >  }<br>
> ><br>
> > @@ -479,7 +479,7 @@ piglit_cl_get_kernel_work_group_info(cl_kernel kernel,<br>
> > cl_device_id device,<br>
> >                 .kernel = kernel,<br>
> >                 .device = device<br>
> >         };<br>
> > -<br>
> > +<br>
> >         return piglit_cl_get_info(clGetKernelWorkGroupInfo, &args, param);<br>
> >  }<br>
> ><br>
> > @@ -620,7 +620,7 @@ piglit_cl_get_device_ids(cl_platform_id platform_id,<br>
> > cl_device_type device_type,<br>
> >                                         piglit_cl_get_error_name(errNo));<br>
> >                                 return 0;<br>
> >                         }<br>
> > -<br>
> > +<br>
> >                         /* get device list */<br>
> >                         if(device_ids != NULL && num_device_ids > 0) {<br>
> >                                 *device_ids = malloc(num_device_ids *<br>
> > sizeof(cl_device_id));<br>
> > @@ -761,7 +761,7 @@<br>
> > piglit_cl_build_program_with_source_extended(piglit_cl_context context,<br>
> >                         piglit_cl_get_error_name(errNo));<br>
> >                 return NULL;<br>
> >         }<br>
> > -<br>
> > +<br>
> >         errNo = clBuildProgram(program,<br>
> >                                context->num_devices,<br>
> >                                context->device_ids,<br>
> > @@ -788,7 +788,7 @@<br>
> > piglit_cl_build_program_with_source_extended(piglit_cl_context context,<br>
> >                         char* log =<br>
> > piglit_cl_get_program_build_info(program,<br>
> ><br>
> >  context->device_ids[i],<br>
> ><br>
> >  CL_PROGRAM_BUILD_LOG);<br>
> > -<br>
> > +<br>
> >                         printf("Build log for device %s:\n -------- \n%s\n<br>
> > -------- \n",<br>
> >                                device_name,<br>
> >                                log);<br>
> > @@ -848,11 +848,11 @@<br>
> > piglit_cl_build_program_with_binary_extended(piglit_cl_context context,<br>
> >                 for(i = 0; i < context->num_devices; i++) {<br>
> >                         char* device_name =<br>
> > piglit_cl_get_device_info(context->device_ids[i],<br>
> ><br>
> > CL_DEVICE_NAME);<br>
> > -<br>
> > +<br>
> >                         printf("Error for %s: %s\n",<br>
> >                                device_name,<br>
> >                                piglit_cl_get_error_name(binary_status[i]));<br>
> > -<br>
> > +<br>
> >                         free(device_name);<br>
> >                 }<br>
> ><br>
> > @@ -860,7 +860,7 @@<br>
> > piglit_cl_build_program_with_binary_extended(piglit_cl_context context,<br>
> >                 return NULL;<br>
> >         }<br>
> >         free(binary_status);<br>
> > -<br>
> > +<br>
> >         errNo = clBuildProgram(program,<br>
> >                                context->num_devices,<br>
> >                                context->device_ids,<br>
> > @@ -884,11 +884,11 @@<br>
> > piglit_cl_build_program_with_binary_extended(piglit_cl_context context,<br>
> >                         char* log =<br>
> > piglit_cl_get_program_build_info(program,<br>
> ><br>
> >  context->device_ids[i],<br>
> ><br>
> >  CL_PROGRAM_BUILD_LOG);<br>
> > -<br>
> > +<br>
> >                         printf("Build log for device %s:\n -------- \n%s\n<br>
> > -------- \n",<br>
> >                                device_name,<br>
> >                                log);<br>
> > -<br>
> > +<br>
> >                         free(device_name);<br>
> >                         free(log);<br>
> >                 }<br>
> > --<br>
> > 2.1.4<br>
> ><br>
> ><br>
<br>
<br>
</div></div><span class="HOEnZb"><font color="#888888">--<br>
Jan Vesely <<a href="mailto:jan.vesely@rutgers.edu">jan.vesely@rutgers.edu</a>><br>
</font></span></blockquote></div><br></div>