forked from NVIDIA/thrust
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgather.test
43 lines (33 loc) · 1.29 KB
/
gather.test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
PREAMBLE = \
"""
#include <thrust/gather.h>
#include <thrust/iterator/counting_iterator.h>
#include <algorithm>
"""
INITIALIZE = \
"""
thrust::host_vector<$InputType> h_input = unittest::random_integers<$InputType>($InputSize);
thrust::host_vector<int> h_map(thrust::make_counting_iterator(0),
thrust::make_counting_iterator($InputSize));
std::random_shuffle(h_map.begin(), h_map.end());
thrust::host_vector<$InputType> h_result($InputSize);
thrust::device_vector<$InputType> d_input = h_input;
thrust::device_vector<int> d_map = h_map;
thrust::device_vector<$InputType> d_result($InputSize);
thrust::gather(h_map.begin(), h_map.end(), h_input.begin(), h_result.begin());
thrust::gather(d_map.begin(), d_map.end(), d_input.begin(), d_result.begin());
ASSERT_EQUAL(h_result, d_result);
"""
TIME = \
"""
thrust::gather(d_map.begin(), d_map.end(), d_input.begin(), d_result.begin());
"""
FINALIZE = \
"""
RECORD_TIME();
RECORD_THROUGHPUT(double($InputSize));
RECORD_BANDWIDTH(sizeof($InputType) * double($InputSize));
"""
InputTypes = SignedIntegerTypes
InputSizes = StandardSizes
TestVariables = [('InputType', InputTypes), ('InputSize', InputSizes)]