]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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 | #ifndef BOOST_COMPUTE_FUNCTIONAL_DETAIL_NVIDIA_BALLOT_HPP | |
12 | #define BOOST_COMPUTE_FUNCTIONAL_DETAIL_NVIDIA_BALLOT_HPP | |
13 | ||
14 | #include <boost/compute/function.hpp> | |
15 | #include <boost/compute/types/fundamental.hpp> | |
16 | ||
17 | namespace boost { | |
18 | namespace compute { | |
19 | namespace detail { | |
20 | ||
21 | template<class T> | |
22 | class nvidia_ballot : public function<uint_(T)> | |
23 | { | |
24 | public: | |
25 | nvidia_ballot() | |
26 | : function<uint_(T)>("nvidia_ballot") | |
27 | { | |
28 | this->set_source( | |
29 | "inline uint nvidia_ballot(const uint x)\n" | |
30 | "{\n" | |
31 | " uint result;\n" | |
32 | " asm volatile(\n" | |
33 | " \"setp.ne.u32 %%p1, %1, 0;\"\n" | |
34 | " \"vote.ballot.b32 %0, %%p1;\"\n" | |
35 | " : \"=r\"(result)\n" | |
36 | " : \"r\"(x)\n" | |
37 | " );\n" | |
38 | " return result;\n" | |
39 | "}\n" | |
40 | ); | |
41 | } | |
42 | }; | |
43 | ||
44 | } // end detail namespace | |
45 | } // end compute namespace | |
46 | } // end boost namespace | |
47 | ||
48 | #endif // BOOST_COMPUTE_FUNCTIONAL_DETAIL_NVIDIA_BALLOT_HPP |