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_BALLOT_HPP
0012 #define BOOST_COMPUTE_FUNCTIONAL_DETAIL_NVIDIA_BALLOT_HPP
0013 
0014 #include <boost/compute/function.hpp>
0015 #include <boost/compute/types/fundamental.hpp>
0016 
0017 namespace boost {
0018 namespace compute {
0019 namespace detail {
0020 
0021 template<class T>
0022 class nvidia_ballot : public function<uint_(T)>
0023 {
0024 public:
0025     nvidia_ballot()
0026         : function<uint_(T)>("nvidia_ballot")
0027     {
0028         this->set_source(
0029             "inline uint nvidia_ballot(const uint x)\n"
0030             "{\n"
0031             "    uint result;\n"
0032             "    asm volatile(\n"
0033             "        \"setp.ne.u32 %%p1, %1, 0;\"\n"
0034             "        \"vote.ballot.b32 %0, %%p1;\"\n"
0035             "        : \"=r\"(result)\n"
0036             "        : \"r\"(x)\n"
0037             "    );\n"
0038             "    return result;\n"
0039             "}\n"
0040         );
0041     }
0042 };
0043 
0044 } // end detail namespace
0045 } // end compute namespace
0046 } // end boost namespace
0047 
0048 #endif // BOOST_COMPUTE_FUNCTIONAL_DETAIL_NVIDIA_BALLOT_HPP