]>
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_POPCOUNT_HPP | |
12 | #define BOOST_COMPUTE_FUNCTIONAL_DETAIL_NVIDIA_POPCOUNT_HPP | |
13 | ||
14 | #include <boost/compute/function.hpp> | |
15 | ||
16 | namespace boost { | |
17 | namespace compute { | |
18 | namespace detail { | |
19 | ||
20 | template<class T> | |
21 | class nvidia_popcount : public function<T(T)> | |
22 | { | |
23 | public: | |
24 | nvidia_popcount() | |
25 | : function<T(T)>("nvidia_popcount") | |
26 | { | |
27 | this->set_source( | |
28 | "inline uint nvidia_popcount(const uint x)\n" | |
29 | "{\n" | |
30 | " uint count;\n" | |
31 | " asm(\"popc.b32 %0, %1;\" : \"=r\"(count) : \"r\"(x));\n" | |
32 | " return count;\n" | |
33 | "}\n" | |
34 | ); | |
35 | } | |
36 | }; | |
37 | ||
38 | } // end detail namespace | |
39 | } // end compute namespace | |
40 | } // end boost namespace | |
41 | ||
42 | #endif // BOOST_COMPUTE_FUNCTIONAL_DETAIL_NVIDIA_POPCOUNT_HPP |