thrust::unique_by_key eating up last element

Posted by Programmer on Stack Overflow See other posts from Stack Overflow or by Programmer
Published on 2012-06-17T08:59:01Z Indexed on 2012/06/17 15:16 UTC
Read the original article Hit count: 144

Filed under:
|
|

Please consider the below simple code:

thrust::device_vector<int> positions(6);
thrust::sequence(positions.begin(), positions.end());
thrust::pair<thrust::device_vector<int>::iterator, thrust::device_vector<int>::iterator > end;
//copyListOfNgramCounteachdoc contains: 0,1,1,1,1,3
end.first = copyListOfNgramCounteachdoc.begin();
end.second = positions.begin();
for(int i =0 ; i < numDocs; i++){
    end= thrust::unique_by_key(end.first, end.first + 3,end.second);
}

int length = end.first - copyListOfNgramCounteachdoc.begin() ;
cout<<"the value of end -s is: "<<length;
for(int i =0 ; i< length ; i++){
  cout<<copyListOfNgramCounteachdoc[i];
}

I expected the output to be 0,1,1,3 of this code; however, the output is 0,1,1. Can anyone let me know what I am missing? Note: the contents of copyListOfNgramCounteachdoc is 0,1,1,1,1,3 . Also the type of copyListOfNgramCounteachdoc is thrust::device_vector<int>.

© Stack Overflow or respective owner

Related posts about cuda

Related posts about gpu