]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/compute/test/test_functional_popcount.cpp
1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2013-2014 Kyle Lutz <kyle.r.lutz@gmail.com>
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
8 // See http://boostorg.github.com/compute for more information.
9 //---------------------------------------------------------------------------//
11 #define BOOST_TEST_MODULE TestFunctionalPopcount
12 #include <boost/test/unit_test.hpp>
14 #include <boost/compute/algorithm/transform.hpp>
15 #include <boost/compute/container/vector.hpp>
16 #include <boost/compute/functional/popcount.hpp>
18 #include "check_macros.hpp"
19 #include "context_setup.hpp"
21 namespace compute
= boost::compute
;
23 typedef boost::mpl::list
<
24 compute::uchar_
, compute::ushort_
, compute::uint_
, compute::ulong_
25 > popcount_test_types
;
27 BOOST_AUTO_TEST_CASE_TEMPLATE(popcount
, T
, popcount_test_types
)
29 compute::vector
<T
> vec(context
);
30 vec
.push_back(0x00, queue
);
31 vec
.push_back(0x01, queue
);
32 vec
.push_back(0x03, queue
);
33 vec
.push_back(0xff, queue
);
35 compute::vector
<int> popcounts(vec
.size(), context
);
37 vec
.begin(), vec
.end(), popcounts
.begin(), compute::popcount
<T
>(), queue
39 CHECK_RANGE_EQUAL(int, 4, popcounts
, (0, 1, 2, 8));
42 BOOST_AUTO_TEST_SUITE_END()