cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

rick_weber
Adept II

How to make arrays of streams in Brook+

Okay, so after messing around with a number of ways of doing this, I found a way of making arrays of streams in Brook+ work. If you can figure out a way to statically make such an array, please reply, as it would allow syntax to be much cleaner. I couldn't figure this out since you can't call anything except the default constructor when statically creating arrays unless you overload the new operator and preallocate space for your objects (a pretty esoteric part of C++). 

const int kNumStreams = 10;
Stream* myStreamArray[kNumStreams];
unsigned int streamDim = 8192; 

for(int i = 0; i < kNumStreams; i++)
{
myStreamArray = new Stream(1,&streamDim); 
}

I needed to do this because I'm more or less computing the outer product of a 640 vector and a ~250k vector creating a 250,000x640 matrix and the resulting matrix has more than the maximum 8192^2 elements allowed by Brook+ and the CAL subsystem (I think this limit is actually architecturally imposed).



0 Likes
4 Replies
sharth
Journeyman III

#include <vector>
#include <brook/brook.h>

int main() {
    int numStreams = 100;
    int dim[] = {8192};
    Stream s(1, dim);
    vector<Stream> v(numStreams, s);
}



Although this would depend a bit on what the copy constructor of Stream does. But that's probably a cleaner route (atleast in my mind).

0 Likes

Stream class has a copy constructor with shallow copying and ref counting.

So, using vectors wouldn't help really.

0 Likes

Dang. I was hoping that they didn't do that...

0 Likes

Yeah, that was like the second thing I tried. It took me while in GDB to figure out that _stream element in the Stream class was always the same when I used the vector class.

0 Likes