]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/compute/test/test_scatter.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / compute / test / test_scatter.cpp
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 TestScatter
12 #include <boost/test/unit_test.hpp>
13
14 #include <boost/compute/system.hpp>
15 #include <boost/compute/algorithm/scatter.hpp>
16 #include <boost/compute/container/vector.hpp>
17 #include <boost/compute/iterator/constant_buffer_iterator.hpp>
18
19 #include "check_macros.hpp"
20 #include "context_setup.hpp"
21
22 namespace bc = boost::compute;
23
24 BOOST_AUTO_TEST_CASE(scatter_int)
25 {
26 int input_data[] = { 1, 2, 3, 4, 5 };
27 bc::vector<int> input(input_data, input_data + 5, queue);
28
29 int map_data[] = { 0, 4, 1, 3, 2 };
30 bc::vector<int> map(map_data, map_data + 5, queue);
31
32 bc::vector<int> output(5, context);
33 bc::scatter(input.begin(), input.end(), map.begin(), output.begin(), queue);
34 CHECK_RANGE_EQUAL(int, 5, output, (1, 3, 5, 4, 2));
35 }
36
37 BOOST_AUTO_TEST_CASE(scatter_constant_indices)
38 {
39 int input_data[] = { 1, 2, 3, 4, 5 };
40 bc::vector<int> input(input_data, input_data + 5, queue);
41
42 int map_data[] = { 0, 4, 1, 3, 2 };
43 bc::buffer map_buffer(context,
44 5 * sizeof(int),
45 bc::buffer::read_only | bc::buffer::use_host_ptr,
46 map_data);
47
48 bc::vector<int> output(5, context);
49 bc::scatter(input.begin(),
50 input.end(),
51 bc::make_constant_buffer_iterator<int>(map_buffer, 0),
52 output.begin(),
53 queue);
54 CHECK_RANGE_EQUAL(int, 5, output, (1, 3, 5, 4, 2));
55 }
56
57 BOOST_AUTO_TEST_SUITE_END()