test_partial_sum.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. //---------------------------------------------------------------------------//
  2. // Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@gmail.com>
  3. //
  4. // Distributed under the Boost Software License, Version 1.0
  5. // See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt
  7. //
  8. // See http://boostorg.github.com/compute for more information.
  9. //---------------------------------------------------------------------------//
  10. #define BOOST_TEST_MODULE TestPartialSum
  11. #include <boost/test/unit_test.hpp>
  12. #include <vector>
  13. #include <numeric>
  14. #include <boost/compute/system.hpp>
  15. #include <boost/compute/command_queue.hpp>
  16. #include <boost/compute/algorithm/copy.hpp>
  17. #include <boost/compute/algorithm/partial_sum.hpp>
  18. #include <boost/compute/container/vector.hpp>
  19. #include "check_macros.hpp"
  20. #include "context_setup.hpp"
  21. namespace bc = boost::compute;
  22. BOOST_AUTO_TEST_CASE(partial_sum_int)
  23. {
  24. int data[] = { 1, 2, 5, 3, 9, 1, 4, 2 };
  25. bc::vector<int> a(8, context);
  26. bc::copy(data, data + 8, a.begin(), queue);
  27. bc::vector<int> b(a.size(), context);
  28. bc::vector<int>::iterator iter =
  29. bc::partial_sum(a.begin(), a.end(), b.begin(), queue);
  30. BOOST_CHECK(iter == b.end());
  31. CHECK_RANGE_EQUAL(int, 8, b, (1, 3, 8, 11, 20, 21, 25, 27));
  32. }
  33. BOOST_AUTO_TEST_SUITE_END()