From 817ade1a5fc43833ca04b0934866b907b8831b8c Mon Sep 17 00:00:00 2001 From: Bernhard Manfred Gruber Date: Mon, 6 Sep 2021 18:25:53 +0200 Subject: [PATCH] fix --- examples/thrust/thrust.cu | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/examples/thrust/thrust.cu b/examples/thrust/thrust.cu index ad24c5f9df..02609cc098 100644 --- a/examples/thrust/thrust.cu +++ b/examples/thrust/thrust.cu @@ -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{0}, - makeViewIteratorFromIndexCreator(view)); - auto e = thrust::make_transform_iterator( - thrust::counting_iterator{N}, - makeViewIteratorFromIndexCreator(view)); + auto makeViewIteratorFromIndex = makeViewIteratorFromIndexCreator(view); + using ViewTransformIterator = thrust::transform_iterator< + decltype(makeViewIteratorFromIndex), + thrust::counting_iterator, + typename decltype(view)::iterator::reference, + typename decltype(view)::iterator::value_type>; + + auto b = ViewTransformIterator{thrust::counting_iterator{0}, makeViewIteratorFromIndex}; + auto e = ViewTransformIterator{thrust::counting_iterator{N}, makeViewIteratorFromIndex}; // auto b = view.begin(); // auto e = view.end(); @@ -559,9 +562,14 @@ void run(std::ostream& plotFile) { auto dstView = llama::allocView(mapping, thrustDeviceAlloc); - auto db = thrust::make_transform_iterator( - thrust::counting_iterator{0}, - makeViewIteratorFromIndexCreator(dstView)); + auto makeDstViewIteratorFromIndex = makeViewIteratorFromIndexCreator(dstView); + using DstViewTransformIterator = thrust::transform_iterator< + decltype(makeDstViewIteratorFromIndex), + thrust::counting_iterator, + typename decltype(view)::iterator::reference, + typename decltype(view)::iterator::value_type>; + auto db + = DstViewTransformIterator{thrust::counting_iterator{0}, makeDstViewIteratorFromIndex}; Stopwatch stopwatch; if constexpr(usePSTL) std::copy_if(exec, b, e, db, Predicate{});