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
11 #define BOOST_TEST_MODULE TestPartialSum
12 #include <boost/test/unit_test.hpp>
13
14 #include <vector>
15 #include <numeric>
16
17 #include <boost/compute/system.hpp>
18 #include <boost/compute/command_queue.hpp>
19 #include <boost/compute/algorithm/copy.hpp>
20 #include <boost/compute/algorithm/partial_sum.hpp>
21 #include <boost/compute/container/vector.hpp>
22
23 #include "check_macros.hpp"
24 #include "context_setup.hpp"
25
26 namespace bc = boost::compute;
27
BOOST_AUTO_TEST_CASE(partial_sum_int)28 BOOST_AUTO_TEST_CASE(partial_sum_int)
29 {
30 int data[] = { 1, 2, 5, 3, 9, 1, 4, 2 };
31 bc::vector<int> a(8, context);
32 bc::copy(data, data + 8, a.begin(), queue);
33
34 bc::vector<int> b(a.size(), context);
35 bc::vector<int>::iterator iter =
36 bc::partial_sum(a.begin(), a.end(), b.begin(), queue);
37 BOOST_CHECK(iter == b.end());
38 CHECK_RANGE_EQUAL(int, 8, b, (1, 3, 8, 11, 20, 21, 25, 27));
39 }
40
41 BOOST_AUTO_TEST_SUITE_END()
42