Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:30:00

0001 //---------------------------------------------------------------------------//
0002 // Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@gmail.com>
0003 //
0004 // Distributed under the Boost Software License, Version 1.0
0005 // See accompanying file LICENSE_1_0.txt or copy at
0006 // http://www.boost.org/LICENSE_1_0.txt
0007 //
0008 // See http://boostorg.github.com/compute for more information.
0009 //---------------------------------------------------------------------------//
0010 
0011 #ifndef BOOST_COMPUTE_FUNCTIONAL_DETAIL_NVIDIA_POPCOUNT_HPP
0012 #define BOOST_COMPUTE_FUNCTIONAL_DETAIL_NVIDIA_POPCOUNT_HPP
0013 
0014 #include <boost/compute/function.hpp>
0015 
0016 namespace boost {
0017 namespace compute {
0018 namespace detail {
0019 
0020 template<class T>
0021 class nvidia_popcount : public function<T(T)>
0022 {
0023 public:
0024     nvidia_popcount()
0025         : function<T(T)>("nvidia_popcount")
0026     {
0027         this->set_source(
0028             "inline uint nvidia_popcount(const uint x)\n"
0029             "{\n"
0030             "    uint count;\n"
0031             "    asm(\"popc.b32 %0, %1;\" : \"=r\"(count) : \"r\"(x));\n"
0032             "    return count;\n"
0033             "}\n"
0034         );
0035     }
0036 };
0037 
0038 } // end detail namespace
0039 } // end compute namespace
0040 } // end boost namespace
0041 
0042 #endif // BOOST_COMPUTE_FUNCTIONAL_DETAIL_NVIDIA_POPCOUNT_HPP