Permalink
Fetching contributors…
Cannot retrieve contributors at this time
44 lines (33 sloc) 1.29 KB
PREAMBLE = \
"""
#include <thrust/gather.h>
#include <thrust/iterator/counting_iterator.h>
#include <algorithm>
"""
INITIALIZE = \
"""
thrust::host_vector<$InputType> h_input = unittest::random_integers<$InputType>($InputSize);
thrust::host_vector<int> h_map(thrust::make_counting_iterator(0),
thrust::make_counting_iterator($InputSize));
std::random_shuffle(h_map.begin(), h_map.end());
thrust::host_vector<$InputType> h_result($InputSize);
thrust::device_vector<$InputType> d_input = h_input;
thrust::device_vector<int> d_map = h_map;
thrust::device_vector<$InputType> d_result($InputSize);
thrust::gather(h_map.begin(), h_map.end(), h_input.begin(), h_result.begin());
thrust::gather(d_map.begin(), d_map.end(), d_input.begin(), d_result.begin());
ASSERT_EQUAL(h_result, d_result);
"""
TIME = \
"""
thrust::gather(d_map.begin(), d_map.end(), d_input.begin(), d_result.begin());
"""
FINALIZE = \
"""
RECORD_TIME();
RECORD_THROUGHPUT(double($InputSize));
RECORD_BANDWIDTH(sizeof($InputType) * double($InputSize));
"""
InputTypes = SignedIntegerTypes
InputSizes = StandardSizes
TestVariables = [('InputType', InputTypes), ('InputSize', InputSizes)]