cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

wateenellende
Journeyman III

shifting streams

BROOK language extentions

For a particular class of applications, such as cellular automata simulations, it would be realy convenient to be able to shift streams. Actually to rotate them would be even better. I've seem a note somewhere (http://merrimac.stanford.edu/brook/quikspec.10-18-02.pdf) that mentions such functions as "coming soon". Any chance of having them in Brook+ ?

Tags (1)
0 Likes
6 Replies
ssclift
Journeyman III

shifting streams

I'll add my voice to that one.  There are a lot of financial applications that reduce to calculations like  

a_0 x[ i ] + a_1 x[i-1] + a_2 x[i-2] ...

which might be more efficient to code into a Brook kernel using offset copies of the x[] vectors.  x[] is are typically ~504 or ~756 in length (2 or 3 years of business-day data at 252 days/year).

0 Likes
michael_chu
Staff
Staff

shifting streams

Would you be able to reformulate your calculation to use gather streams?

Michael.
0 Likes
ssclift
Journeyman III

shifting streams

Probably.

With a float4 assigned to x..x[i-3] that would cover a lot of cases.  I'll have to test it out to see; I don't have a good feel for the relative efficiency of each approach.

0 Likes
Ceq
Journeyman III

shifting streams

I think this could be helpful:
In another thread 'udeepta' told about the domain operator.
I think you can use it like a stream shift, for example:


kernel void mul(float i1<>, float i2<>, out float o<> ) {
o = i1 * i2;
}

{
...
float input1<10>;
float input2<10>;
float output<9>;
...
mul(input1.domain(0, 9), input2.domain(1, 10), output);
...
}

(It can be used to control the output range too)
0 Likes
ssclift
Journeyman III

shifting streams

So the  .domain(a,b) is inclusive of b?  I ask because the C++ convention would have b set to one past the upper element.

 

0 Likes
Ceq
Journeyman III

shifting streams

It is exclusive of b, note that if it were inclusive the example would be indexing 11 stream elements in the kernel call.
You can try it yourself, even if you are using CPU backend it would still work.
0 Likes