9 Replies Latest reply on Dec 13, 2008 5:42 PM by entity279

    indexof question

      indexof returns a float4? For example: indexof(float4 variable here)

      Why is this? For example, if I have a float4 stream how can I determine the index of the stream? That's all I want to do. The index of the stream should be one int value, I don't know how to abstract the index from a float4 type.

      Any ideas how I would do this?

      EDIT: As a side note, I'm glad that the overall performance has increased in 1.3 for Brook+; however, I'm sad that AMD had to also significantly increase the complexity of programming for Brook+ as the tradeoff. The documentation STILL needs a TON of work, it's just all around bad and too limited at the moment. I thought this was suppose to be improved in this release but I guess not. Most of it is just the same old documentation with a "few" (very few) new additions to it.

      ps. I couldn't get the "-a" to work without errors.
        • indexof question
          I don't find that strange. Think that you can use indexof on multi-dimensional streams:
          float a< x>;
          float b< x, y>;
          float c< x, y, z>;
          float d< x, y, z, t>;

          So for simplicity the implementation returns always a float4, but only the first values are significative.
          float4 posA = indexof( a ); returns the position in posA.x
          float4 posB = indexof( b ); returns the x location in posB.x and y in posB.y
          and so on

          If you find it simpler I think this should work:
          float posA = indexof( a );
            • indexof question
              float posA = indexof(a); why would this work, you are returning a float4 from indexof into a float?

              I understand what you mean, but is this indeed the way it works, by your example, if you return the indexof a float does that index get put it .x and so on and so forth?
                • indexof question

                  If I've understood the docs correctly, then indexof(x) will return a float, float2, float3, of float4 depending on how many dimensions stream x has.  The new instance() "function" always returns int4.


                  in either case, use float posA = indexof(a).x; if you just want the first dim.




                    • indexof question
                      The float4 in my example is ONE dimension and I get the errors above. So I don't think it returns a float, float2, float3 or float4. According to the docs it ALWAYS returns a float4.

                      My question is why? Is it because of what Ceq said? Does the SDK even support 4 dimension streams?

                      Maybe AMD can shed some light on this for me.
                        • indexof question

                          At compile time brcc doesn't know about the dimension of the stream. That's why indexof() always return float4.

                          • indexof question

                            This reply is with respect to 1.3 version of Brook+.

                            - Like someone said already, at compile time, brcc does not have information on the dimensionality of the Stream (<> syntax streams are dimension-independent). Hence brcc always assumes float4 as the return value from indexof(). However, the LHS of the expression _must_ match the return type from indexof(). Hence, the following is illegal (brcc 1.3 would check for the type match) -

                                float a = indexof(streamA);

                               The correct way to write the above code would be

                                float a - indexof(streamA).x;

                            - indexof() is always specific to the Stream passed to the intrinsic (atleast as per the spec :-)) and can be ill-defined for cases like scatter (e.g. out stream[][]). The fact that indexof() returns a float4 to some extent is also due to the fact that GPUs use floating point indexing internally to access memory buffers (textures) and hence has a legacy element to it!

                            - With 1.3 release, Brook+ supports a more intuitive interface for accessing kernel instances using the instance() intrinsic.

                              + instance() is NOT stream specific and hence is always defined, even for scatter. It corresponds to the kernel invocation and is relative to the domain of kernel execution.

                              + instance() returns an int4 which should be more intuitive for those comparing this with the regular C array indexing mechanisms.

                            - Brook+ 1.3 supports C-style indexing of multi-dimensional gather streams (e.g. streamA[j]).


                              • indexof question

                                indexof(stream).x always returns 0.0f when  brt_runtime=cal but works just fine when brt_runtime=cpu

                                where stream is unidimensional stream of 50 elements, input of a reduce kernel


                                also tried using instance() but the brcc.exe (if that's the name of the brook+ builder) stalls using 100% cpu and not returning compilation results to IDE


                                  • indexof question

                                    Calling indexof() or instance() in a reduce kernel is not allowed.

                                      • indexof question

                                        That's to bad the compiler is totally silent about it.


                                        That would mean the only way to solve my problem would be to manually add another float to each stream (for example if the stream normal stream has been float2 i'll have to make it float3), float wich will be used for indexing.

                                        What I was trying to do is just to get the minimum element index in a stream.