Friday, 15 June 2012

collect position of specific value in an array using CUDA or thrust -



collect position of specific value in an array using CUDA or thrust -

i have array this:

array: 0 1 0 0 1 0 1

index: 0 1 2 3 4 5 6

and want collect position of "1" result array this:

1 4 6

thrust has "counting" function can count number of "1"

so what's fastest way of doing this? thrust have function handle this? if not, how implement cuda in efficient way?

my own idea: first utilize prefix-sum offset array, add together kernel in every thread write id resultarray[offset[id]] if info array value "1". think thought ugly. improve way?

thrust has illustration doing that:

https://github.com/thrust/thrust/blob/master/examples/counting_iterator.cu

cuda thrust

No comments:

Post a Comment