Since read-modify-write operation may be not atomic. If two program instances try to modify sum simultaneously, the sum may be incorrect. So one way to solve it is to create partial sum for each program instance. "partial" in each instance can only be modified by one instance so that correctness can be guaranteed.
This comment was marked helpful 0 times.
miko
It is also significant to note that one should only return uniform variables, something that each program instance has in common with one another.
This comment was marked helpful 0 times.
xs33
Question: Can someone please tell me how reduceAdd() works conceptually?
This comment was marked helpful 0 times.
kayvonf
The input to reduceAdd is of type per-instance float. The output of reduceAdd is of type uniform float.
The semantics of uniform float sum = reduceAdd(partial) above are as follows:
You can think about reduceAdd running once per gang, not once per program instance. reduceAdd accepts as input the individual values of partial for each instance in the gang, computes their sum, and then returns a single value as a result, which is stored into the uniform value sum.
Note that this is a form of inter-instance communication. ISPC provides special language built-in functions like reduceAdd for this purpose.
Since read-modify-write operation may be not atomic. If two program instances try to modify sum simultaneously, the sum may be incorrect. So one way to solve it is to create partial sum for each program instance. "partial" in each instance can only be modified by one instance so that correctness can be guaranteed.
This comment was marked helpful 0 times.
It is also significant to note that one should only return uniform variables, something that each program instance has in common with one another.
This comment was marked helpful 0 times.
Question: Can someone please tell me how reduceAdd() works conceptually?
This comment was marked helpful 0 times.
The input to
reduceAdd
is of type per-instancefloat
. The output ofreduceAdd
is of typeuniform float
.The semantics of
uniform float sum = reduceAdd(partial)
above are as follows:You can think about
reduceAdd
running once per gang, not once per program instance.reduceAdd
accepts as input the individual values ofpartial
for each instance in the gang, computes their sum, and then returns a single value as a result, which is stored into the uniform valuesum
.Note that this is a form of inter-instance communication. ISPC provides special language built-in functions like
reduceAdd
for this purpose.This comment was marked helpful 0 times.