cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

ryta1203
Journeyman III

Streams of arrays

What do kernel calls and kernel declarations look like for streams of arrays?

For instance, if I have the parameter A<500>[1000] how do I pass it to a kernel function and how does it look in the kernel declaration?

I would like to do streams of arrays since I want to be able to access each element of a stream with the kernel. Is it possible (or will it be with v1.0) to do a sum (or like operation, say a simple sort) of the 1000 elements for each stream? So the streams run in parallel and each array element is summed sequentially for each stream element (which will be done in parallel).

If someone could point me to an example or some documentation that would be great. I really hope that the documentation for the official v1.0 of Brook+ is MUCH more detailed. The CAL documentation is good but the Brook+ documentation is severely lacking.
0 Likes
14 Replies

Hi ryta1203,

Streams of arrays are currently not supported in Brook+.

It is on the list of features being requested and will be looked at for a future release.

You could try this with a gather stream and generate the addressing you need into the input streams within the kernel code.

If you are looking to do a sort, you can also look at bitonic_sort in the Brook+ sample code directory.

Michael.
0 Likes

According to the Brook+ documentation, Stream of Arrays AND 3D streams are supported (both are given in the examples table), this should probably be fixed.

The problem with the sort is that I don't want to sort 1 array, I want to sort multiple arrays at 1 time. I will look into your suggestion about the gather, although it appeared that wouldn't work for me when I looked into that to begin with.
0 Likes

I've noted both stream of arrays and 3D streams in the requested feature list (or in this case, requested fix list).

If you can, take a look again at gather and let me know if it is still not what you can use.

Michael.
0 Likes

Michael,

Thanks alot. Also, is it possible to have array of streams, such that you could do the opposite of what I was saying (say, do 1 reduction per stream on multiple streams in 1 kernel)?

Also, integer operation support is in v1.0 correct? I'm just wondering because Brook+ currently does not let me increment an int in a kernel with the ++, such as is done in a for loop.
0 Likes

Hi ryta1203,

You should be able to do an array of streams but I think there is an issue with the way that brcc parses the [] notation. This was asked on streamdeveloper@amd.com before and if I remember correctly, I had to split my CPU code out of the .br file and expand the stream notations myself. You'll see that it is simply doing the transformations on the CPU code that brcc would have done anyways.

Here is a snippet of code from when I answered it in the private email:

int j, i;
//float a<10, 10>;
//float b<10, 10>;
//float c<10, 10>[20];
// below, use (float *) when referencing type float.
// below, -1 is used to indicate the end of the variable argument list.
::brook::stream a(::brook::getStreamType(( float *)0), 10 , 10,-1);
::brook::stream b(::brook::getStreamType(( float *)0), 10 , 10,-1);
::brook::stream ** c;
c = new ::brook::stream *[20];
for( i = 0; i < 20; i++ )
{
c = new ::brook::stream(::brook::getStreamType(( float *)0), 10 , 10,-1);
}

.
.
.

streamRead(a, input_a);
streamRead(b, input_b);
sum(a, b, *(c[0]));
streamWrite(*(c[0]), input_c);


For sum, I copied in the prototype from the .cpp file generated by brcc:

void sum (::brook::stream a,
::brook::stream b,
::brook::stream c);


As for integer support, the team is working hard on it and it is looking possible but I can't commit to definite integer support by v1.0. We'll know more definitely in a week or 2.

Michael.
0 Likes

Michael,

Thanks again, very helpful.

I am a bit confused though, isn't this: c<10>[20] streams of arrays, that is there are 10 streams with 20 elements in each stream? Why is the syntax for Array of streams c<10>[20] in your example and not c[20]<10>?
0 Likes

You are correct. 🙂

I went back to some old emails internally and one of our engineers corrected me on the same thing in the past.

float c[20]<10> should be an array of 20 streams, each stream being 10 floats long.

Michael.
0 Likes

Michael,

I just wanted to point out that on page 11 of the BrookPlusSpecification in the table near the bottom of the page it looks like streams of arrays and 3D streams are acceptable types in Brook+. IN FACT, it clearly states at the top of page 12:
Streams can contain arrays as primitive elements, but arrays of streams are
not permitted.
So is the documentation backwards or am I misunderstanding something here?

Is the documentation going to be more extensive and more accurate for the official version?

Thanks.
0 Likes

Hi ryta1203,

Nope, its not you, its our documentation that has it wrong! 🙂 Sorry about that and thanks for the catch!

We are working on improving the documentation's accuracy every time we have a chance and when users give us feedback on it.

I'll get this one logged to make sure that it is: 1) correct and 2) less ambiguous about 3D streams.

Michael.
0 Likes

Hi ryta1203,

Actually, I was mistaken about 3D streams.

3D streams work... gather on 3D streams don't work.

Let me know if you find it to not be working and I'll file a bug for you.

Michael.
0 Likes

It would be great if they could get rid of the stream of arrays example too if that is not supported.

I haven't tried gather on 3D streams yet, but I will let you know. What about scattering into a 3D stream? Is that supported?
0 Likes

Hi ryta1203,

I've sent your request to the Brook+ team to make sure we are not giving out stream of arrays examples.

I've also asked them about scattering to 3D streams and will post back when I get an answer.

Michael.
0 Likes

Hi ryta1203,

The Brook+ team got back to me and told me that scatter is current supported only on 1D streams.

Is it possible to treat your output stream as a 1D stream instead?

Michael.
0 Likes

Michael,

Absolutely, thanks for getting back to me so fast, the help is always appreciated. I think I saw this in the release notes today when I was looking at them. Unfortuntaely, I just recently upgraded to .2
0 Likes