mpl::for_each works on nvidia gpu's

This commit is contained in:
Eric Niebler
2014-05-01 15:38:13 -07:00
parent cafafafea3
commit 7f823bec1c
5 changed files with 47 additions and 1 deletions

View File

@@ -25,6 +25,7 @@
#include <boost/mpl/aux_/config/dtp.hpp>
#include <boost/mpl/aux_/config/gcc.hpp>
#include <boost/mpl/aux_/config/msvc.hpp>
#include <boost/mpl/aux_/config/gpu.hpp>
#include <boost/mpl/aux_/config/static_constant.hpp>
#include <boost/mpl/aux_/config/pp_counter.hpp>
#include <boost/mpl/aux_/config/workaround.hpp>
@@ -55,7 +56,7 @@
// and GCC (which issues "unused variable" warnings when static constants are used
// at a function scope)
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x610)) \
|| (BOOST_MPL_CFG_GCC != 0)
|| (BOOST_MPL_CFG_GCC != 0) || (BOOST_MPL_CFG_GPU != 0)
# define BOOST_MPL_AUX_ASSERT_CONSTANT(T, expr) enum { expr }
#else
# define BOOST_MPL_AUX_ASSERT_CONSTANT(T, expr) BOOST_STATIC_CONSTANT(T, expr)

View File

@@ -0,0 +1,35 @@
#ifndef BOOST_MPL_AUX_CONFIG_GPU_HPP_INCLUDED
#define BOOST_MPL_AUX_CONFIG_GPU_HPP_INCLUDED
// Copyright Eric Niebler 2014
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org/libs/mpl for documentation.
// $Id$
// $Date$
// $Revision$
#include <boost/config.hpp>
#if !defined(BOOST_MPL_CFG_GPU_ENABLED) \
# define BOOST_MPL_CFG_GPU_ENABLED BOOST_GPU_ENABLED
#endif
#if defined __CUDACC__
# define BOOST_MPL_CFG_GPU 1
#else
# define BOOST_MPL_CFG_GPU 0
#endif
#endif // BOOST_MPL_AUX_CONFIG_GPU_HPP_INCLUDED

View File

@@ -24,6 +24,7 @@
|| BOOST_WORKAROUND(__EDG_VERSION__, <= 245) \
|| BOOST_WORKAROUND(BOOST_MPL_CFG_GCC, <= 0x0295) \
|| BOOST_WORKAROUND(__IBMCPP__, BOOST_TESTED_AT(600)) \
|| BOOST_WORKAROUND(__NVCC__, BOOST_TESTED_AT(1)) \
)
# define BOOST_MPL_CFG_USE_OPERATORS_OVERLOADING

View File

@@ -16,10 +16,12 @@
// $Revision$
#include <boost/ref.hpp>
#include <boost/mpl/aux_/config/gpu.hpp>
namespace boost { namespace mpl { namespace aux {
template< typename F >
BOOST_MPL_CFG_GPU_ENABLED
inline
F& unwrap(F& f, long)
{
@@ -27,6 +29,7 @@ F& unwrap(F& f, long)
}
template< typename F >
BOOST_MPL_CFG_GPU_ENABLED
inline
F&
unwrap(reference_wrapper<F>& f, int)
@@ -35,6 +38,7 @@ unwrap(reference_wrapper<F>& f, int)
}
template< typename F >
BOOST_MPL_CFG_GPU_ENABLED
inline
F&
unwrap(reference_wrapper<F> const& f, int)

View File

@@ -22,6 +22,7 @@
#include <boost/mpl/deref.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/mpl/aux_/config/gpu.hpp>
#include <boost/mpl/aux_/unwrap.hpp>
#include <boost/type_traits/is_same.hpp>
@@ -40,6 +41,7 @@ struct for_each_impl
, typename TransformFunc
, typename F
>
BOOST_MPL_CFG_GPU_ENABLED
static void execute(
Iterator*
, LastIterator*
@@ -59,6 +61,7 @@ struct for_each_impl<false>
, typename TransformFunc
, typename F
>
BOOST_MPL_CFG_GPU_ENABLED
static void execute(
Iterator*
, LastIterator*
@@ -89,6 +92,7 @@ template<
, typename TransformOp
, typename F
>
BOOST_MPL_CFG_GPU_ENABLED
inline
void for_each(F f, Sequence* = 0, TransformOp* = 0)
{
@@ -105,6 +109,7 @@ template<
typename Sequence
, typename F
>
BOOST_MPL_CFG_GPU_ENABLED
inline
void for_each(F f, Sequence* = 0)
{