cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

hennequi
Journeyman III

gather with streams of different sizes

gather with streams of different sizes

Good morning,

i am wondering if the domain over which a gather stream is reachable can be bigger than the domain of execution of the kernel.

In my case, I have a 1D input stream a<> of length N, one 2D gather stream b[][] of dimensions {M,N}, a normal 1D out stream c<> of length N, and I do the following

kernel void mykernel(float4 a<>, float4 b[][], out float4 c<>){

  unsigned int j;

  unsigned int index = instance().x;

  float4 tmp = a;

  for(j=0;j<M;j++) tmp = tmp + b[index];

  c = tmp;

}

What I noticed was that if N >= M the result is correct,

on the contrary if M < N it seems to be able to gather only those values b[index] for which j < N ...

is there a way to access the whole gather stream??

should I use one of those .domain things?

Thanks a lot

Guillaume.

 

0 Likes
3 Replies
gaurav_garg
Adept I

 

on the contrary if M < N it seems to be able to gather only those values b[index] for which j < N ...

 



I don't understand it. If M < N, Is 0<=j<M not expected to be < N?

Could you post your runtime code?

0 Likes
Gipsel
Adept I

Originally posted by: hennequione 2D gather stream b[][] of dimensions {M,N}, a normal 1D out stream c<> of length N, and I do the  following

[..]

  for(j=0; j<M; j++) tmp = tmp + b[index];



I guess that is once again the confusing definition of the stream dimensions. If you defined the dimensions of stream b as {M,N}, the last element is actually b[N-1][M-1]. So I think you have to switch the indices (or the dimensions) to get a correct behaviour.
0 Likes

you're right Gispel,

i inverted my indices and it now works fine.

Probably some hint at this issue in the documentation would save a lot of programmers quite some time 🙂

0 Likes