forked from NVIDIA/thrust
-
Notifications
You must be signed in to change notification settings - Fork 1
/
find.test
62 lines (49 loc) · 1.4 KB
/
find.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
PREAMBLE = \
"""
#include <thrust/find.h>
#include <thrust/reduce.h>
#include <thrust/extrema.h>
template <typename Vector>
void find_partial(const Vector& v)
{
thrust::find(v.begin(), v.end(), 1);
}
template <typename Vector>
void find_full(const Vector& v)
{
thrust::max_element(v.begin(), v.end());
}
template <typename Vector>
void reduce_full(const Vector& v)
{
thrust::max_element(v.begin(), v.end());
}
"""
INITIALIZE = \
"""
thrust::host_vector<$InputType> h_input($InputSize, 0);
thrust::device_vector<$InputType> d_input($InputSize, 0);
size_t pos = $Fraction * $InputSize;
if (pos < $InputSize)
{
h_input[pos] = 1;
d_input[pos] = 1;
}
size_t h_index = thrust::find(h_input.begin(), h_input.end(), 1) - h_input.begin();
size_t d_index = thrust::find(d_input.begin(), d_input.end(), 1) - d_input.begin();
ASSERT_EQUAL(h_index, d_index);
"""
TIME = \
"""
$Method(d_input);
"""
FINALIZE = \
"""
RECORD_TIME();
RECORD_BANDWIDTH(sizeof($InputType) * double($InputSize));
"""
InputTypes = ['int']
InputSizes = [2**23]
Fractions = [0.01, 0.99]
Methods = ['find_partial', 'find_full', 'reduce_full']
TestVariables = [('InputType', InputTypes), ('InputSize', InputSizes), ('Fraction', Fractions), ('Method', Methods)]