Skip to content

Commit

Permalink
Fix gather algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
jszuppe committed Aug 22, 2016
1 parent 184f8cd commit 854acc5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
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

0 comments on commit 854acc5

Please sign in to comment.