1 // Copyright (c) 2007-2016 Hartmut Kaiser 2 // Copyright (c) 2016 Matthias Kretz 3 // 4 // Distributed under the Boost Software License, Version 1.0. (See accompanying 5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 7 #if !defined(HPX_PARALLEL_DATAPAR_VC_COUNT_BITS_SEP_07_2016_1217PM) 8 #define HPX_PARALLEL_DATAPAR_VC_COUNT_BITS_SEP_07_2016_1217PM 9 10 #include <hpx/config.hpp> 11 12 #if defined(HPX_HAVE_DATAPAR_VC) 13 #include <cstddef> 14 15 #include <Vc/global.h> 16 17 #if defined(Vc_IS_VERSION_1) && Vc_IS_VERSION_1 18 19 #include <Vc/Vc> 20 21 namespace hpx { namespace parallel { namespace traits 22 { 23 /////////////////////////////////////////////////////////////////////// 24 template <typename T, typename Abi> 25 HPX_HOST_DEVICE HPX_FORCEINLINE count_bits(Vc::Mask<T,Abi> const & mask)26 std::size_t count_bits(Vc::Mask<T, Abi> const& mask) 27 { 28 return mask.count(); 29 } 30 }}} 31 32 #else 33 34 #include <Vc/datapar> 35 36 namespace hpx { namespace parallel { namespace traits 37 { 38 /////////////////////////////////////////////////////////////////////// 39 template <typename T, typename Abi> 40 HPX_HOST_DEVICE HPX_FORCEINLINE count_bits(Vc::mask<T,Abi> const & mask)41 std::size_t count_bits(Vc::mask<T, Abi> const& mask) 42 { 43 return Vc::popcount(mask); 44 } 45 }}} 46 47 #endif // Vc_IS_VERSION_1 48 49 #endif 50 #endif 51 52