forked from NVIDIA/thrust
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbinary_search.test
45 lines (32 loc) · 1.26 KB
/
binary_search.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
42
43
44
PREAMBLE = \
"""
#include <thrust/sort.h>
#include <thrust/binary_search.h>
"""
INITIALIZE = \
"""
thrust::host_vector<$KeyType> h_keys = unittest::random_integers<$KeyType>($InputSize);
thrust::device_vector<$KeyType> d_keys = h_keys;
thrust::sort(h_keys.begin(), h_keys.end());
thrust::sort(d_keys.begin(), d_keys.end());
ASSERT_EQUAL(d_keys, h_keys);
thrust::host_vector<$KeyType> h_search = unittest::random_integers<$KeyType>($InputSize);
thrust::device_vector<$KeyType> d_search = h_search;
thrust::host_vector<unsigned int> h_output($InputSize);
thrust::device_vector<unsigned int> d_output($InputSize);
thrust::binary_search(h_keys.begin(), h_keys.end(), h_search.begin(), h_search.end(), h_output.begin());
thrust::binary_search(d_keys.begin(), d_keys.end(), d_search.begin(), d_search.end(), d_output.begin());
ASSERT_EQUAL(d_output, h_output);
"""
TIME = \
"""
thrust::binary_search(d_keys.begin(), d_keys.end(), d_search.begin(), d_search.end(), d_output.begin());
"""
FINALIZE = \
"""
RECORD_TIME();
RECORD_THROUGHPUT(double($InputSize));
"""
KeyTypes = ['int']
InputSizes = [2**24]
TestVariables = [('KeyType', KeyTypes), ('InputSize', InputSizes)]