forked from NVIDIA/thrust
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathunique.test
42 lines (31 loc) · 1.18 KB
/
unique.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/unique.h>
"""
INITIALIZE = \
"""
thrust::host_vector<$InputType> h_input = unittest::random_integers<$InputType>($InputSize);
// increase likelihood of equal consecutive elements
for(size_t i = 0; i < $InputSize; i++)
h_input[i] %= 4;
thrust::device_vector<$InputType> d_input = h_input;
thrust::device_vector<$InputType> d_copy = d_input;
thrust::host_vector<$InputType>::iterator h_end = thrust::unique(h_input.begin(), h_input.end());
thrust::device_vector<$InputType>::iterator d_end = thrust::unique(d_input.begin(), d_input.end());
thrust::host_vector<$InputType> h_result(h_input.begin(), h_end);
thrust::device_vector<$InputType> d_result(d_input.begin(), d_end);
ASSERT_EQUAL(h_result, d_result);
"""
TIME = \
"""
thrust::copy(d_copy.begin(), d_copy.end(), d_input.begin());
thrust::unique(d_input.begin(), d_input.end());
"""
FINALIZE = \
"""
RECORD_TIME();
RECORD_THROUGHPUT(double($InputSize));
"""
InputTypes = SignedIntegerTypes
InputSizes = StandardSizes
TestVariables = [('InputType', InputTypes), ('InputSize', InputSizes)]