Gpu methods to locate unique IDs

Hi,
I am just looking for some ideas to solve this problem on gpu with matlab.
There is a 2 x N vector. Row 1 has N has Ids which can be duplicate. Row 2 has corresponding numerical values. I need to sum all the values for which there is a unique column ID.
Input : [1 1 1 2 2 3 3; 10 11 12 13 14 15 16] Output : [1 2 3; 33 27 31]
A vectorized solution of this on a GPU I am guessing would be the fastest
Any suggestions would be greatly appreciated.
Thanks

回答 (1 件)

Jan
Jan 2013 年 4 月 9 日

2 投票

Start with an implementation on the CPU using accumarray.
Then decide, if the index vector is dense, this means if it contains values from 1 to N, which are all positive integers without larger gaps. Then it is much faster to accumulate the values using them as indixes. In this case a C-Mex function might be very efficient.

3 件のコメント

EssGee
EssGee 2013 年 4 月 12 日
Thanks Jan,
As you suggest, a CUDA kernel may be the only fast solution. I am not sure how to do this efficiently with bsxfun or arrayfun.
Jan
Jan 2013 年 4 月 12 日
Please explain, if the IDs are "dense" positive integers. I'm not convinced, that this is most efficient on the GPU. How large is the array?
EssGee
EssGee 2013 年 4 月 12 日
Yes the IDs are positive integers, with no gaps. I am also not very sure that this a GPU problem. However most of the calculations leading up to this operations were on the GPU. so transferring the data out of the GPU just for this would be a big overhead.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeGPU Computing についてさらに検索

タグ

質問済み:

2013 年 4 月 9 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by