Permalink
Fetching contributors…
Cannot retrieve contributors at this time
43 lines (32 sloc) 1.25 KB
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)]