Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
52 lines (40 sloc) 1.21 KB
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)]