forked from NVIDIA/thrust
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfill_optimization.test
51 lines (40 loc) · 1.21 KB
/
fill_optimization.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
PREAMBLE = \
"""
#include <thrust/fill.h>
#include <thrust/generate.h>
template <typename T>
struct constant_functor
{
T x;
constant_functor(T x) : x(x) {}
__host__ __device__
T operator()(void) const {return x;}
};
template <typename Iterator, typename T>
void generate_fill(Iterator first, Iterator last, T x)
{
thrust::generate(first, last, constant_functor<T>(x));
}
"""
INITIALIZE = \
"""
thrust::host_vector<$InputType> h_input($InputSize);
thrust::device_vector<$InputType> d_input($InputSize);
thrust::fill(h_input.begin(), h_input.end(), $InputType(13));
$Method(d_input.begin(), d_input.end(), $InputType(13));
ASSERT_EQUAL(h_input, d_input);
"""
TIME = \
"""
$Method(d_input.begin(), d_input.end(), $InputType(13));
"""
FINALIZE = \
"""
RECORD_TIME();
RECORD_THROUGHPUT(double($InputSize));
RECORD_BANDWIDTH(sizeof($InputType) * double($InputSize));
"""
InputTypes = ['char', 'short', 'int', 'long']
InputSizes = [2**24]
Methods = ['thrust::fill', 'generate_fill']
TestVariables = [('InputType', InputTypes), ('InputSize', InputSizes), ('Method', Methods)]