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.
At compile time brcc doesn't know about the dimension of the stream. That's why indexof() always return float4.
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
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
Calling indexof() or instance() in a reduce kernel is not allowed.
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.