This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Apr 11th, 2012  |  syntax: C++  |  size: 0.85 KB  |  views: 32  |  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/sort.h>
  3. #include <thrust/extrema.h>
  4. #include <iostream>
  5.  
  6. extern "C" {
  7.  
  8. //Min for float arrays
  9. int min_float_wrapper( float *data, int N)
  10. {
  11. thrust::device_ptr <float> dev_ptr(data);
  12. return (thrust::raw_pointer_cast(thrust::min_element(dev_ptr, dev_ptr+N)) - data);
  13. }
  14.  
  15. int min_double_wrapper( double *data, int N)
  16. {
  17. printf("\nmin_float_wrapper enter");
  18. thrust::device_ptr <double> dev_ptr(data);
  19. printf("\npointer created");
  20. thrust::min_element(dev_ptr, dev_ptr+N);
  21. printf("\ntmp calculated");
  22. return (int)(thrust::min_element(dev_ptr, dev_ptr+N) - dev_ptr);
  23. }
  24.  
  25. //Sort for float arrays
  26. void sort_float_wrapper( float *data, int N)
  27. {
  28. printf("\nsort enter");
  29. thrust::device_ptr <float> dev_ptr(data);
  30. printf("\nptr created");
  31. thrust::sort(dev_ptr, dev_ptr+N);
  32. printf("\nsorted!");
  33. }
  34.  
  35. }
clone this paste RAW Paste Data