cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

Size of arguments passed in shuffle2 operation

Can we pass any size of arguments in the shuffle2 operation, i.e. if we have two arrays  data1[1000],  data2[1000] and  a mask as mask[1000] can we declare it as  shuffle2[data1[1000],data2[1000],mask[1000]].... If not in this way how do we declare it...?

0 Likes
1 Solution
himanshu_gautam
Grandmaster

Hi shreedhar,

From my understanding of description of shuffle from OpenCL spec, the function should accept the supported opencl vector types (like uint8, float16 etc), and not any array of values.

If you are looking to shuffle 1000 values, wouldn't you want to do them using multiple threads, instead of a single workitem ?

So I would suggest to have something like:

int gid = get_global_id(0);

out[gid] = shuffle2(data1[gid], data2[gid], mask[gid]);

View solution in original post

0 Likes
3 Replies
himanshu_gautam
Grandmaster

Hi shreedhar,

From my understanding of description of shuffle from OpenCL spec, the function should accept the supported opencl vector types (like uint8, float16 etc), and not any array of values.

If you are looking to shuffle 1000 values, wouldn't you want to do them using multiple threads, instead of a single workitem ?

So I would suggest to have something like:

int gid = get_global_id(0);

out[gid] = shuffle2(data1[gid], data2[gid], mask[gid]);

0 Likes

Hi Himanshu,
   Even I had a slight intuition about what you are saying about shuffle2, but then what if I need to shuffle some odd no. of values...?  I mean if I choose float8 then I should have  just multiple of 8 no. of values to get it done using get_global_id(0)...!

0 Likes

I mean if I choose float8 then I should have  just multiple of 8 no. of values to get it done using get_global_id(0)...!

That is a common problem with any vector operation. It all depends on what the algorithm requires and how many threads have been launched. You can consider adding some padding if it helps you gain performance.

0 Likes