Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Dec 25th, 2011  |  syntax: C++  |  size: 0.65 KB  |  views: 61  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include <thrust/device_vector.h>
  2. #include <thrust/device_vector.h>
  3. #include <thrust/sort.h>
  4.  
  5. extern "C" {
  6. //Sort for integer arrays
  7. void sort_int_wrapper( int *data, int N)
  8. {
  9. // Wrap raw pointer with a device_ptr
  10. thrust::device_ptr <int> dev_ptr(data);
  11. // Use device_ptr in Thrust sort algorithm
  12. thrust::sort(dev_ptr, dev_ptr+N);
  13. }
  14.  
  15. //Sort for float arrays
  16. void sort_float_wrapper( float *data, int N)
  17. {
  18. thrust::device_ptr <float> dev_ptr(data);
  19. thrust::sort(dev_ptr, dev_ptr+N);
  20. }
  21.  
  22. //Sort for double arrays
  23. void sort_double_wrapper( double *data, int N)
  24. {
  25.  
  26. thrust::device_ptr <double> dev_ptr(data);
  27. thrust::sort(dev_ptr, dev_ptr+N);
  28. }
  29. }
clone this paste RAW Paste Data