12.01.2013 Views

High-Productivity CUDA Development with the Thrust Template ...

High-Productivity CUDA Development with the Thrust Template ...

High-Productivity CUDA Development with the Thrust Template ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Iterators<br />

� Pair of iterators defines a range<br />

// allocate device memory<br />

device_vector d_vec(10);<br />

// declare iterator variables<br />

device_vector::iterator begin = d_vec.begin();<br />

device_vector::iterator end = d_vec.end();<br />

device_vector::iterator middle = begin + 5;<br />

// sum first and second halves<br />

int sum_half1 = reduce(begin, middle);<br />

int sum_half2 = reduce(middle, end);<br />

// empty range<br />

int empty = reduce(begin, begin);

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!