Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
bernhardmgruber committed Sep 6, 2021
1 parent bbe9d12 commit 817ade1
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions examples/thrust/thrust.cu
Original file line number Diff line number Diff line change
Expand Up @@ -377,12 +377,15 @@ void run(std::ostream& plotFile)

auto makeViewIteratorFromIndexCreator = [](decltype(view) view)
{ return [view] __host__ __device__(std::size_t i) mutable { return *(view.begin() + i); }; };
auto b = thrust::make_transform_iterator(
thrust::counting_iterator<std::size_t>{0},
makeViewIteratorFromIndexCreator(view));
auto e = thrust::make_transform_iterator(
thrust::counting_iterator<std::size_t>{N},
makeViewIteratorFromIndexCreator(view));
auto makeViewIteratorFromIndex = makeViewIteratorFromIndexCreator(view);
using ViewTransformIterator = thrust::transform_iterator<
decltype(makeViewIteratorFromIndex),
thrust::counting_iterator<std::size_t>,
typename decltype(view)::iterator::reference,
typename decltype(view)::iterator::value_type>;

auto b = ViewTransformIterator{thrust::counting_iterator<std::size_t>{0}, makeViewIteratorFromIndex};
auto e = ViewTransformIterator{thrust::counting_iterator<std::size_t>{N}, makeViewIteratorFromIndex};
// auto b = view.begin();
// auto e = view.end();

Expand Down Expand Up @@ -559,9 +562,14 @@ void run(std::ostream& plotFile)

{
auto dstView = llama::allocView(mapping, thrustDeviceAlloc);
auto db = thrust::make_transform_iterator(
thrust::counting_iterator<std::size_t>{0},
makeViewIteratorFromIndexCreator(dstView));
auto makeDstViewIteratorFromIndex = makeViewIteratorFromIndexCreator(dstView);
using DstViewTransformIterator = thrust::transform_iterator<
decltype(makeDstViewIteratorFromIndex),
thrust::counting_iterator<std::size_t>,
typename decltype(view)::iterator::reference,
typename decltype(view)::iterator::value_type>;
auto db
= DstViewTransformIterator{thrust::counting_iterator<std::size_t>{0}, makeDstViewIteratorFromIndex};
Stopwatch stopwatch;
if constexpr(usePSTL)
std::copy_if(exec, b, e, db, Predicate{});
Expand Down

0 comments on commit 817ade1

Please sign in to comment.