Advertisement
Guest User

Untitled

a guest
Apr 11th, 2012
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.85 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement