Just to clarify - the "uniform" keyword implies that the value is consistent across all instances?
kayvonf
@SR_94. Not quite. uniform implies there is a single instance of this variable shared by all program instances. This is different from being constant. For example, the code at right on slide 18 uses a uniform value that is stored to. (So it's not a constant.)
preritrodney
Apart from the performance difference between the implementations on slide 9 and this code, there is another difference : The code on this slide will not work correctly for N%programCount != 0 while the code on slide 9 will work correctly for the same as well.
pht
Since uniform implies that there's a single instance of this variable shared by all program instances, when updating the variable, are locks needed? How will the different program instances synchronize this variable?
kayvonf
@pht: that assignment of the uniform is from an immediate (which you can think of as being of type uniform int). Since the expression only utilizes values of type uniform, it's a valid expression. By definition, uniform expressions are executed once per gang (not per instance) and thus no synchronization is needed.
Assignment of a per-instance value to a uniform is invalid, and will generated a compile-time type error. An example of code that triggers this error is on slide 18.
Just to clarify - the "uniform" keyword implies that the value is consistent across all instances?
@SR_94. Not quite.
uniform
implies there is a single instance of this variable shared by all program instances. This is different from being constant. For example, the code at right on slide 18 uses a uniform value that is stored to. (So it's not a constant.)Apart from the performance difference between the implementations on slide 9 and this code, there is another difference : The code on this slide will not work correctly for N%programCount != 0 while the code on slide 9 will work correctly for the same as well.
Since uniform implies that there's a single instance of this variable shared by all program instances, when updating the variable, are locks needed? How will the different program instances synchronize this variable?
@pht: that assignment of the uniform is from an immediate (which you can think of as being of type uniform int). Since the expression only utilizes values of type uniform, it's a valid expression. By definition, uniform expressions are executed once per gang (not per instance) and thus no synchronization is needed.
Assignment of a per-instance value to a uniform is invalid, and will generated a compile-time type error. An example of code that triggers this error is on slide 18.