14 Replies Latest reply on Apr 22, 2008 6:18 PM by ryta1203

    Streams of arrays

    ryta1203
      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.
        • Streams of arrays
          michael.chu
          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.
            • Streams of arrays
              ryta1203
              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.
                • Streams of arrays
                  michael.chu
                  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.
                    • Streams of arrays
                      ryta1203
                      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.
                        • Streams of arrays
                          michael.chu
                          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 ******* 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.
                            • Streams of arrays
                              ryta1203
                              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>?
                                • Streams of arrays
                                  michael.chu
                                  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.
                                    • Streams of arrays
                                      ryta1203
                                      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.
                                        • Streams of arrays
                                          michael.chu
                                          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.