# Bitonic Sort with CUDA

**URL:** <https://forums.developer.nvidia.com/t/bitonic-sort-with-cuda/34246>\
**Category:** CUDA Setup and Installation\
**Created:** [July 30, 2014, 2:30am UTC](https://forums.developer.nvidia.com/t/bitonic-sort-with-cuda/34246 "2014-07-30T02:30:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![xiongjj](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@xiongjj](https://forums.developer.nvidia.com/u/xiongjj)\
**Post date:** [July 30, 2014, 2:30am UTC](https://forums.developer.nvidia.com/t/bitonic-sort-with-cuda/34246/1 "2014-07-30T02:30:50Z")

</div>

Anyone knows bitonic sort with cuda or is there any reference that I can read and learn.

---

<div class="post-metadata">

**Author:** ![Robert\_Crovella](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/robert_crovella/32/14043_2.png) [@Robert\_Crovella](https://forums.developer.nvidia.com/u/Robert_Crovella)\
**Post date:** [July 30, 2014, 4:54am UTC](https://forums.developer.nvidia.com/t/bitonic-sort-with-cuda/34246/2 "2014-07-30T04:54:40Z")

</div>

One of the CUDA sample codes implements bitonic sort and also indicates some references:

[url][CUDA Samples :: CUDA Toolkit Documentation](http://docs.nvidia.com/cuda/cuda-samples/index.html#cuda-sorting-networks%5B/url%5D)

You may also be interested in this paper:

[url][http://www.informatik.uni-kiel.de/fileadmin/arbeitsgruppen/comsys/files/public/ppam09.pdf[/url]](http://www.informatik.uni-kiel.de/fileadmin/arbeitsgruppen/comsys/files/public/ppam09.pdf%5B/url%5D)

Which discusses a CUDA bitonic sort from the standpoint of an in-place algorithm.

---

<div class="post-metadata">

**Author:** ![xiongjj](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@xiongjj](https://forums.developer.nvidia.com/u/xiongjj)\
**Post date:** [July 30, 2014, 7:28am UTC](https://forums.developer.nvidia.com/t/bitonic-sort-with-cuda/34246/3 "2014-07-30T07:28:49Z")

</div>

Is there any sort methods based on GPU or CPU which can process 50 thousands disorder integers within  
1 msec. I am not sure that the bitonic sort could finish sorting in 1 msec.  
Many thanks for your help.

---

<div class="post-metadata">

**Author:** ![Robert\_Crovella](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/robert_crovella/32/14043_2.png) [@Robert\_Crovella](https://forums.developer.nvidia.com/u/Robert_Crovella)\
**Post date:** [July 30, 2014, 11:32am UTC](https://forums.developer.nvidia.com/t/bitonic-sort-with-cuda/34246/4 "2014-07-30T11:32:25Z")

</div>

Yes, thrust sort (a radix sort, for ordinary data types) has performance over 500M Keys/s, which would translate to over 500K Keys/ms (32-bit quantities). This will depend to a large extent on which GPU you are running on:

[url][http://sbel.wisc.edu/Courses/ME964/Literature/thrustGPUgems2011.pdf[/url]](http://sbel.wisc.edu/Courses/ME964/Literature/thrustGPUgems2011.pdf%5B/url%5D)

(figure 26.2)

Thrust ships as part of the CUDA toolkit:

[url][GitHub - NVIDIA/thrust: The C++ parallel algorithms library.](https://github.com/thrust/thrust/wiki/Quick-Start-Guide%5B/url%5D)

The fastest (easy-to-use, packaged) sort may be in CUB:

[url][http://nvlabs.github.io/cub/structcub\_1\_1\_device\_radix\_sort.html[/url]](http://nvlabs.github.io/cub/structcub_1_1_device_radix_sort.html%5B/url%5D)

Note that these performance numbers do not include the time “cost” of transferring data to/from the GPU. If you include these times, the performance will be considerably lower.

---

<div class="post-metadata">

**Author:** ![xiongjj](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@xiongjj](https://forums.developer.nvidia.com/u/xiongjj)\
**Post date:** [August 5, 2014, 8:57am UTC](https://forums.developer.nvidia.com/t/bitonic-sort-with-cuda/34246/5 "2014-08-05T08:57:12Z")

</div>

Thanks a lot!!!
