From 3e0ccb8649842b5383ec4ff79b1d152d0616d74a Mon Sep 17 00:00:00 2001 From: Jakub Szuppe Date: Mon, 22 Aug 2016 18:51:14 +0200 Subject: [PATCH] Fix gather algorithm --- include/boost/compute/algorithm/gather.hpp | 4 +--- test/test_gather.cpp | 5 +++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/include/boost/compute/algorithm/gather.hpp b/include/boost/compute/algorithm/gather.hpp index b2f725d54..24c5c727a 100644 --- a/include/boost/compute/algorithm/gather.hpp +++ b/include/boost/compute/algorithm/gather.hpp @@ -36,7 +36,6 @@ class gather_kernel : public meta_kernel OutputIterator result) { m_count = iterator_range_size(first, last); - m_offset = first.get_index(); *this << "const uint i = get_global_id(0);\n" << @@ -50,12 +49,11 @@ class gather_kernel : public meta_kernel return event(); } - return exec_1d(queue, m_offset, m_count); + return exec_1d(queue, 0, m_count); } private: size_t m_count; - size_t m_offset; }; } // end detail namespace diff --git a/test/test_gather.cpp b/test/test_gather.cpp index 6696c6a9a..2d6af2c86 100644 --- a/test/test_gather.cpp +++ b/test/test_gather.cpp @@ -34,6 +34,11 @@ BOOST_AUTO_TEST_CASE(gather_int) indices.begin(), indices.end(), input.begin(), output.begin(), queue ); CHECK_RANGE_EQUAL(int, 5, output, (1, 5, 2, 4, 3)); + + compute::gather( + indices.begin() + 1, indices.end(), input.begin(), output.begin(), queue + ); + CHECK_RANGE_EQUAL(int, 5, output, (5, 2, 4, 3, 3)); } BOOST_AUTO_TEST_CASE(copy_index_then_gather)