# thrust sort problem

**URL:** <https://forums.developer.nvidia.com/t/thrust-sort-problem/25828>\
**Category:** CUDA Programming and Performance\
**Created:** [February 18, 2012, 1:21am UTC](https://forums.developer.nvidia.com/t/thrust-sort-problem/25828 "2012-02-18T01:21:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![zhaojuanmao](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@zhaojuanmao](https://forums.developer.nvidia.com/u/zhaojuanmao)\
**Post date:** [February 18, 2012, 1:21am UTC](https://forums.developer.nvidia.com/t/thrust-sort-problem/25828/1 "2012-02-18T01:21:57Z")

</div>

I want to sort each row in a large matrix on GPU using thrust library.

cudaMalloc( (void\*\*)&d\_distMatrix, sizeof(float)_n_m); //n rows and m columns of matrix, their values are already assigned correctly.

for(i=0; i\<n; i++){

```
   thrust::device_ptr<float> dev_ptr(d_distMatrix+i*m);
   thrust::sort(dev_ptr, dev_ptr + m);

```

}

when m is small, it can return correct results. But when m is larger, i.e., more than 10000, the sorted results are rubbish values!!

My device memory is large enough, 6GB. There is no error message.

Does anyone know what is wrong with my codes?

Thanks a lot~

---

<div class="post-metadata">

**Author:** ![jpaulorio](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@jpaulorio](https://forums.developer.nvidia.com/u/jpaulorio)\
**Post date:** [June 30, 2013, 2:06pm UTC](https://forums.developer.nvidia.com/t/thrust-sort-problem/25828/2 "2013-06-30T14:06:14Z")

</div>

Did you manage to solve it? I have the same problem.
