[Piglit] [PATCH] Replace CL kernel names to not use C++ reserved words.

Aaron Watry awatry at gmail.com
Mon Nov 26 16:43:54 PST 2012


On Mon, Nov 26, 2012 at 12:29 PM, Tom Stellard <tom at stellard.net> wrote:
> On Sun, Nov 25, 2012 at 09:36:42PM -0600, Aaron Watry wrote:
>> These tests were failing to compile on Nvidia CL runtime on *NIX.
>
> I can't find anything in the OpenCL spec that says these function
> names are illegal.  This looks like a bug in the NVIDIA implementation
> and should be fixed by them.

A bit of follow-up.  Section 6.1.9 of the OpenCL spec (I'm looking at
version 1.1 currently), says:
The following names are reserved for use as keywords in OpenCL C and
shall not be used
otherwise.
- Names reserved as keywords by C99.
- more...

I don't think it necessarily qualifies, but there was an amendment in
1995 to the C90 standard which added and/or/not/xor/others as macros
to the C standard library (iso646.h). It doesn't look like they're
reserved keywords in C99, but they do exist and can be used in
compiled C code after including that header.

I agree that it looks like Nvidia has a bug in their implementation
(they're probably including that header in their CL built-in sources
or something).

I'll see if I can come up with some more tests that check for usage of
reserved words in function/kernel names.

--Aaron

>
> However, since the function names in this test are arbitrary and have
> nothing to do with the execution of the test there is really no practical
> reason to keep the names the same.  The only reason not to change them is
> on the principle of not changing code to work around bugs in OpenCL
> implementations.
>
> In this case, since the function names don't matter I would ACK this patch
> if it was accompanied by additional test cases that try to compile functions
> with C++ reserved words.  Though, I would be interested to hear what some of
> the veteran OpenGL spec enforcers think about this.
>
> -Tom
>
>> ---
>>  tests/cl/program/execute/scalar-logical-float.cl |   24 +++++++++++-----------
>>  tests/cl/program/execute/scalar-logical-int.cl   |   24 +++++++++++-----------
>>  2 files changed, 24 insertions(+), 24 deletions(-)
>>
>> diff --git a/tests/cl/program/execute/scalar-logical-float.cl b/tests/cl/program/execute/scalar-logical-float.cl
>> index ae75bf4..43265d5 100644
>> --- a/tests/cl/program/execute/scalar-logical-float.cl
>> +++ b/tests/cl/program/execute/scalar-logical-float.cl
>> @@ -14,19 +14,19 @@ global_size: 1 0 0
>>
>>  [test]
>>  name: !num
>> -kernel_name: not
>> +kernel_name: test_not
>>  arg_in:  1 float 1.5
>>  arg_out: 0 buffer int[1] 0
>>
>>  [test]
>>  name: !0
>> -kernel_name: not
>> +kernel_name: test_not
>>  arg_in:  1 float 0
>>  arg_out: 0 buffer int[1] 1
>>
>>  [test]
>>  name: !inf
>> -kernel_name: not
>> +kernel_name: test_not
>>  arg_in:  1 float inf
>>  arg_out: 0 buffer int[1] 0
>>
>> @@ -34,21 +34,21 @@ arg_out: 0 buffer int[1] 0
>>
>>  [test]
>>  name: num&&-num
>> -kernel_name: and
>> +kernel_name: test_and
>>  arg_in:  1 float 34.25
>>  arg_in:  2 float -55.125
>>  arg_out: 0 buffer int[1] 1
>>
>>  [test]
>>  name: num&&0
>> -kernel_name: and
>> +kernel_name: test_and
>>  arg_in:  1 float 1.5
>>  arg_in:  2 float 0
>>  arg_out: 0 buffer int[1] 0
>>
>>  [test]
>>  name: 0&&0
>> -kernel_name: and
>> +kernel_name: test_and
>>  arg_in:  1 float 0
>>  arg_in:  2 float 0
>>  arg_out: 0 buffer int[1] 0
>> @@ -57,35 +57,35 @@ arg_out: 0 buffer int[1] 0
>>
>>  [test]
>>  name: num||-num
>> -kernel_name: or
>> +kernel_name: test_or
>>  arg_in:  1 float 14.3
>>  arg_in:  2 float -34.1
>>  arg_out: 0 buffer int[1] 1
>>
>>  [test]
>>  name: num||0
>> -kernel_name: or
>> +kernel_name: test_or
>>  arg_in:  1 float 45.3
>>  arg_in:  2 float 0
>>  arg_out: 0 buffer int[1] 1
>>
>>  [test]
>>  name: 0||0
>> -kernel_name: or
>> +kernel_name: test_or
>>  arg_in:  1 float 0
>>  arg_in:  2 float 0
>>  arg_out: 0 buffer int[1] 0
>>
>>  !*/
>>
>> -kernel void not(global int* out, float in) {
>> +kernel void test_not(global int* out, float in) {
>>       out[0] = !in;
>>  }
>>
>> -kernel void and(global int* out, float a, float b) {
>> +kernel void test_and(global int* out, float a, float b) {
>>       out[0] = a && b;
>>  }
>>
>> -kernel void or(global int* out, float a, float b) {
>> +kernel void test_or(global int* out, float a, float b) {
>>       out[0] = a || b;
>>  }
>> diff --git a/tests/cl/program/execute/scalar-logical-int.cl b/tests/cl/program/execute/scalar-logical-int.cl
>> index f09eb0b..303bd5b 100644
>> --- a/tests/cl/program/execute/scalar-logical-int.cl
>> +++ b/tests/cl/program/execute/scalar-logical-int.cl
>> @@ -14,19 +14,19 @@ global_size: 1 0 0
>>
>>  [test]
>>  name: !true
>> -kernel_name: not
>> +kernel_name: test_not
>>  arg_in:  1 int 1
>>  arg_out: 0 buffer int[1] 0
>>
>>  [test]
>>  name: !false
>> -kernel_name: not
>> +kernel_name: test_not
>>  arg_in:  1 int 0
>>  arg_out: 0 buffer int[1] 1
>>
>>  [test]
>>  name: !big_num
>> -kernel_name: not
>> +kernel_name: test_not
>>  arg_in:  1 int 3452
>>  arg_out: 0 buffer int[1] 0
>>
>> @@ -34,21 +34,21 @@ arg_out: 0 buffer int[1] 0
>>
>>  [test]
>>  name: true&&true
>> -kernel_name: and
>> +kernel_name: test_and
>>  arg_in:  1 int 1
>>  arg_in:  2 int 1
>>  arg_out: 0 buffer int[1] 1
>>
>>  [test]
>>  name: true&&false
>> -kernel_name: and
>> +kernel_name: test_and
>>  arg_in:  1 int 1
>>  arg_in:  2 int 0
>>  arg_out: 0 buffer int[1] 0
>>
>>  [test]
>>  name: false&&false
>> -kernel_name: and
>> +kernel_name: test_and
>>  arg_in:  1 int 0
>>  arg_in:  2 int 0
>>  arg_out: 0 buffer int[1] 0
>> @@ -57,35 +57,35 @@ arg_out: 0 buffer int[1] 0
>>
>>  [test]
>>  name: true||true
>> -kernel_name: or
>> +kernel_name: test_or
>>  arg_in:  1 int 1
>>  arg_in:  2 int 1
>>  arg_out: 0 buffer int[1] 1
>>
>>  [test]
>>  name: true||false
>> -kernel_name: or
>> +kernel_name: test_or
>>  arg_in:  1 int 1
>>  arg_in:  2 int 0
>>  arg_out: 0 buffer int[1] 1
>>
>>  [test]
>>  name: false||false
>> -kernel_name: or
>> +kernel_name: test_or
>>  arg_in:  1 int 0
>>  arg_in:  2 int 0
>>  arg_out: 0 buffer int[1] 0
>>
>>  !*/
>>
>> -kernel void not(global int* out, int in) {
>> +kernel void test_not(global int* out, int in) {
>>       out[0] = !in;
>>  }
>>
>> -kernel void and(global int* out, int a, int b) {
>> +kernel void test_and(global int* out, int a, int b) {
>>       out[0] = a && b;
>>  }
>>
>> -kernel void or(global int* out, int a, int b) {
>> +kernel void test_or(global int* out, int a, int b) {
>>       out[0] = a || b;
>>  }
>> --
>> 1.7.10.4
>>
>> _______________________________________________
>> Piglit mailing list
>> Piglit at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/piglit


More information about the Piglit mailing list