varying TYPE * uniform ptr in exported function

159 views
Skip to first unread message

Brian

unread,
Nov 9, 2020, 5:33:16 PM11/9/20
to Intel SPMD Program Compiler Users

An exported function (at least up to 1.12) happily accepted parameters of the form:

varying TYPE * uniform ptr

I am trying out 1.14.1 and get the following error:

test.ispc:2:19: Warning: Exported
        function parameter "ptr" points
        to varying type
run(varying float * uniform ptr)

From this code:

export void
run(varying float * uniform ptr)
{
}

The code compiles as expected at least up to 1.12.

Is this an expected change?  I didn't see anything about it in the release notes.

Cheers,
-Brian

Deepak Rajendrakumaran

unread,
Nov 9, 2020, 8:36:42 PM11/9/20
to Intel SPMD Program Compiler Users
Hello,


Functionally there is not change but a warning got added. You should still be able to compile and run your code, but it'll print the warning . 'Warning: Exported function parameter "ptr" points to varying type' merely lets the user know they are dealing with a varying type.

-Deepak

Marianna Neubauer

unread,
Jan 13, 2021, 6:22:45 PM1/13/21
to Intel SPMD Program Compiler Users
Hello,

Since uniform pointers to varying types are permitted for an exported function, I don't understand why this warrants a warning. What was the motivation for adding this warning?

Thank you,
Marianna

Pete Brubaker

unread,
Jan 13, 2021, 10:00:43 PM1/13/21
to ispc-...@googlegroups.com
I'm fairly certain this warning was added because varying is the default specifier for types and can possibly confuse people new to the language.  However it doesn't look like it's working as intended.


It looks like pointer parameters on exported functions aren't automatically promoted varying.  However pass by value types are.

Cheers,

Pete



--
You received this message because you are subscribed to the Google Groups "Intel SPMD Program Compiler Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ispc-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ispc-users/3240f3c9-1fc2-462e-b3de-6f07ffc61a93n%40googlegroups.com.

Deepak Rajendrakumaran

unread,
Jan 14, 2021, 12:46:22 AM1/14/21
to ispc-...@googlegroups.com
Hi guys,

If I understand correctly, we are discussing 2 different things here. Feel free to point out and correct me if I understand either incorrectly.

Issue 1 - Reason for warning getting added
This was mainly to avoid confusion for the user since varying is an ISPC feature and generally forbidden from exporting to cpp side outside of exceptions like this. 
We decided to add it, looking at the function signatures created for c-side header files by ispc for varying types and possibility of users finding it confusing. 
Note : To create header to check - ispc <input_file.ispc> -h <header_file.h>

For eg.
Ispc function: export void test2( varying float *uniform src, varying float *uniform dst ) { .. }
exported function signature in Header created : extern void test2(float( * src)[8], float( * dst)[8]);  // the [8] here is because is 8 wide(varying) since i compiled for avx2-i32x8 .
Varying though represented as vectors internally in ispc IR is represented as arrays in headers.


Similarly array
Ispc Function : export void test3(float src[20], float  dst[20])
exported function signature in  Header created : extern void test3(float( * src)[8], float( * dst)[8]); // the [8] here is because is 8 wide(varying) since i compiled for avx2-i32x8.

Reference to compare IR for ISPC and corresponding function signature in header

If you prefer to remove the warning, one option is to use 'pragma ignore warning ' before the function. See perfbench.ispc here - https://github.com/ispc/ispc/commit/761de37d076c64dbf8f74226a3b1f88fcb8fdc1e 

Issue 2 - variability of pointer type

Looking at Pete's code - https://ispc.godbolt.org/z/76dajK

The below excerpt is from the ispc documentation - https://ispc.github.io/ispc.html#pointer-types
'** Like other types in ispc, pointers are varying by default, if an explicit uniform qualifier isn't provided. However, the default variability of the pointed-to type is uniform. ** This rule will be illustrated and explained in examples below.'

So ,
int * uniform var = uniform int *uniform var
int * var =             uniform int * varying var

Considering the above, you are right that default Variability is 'varying' but pointed-to type for pointers is an exception. 
So, the current behaviour seems correct to me.

Note - we do have a typecast buf for Variability now- https://github.com/ispc/ispc/pull/1978 . But, that's not immediately related to this.


Regards,
Deepak


Pete Brubaker

unread,
Jan 14, 2021, 8:51:56 PM1/14/21
to ispc-...@googlegroups.com
"'** Like other types in ispc, pointers are varying by default, if an explicit uniform qualifier isn't provided. However, the default variability of the pointed-to type is uniform. "

Thank you Deepak, this was the bit I was missing.

Cheers,

Pete

Reply all
Reply to author
Forward
0 new messages