[Piglit] [PATCH] cl: Update integer/long limit tests to detect incorrect storage sizes

Jan Vesely jan.vesely at rutgers.edu
Sat Oct 3 13:47:10 PDT 2015


On Fri, 2015-10-02 at 10:32 -0500, Aaron Watry wrote:
> The tests for the integer/long minimums do not properly
> check that the value is stored in the correct type.
> E.g. (-2147483648) actually gets parsed as a long by the
> preprocessor,
> and therefore INT_MIN is actually stored as long and can't be
> automatically
> vectorized.
> 
> By subtracting a vector with value of 0 from the given defined *_MIN
> and then grabbing the first element of the resulting vector, we can
> make sure that the values are actually stored in the correct type.
> 
> v2: Remove char/short modifications.
>     Test *_MAX vectorization as well as _MIN for int/long
> 
> CC: Jan Vesely <jan.vesely at rutgers.edu>
> Reported-By: Moritz Pflanzer <moritz.pflanzer14 at imperial.ac.uk>
> Signed-off-by: Aaron Watry <awatry at gmail.com>

I'm still not 100% convinced this is a hard requirement, but using
(xxxxx -1) form in the specs clearly shows the intent.

Reviewed-by: Jan Vesely <jan.vesely at rutgers.edu>

Jan

> ---
>  tests/cl/program/execute/int-definitions.cl | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/tests/cl/program/execute/int-definitions.cl
> b/tests/cl/program/execute/int-definitions.cl
> index 011599d..75ce2ed 100644
> --- a/tests/cl/program/execute/int-definitions.cl
> +++ b/tests/cl/program/execute/int-definitions.cl
> @@ -51,14 +51,14 @@ kernel void test_short(global int* out) {
>  
>  kernel void test_int(global int* out) {
>    int i = 0;
> -  out[i++] = INT_MAX;
> -  out[i++] = INT_MIN;
> -  out[i++] = UINT_MAX;
> +  out[i++] = (INT_MAX - (int2)(0)).s0;
> +  out[i++] = (INT_MIN - (int2)(0)).s0;
> +  out[i++] = (UINT_MAX - (uint2)(0)).s0;
>  }
>  
>  kernel void test_long(global long* out) {
>    int i = 0;
> -  out[i++] = LONG_MAX;
> -  out[i++] = LONG_MIN;
> -  out[i++] = ULONG_MAX;
> +  out[i++] = (LONG_MAX - (long2)(0)).s0;
> +  out[i++] = (LONG_MIN - (long2)(0)).s0;
> +  out[i++] = (ULONG_MAX - (ulong2)(0)).s0;
>  }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20151003/f6e6d759/attachment.sig>


More information about the Piglit mailing list