Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix gather algorithm
  • Loading branch information
jszuppe committed Aug 22, 2016
commit 45ea54f704fd089fee282f30250a7502f08080eb
4 changes: 1 addition & 3 deletions include/boost/compute/algorithm/gather.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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" <<
Expand All @@ -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
Expand Down
5 changes: 5 additions & 0 deletions test/test_gather.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down