Skip to content

Commit

Permalink
Add set_union performance test
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredhoberock committed Dec 1, 2010
1 parent 69049d0 commit c76efa1
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions performance/set_union.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
PREAMBLE = \
"""
#include <thrust/set_operations.h>
#include <thrust/sort.h>
"""

INITIALIZE = \
"""
thrust::host_vector<$InputType> h_a = unittest::random_integers<$InputType>($InputSize);
thrust::host_vector<$InputType> h_b = unittest::random_integers<$InputType>($InputSize);
thrust::sort(h_a.begin(), h_a.end());
thrust::sort(h_b.begin(), h_b.end());

thrust::host_vector<$InputType> h_result(h_a.size() + h_b.size());
thrust::host_vector<$InputType>::iterator h_new_end =
thrust::set_union(h_a.begin(), h_a.end(), h_b.begin(), h_b.end(), h_result.begin());
h_result.resize(h_new_end - h_result.begin());

thrust::device_vector<$InputType> d_a = h_a, d_b = h_b;

thrust::device_vector<$InputType> d_result(d_a.size() + d_b.size());
thrust::device_vector<$InputType>::iterator d_new_end =
thrust::set_union(d_a.begin(), d_a.end(), d_b.begin(), d_b.end(), d_result.begin());
d_result.resize(d_new_end - d_result.begin());

ASSERT_EQUAL(h_result, d_result);
"""

TIME = \
"""
thrust::set_union(d_a.begin(), d_a.end(), d_b.begin(), d_b.end(), d_result.begin());
"""

FINALIZE = \
"""
RECORD_TIME();
RECORD_BANDWIDTH(sizeof($InputType) * double(d_a.size() + d_b.size() + d_result.size()));
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)]

0 comments on commit c76efa1

Please sign in to comment.