forked from NVIDIA/thrust
-
Notifications
You must be signed in to change notification settings - Fork 1
/
merge.test
42 lines (32 loc) · 1.25 KB
/
merge.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/merge.h>
#include <thrust/sort.h>
"""
INITIALIZE = \
"""
thrust::device_vector<$InputType> d_a = unittest::random_integers<$InputType>($InputSize);
thrust::device_vector<$InputType> d_b = unittest::random_integers<$InputType>($InputSize);
thrust::sort(d_a.begin(), d_a.end());
thrust::sort(d_b.begin(), d_b.end());
thrust::device_vector<$InputType> d_sorted;
d_sorted.insert(d_sorted.end(), d_a.begin(), d_a.end());
d_sorted.insert(d_sorted.end(), d_b.begin(), d_b.end());
thrust::stable_sort(d_sorted.begin(), d_sorted.end());
thrust::device_vector<$InputType> d_result(d_a.size() + d_b.size());
thrust::merge(d_a.begin(), d_a.end(), d_b.begin(), d_b.end(), d_result.begin());
ASSERT_EQUAL(d_sorted, d_result);
"""
TIME = \
"""
thrust::merge(d_a.begin(), d_a.end(), d_b.begin(), d_b.end(), d_result.begin());
"""
FINALIZE = \
"""
RECORD_TIME();
RECORD_BANDWIDTH(4 * sizeof($InputType) * double($InputSize));
RECORD_SORTING_RATE(2 * double($InputSize))
"""
InputTypes = ['char', 'short', 'int', 'long', 'float', 'double']
InputSizes = [2**N for N in range(10, 25)]
TestVariables = [('InputType', InputTypes), ('InputSize', InputSizes)]