Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

58 lines (42 sloc) 1.721 kB
PREAMBLE = \
"""
#include <thrust/detail/backend/cuda/copy_if.h>
#include <thrust/copy.h>
#include <thrust/device_vector.h>
#include <thrust/host_vector.h>
#include <unittest/unittest.h>
#include <thrust/sequence.h>
using namespace thrust;
struct pred
{
__host__ __device__
bool operator()(int x) { return bool(x); }
};
"""
INITIALIZE = \
"""
thrust::host_vector<int> h_input($InputSize); thrust::sequence(h_input.begin(), h_input.end());
thrust::host_vector<int> h_stencil = unittest::random_integers<bool>($InputSize);
thrust::host_vector<int> h_output($InputSize, -1);
thrust::device_vector<int> d_input = h_input;
thrust::device_vector<int> d_stencil = h_stencil;
thrust::device_vector<int> d_output = h_output;
typedef thrust::device_vector<int>::iterator OutputIterator;
size_t h_count = thrust::copy_if(h_input.begin(), h_input.end(), h_stencil.begin(), h_output.begin(), pred()) - h_output.begin();
size_t d_count = $Function(d_input.begin(), d_input.end(), d_stencil.begin(), d_output.begin(), pred()) - d_output.begin();
ASSERT_EQUAL(h_output, d_output);
ASSERT_EQUAL(h_count, d_count);
"""
TIME = \
"""
$Function(d_input.begin(), d_input.end(), d_stencil.begin(), d_output.begin(), pred());
"""
FINALIZE = \
"""
RECORD_TIME();
RECORD_THROUGHPUT(double($InputSize));
RECORD_BANDWIDTH((2*sizeof(int) + 2*sizeof(float)) * double($InputSize));
"""
Functions = ['thrust::copy_if','thrust::detail::backend::cuda::copy_if']
InputSizes = [2**N for N in range(20, 27)]
TestVariables = [('Function',Functions), ('InputSize', InputSizes)]
Jump to Line
Something went wrong with that request. Please try again.