Advertisement
Guest User

Untitled

a guest
Dec 18th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. #include <device_functions.h>
  2. #include "cuda_runtime.h"
  3. #include "device_launch_parameters.h"
  4.  
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <cstring>
  8. #include <vector>
  9. #include <thrust/host_vector.h>
  10. #include <thrust/device_vector.h>
  11. #include <thrust/generate.h>
  12. #include <thrust/copy.h>
  13. #include <thrust/sort.h>
  14. #include <iostream>
  15. #include <fstream>
  16. #include <ctime>
  17.  
  18.  
  19. using namespace std;
  20.  
  21.  
  22. int main()
  23. {
  24.  
  25.  
  26. std::clock_t start;
  27. double duration;
  28.  
  29. start = std::clock();
  30.  
  31. thrust::host_vector<int> h_vec(50000);
  32. thrust::generate_n(h_vec.begin(), h_vec.end(), rand);
  33. thrust::device_vector<int> d_vec = h_vec;
  34. thrust::sort(d_vec.begin(), d_vec.end());
  35. thrust::copy(d_vec.begin(), d_vec.end(), h_vec.begin());
  36.  
  37. duration = (std::clock() - start) / (double)CLOCKS_PER_SEC;
  38.  
  39. std::cout << "printf: " << duration << '\n';
  40.  
  41. cout << "labas";
  42.  
  43.  
  44.  
  45. return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement