cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

tgm
Journeyman III

Brook+ accumulate operation

Brook+ does not allow output stream is accumulated ?

For example:

kernel void test(float a[], float b<>

{

tid = instance().x

b += a[tid];

}

The elements in output stream sometimes are NAN.

0 Likes
1 Reply
gaurav_garg
Adept I

I assume you have declared b with out qualifier. It seems from your kernel you don't want to accumulate data in b, but want to read the previous value and update it with a new value. Brook+ doesn't allow reading and writing to the same stream. But, you can try something like this -

kernel void test(float a[], float bOld<>, out float b<>)

{

tid = instance().x

b = a[tid] + bOld;

}

As a sidenote Brook+ allows accumulating data of a stream to a smaller size stream using reduction kernel -

reduce void test(float a<>, reduce float b<>)

{

b += a;

}

0 Likes