]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/compute/test/test_invoke.cpp
1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2013-2015 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://kylelutz.github.com/compute for more information.
9 //---------------------------------------------------------------------------//
11 #define BOOST_TEST_MODULE TestInvoke
12 #include <boost/test/unit_test.hpp>
14 #include <boost/compute/function.hpp>
15 #include <boost/compute/lambda.hpp>
16 #include <boost/compute/functional/integer.hpp>
17 #include <boost/compute/functional/math.hpp>
18 #include <boost/compute/utility/invoke.hpp>
20 #include "context_setup.hpp"
22 namespace compute
= boost::compute
;
24 BOOST_AUTO_TEST_CASE(invoke_builtin
)
26 BOOST_CHECK_EQUAL(compute::invoke(compute::abs
<int>(), queue
, -3), 3);
27 BOOST_CHECK_CLOSE(compute::invoke(compute::pow
<float>(), queue
, 2.f
, 8.f
), 256.f
, 1e-4);
30 BOOST_AUTO_TEST_CASE(invoke_function
)
32 BOOST_COMPUTE_FUNCTION(int, plus_two
, (int x
),
37 BOOST_CHECK_EQUAL(compute::invoke(plus_two
, queue
, 2), 4);
39 BOOST_COMPUTE_FUNCTION(float, get_max
, (float x
, float y
),
47 BOOST_CHECK_EQUAL(compute::invoke(get_max
, queue
, 10.f
, 20.f
), 20.f
);
50 BOOST_AUTO_TEST_CASE(invoke_lambda
)
52 using boost::compute::lambda::_1
;
53 using boost::compute::lambda::_2
;
55 BOOST_CHECK_EQUAL(compute::invoke(_1
/ 2, queue
, 4), 2);
56 BOOST_CHECK_EQUAL(compute::invoke(_1
* _2
+ 1, queue
, 3, 3), 10);
59 BOOST_AUTO_TEST_SUITE_END()