title: cuda: Any efficient way to get non-zero elements in sparse matrix
body: <p>I have a big 2D histogram, in which most of the elements are zero. I want to put the non-zero ones and their positions to 2 arrays(or vectors). Is there any efficient way to do this?</p>
  
  <p>I hope have stated my problem clearly. Here is some detail.</p>
  
  <p>1) I have a 1024*1024 histogram, and filled by atomicAdd().
  2) For each element in histogram, if it's not a local peak, it's content is set to be 0. (Usually I have &lt;50 peaks) In this way, my histogram becomes a big sparse matrix.
  3) My problem is : I want to put all non-zero elements and their positions to 2 arrays. I don't know how to do it efficiently.</p>
  
  <p>Hope for your suggestions, thank you in advance.</p>