1 //---------------------------------------------------------------------------// 2 // Copyright (c) 2015 Jakub Szuppe <j.szuppe@gmail.com> 3 // 4 // Distributed under the Boost Software License, Version 1.0 5 // See accompanying file LICENSE_1_0.txt or copy at 6 // http://www.boost.org/LICENSE_1_0.txt 7 // 8 // See http://boostorg.github.com/compute for more information. 9 //---------------------------------------------------------------------------// 10 11 #include <algorithm> 12 #include <cstdlib> 13 #include <iostream> 14 15 #include <thrust/copy.h> 16 #include <thrust/device_vector.h> 17 #include <thrust/generate.h> 18 #include <thrust/host_vector.h> 19 #include <thrust/reverse.h> 20 21 #include "perf.hpp" 22 main(int argc,char * argv[])23int main(int argc, char *argv[]) 24 { 25 perf_parse_args(argc, argv); 26 27 std::cout << "size: " << PERF_N << std::endl; 28 thrust::host_vector<int> h_vec = generate_random_vector<int>(PERF_N); 29 30 // transfer data to the device 31 thrust::device_vector<int> d_vec; 32 d_vec = h_vec; 33 34 // device vector for reversed data 35 thrust::device_vector<int> d_reversed_vec(PERF_N); 36 37 perf_timer t; 38 for(size_t trial = 0; trial < PERF_TRIALS; trial++){ 39 t.start(); 40 thrust::reverse_copy(d_vec.begin(), d_vec.end(), d_reversed_vec.begin()); 41 cudaDeviceSynchronize(); 42 t.stop(); 43 } 44 std::cout << "time: " << t.min_time() / 1e6 << " ms" << std::endl; 45 46 return 0; 47 } 48