mirror of
https://github.com/boostorg/mpl.git
synced 2025-08-02 22:34:31 +02:00
mpl::for_each works on nvidia gpu's
This commit is contained in:
@@ -25,6 +25,7 @@
|
|||||||
#include <boost/mpl/aux_/config/dtp.hpp>
|
#include <boost/mpl/aux_/config/dtp.hpp>
|
||||||
#include <boost/mpl/aux_/config/gcc.hpp>
|
#include <boost/mpl/aux_/config/gcc.hpp>
|
||||||
#include <boost/mpl/aux_/config/msvc.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/static_constant.hpp>
|
||||||
#include <boost/mpl/aux_/config/pp_counter.hpp>
|
#include <boost/mpl/aux_/config/pp_counter.hpp>
|
||||||
#include <boost/mpl/aux_/config/workaround.hpp>
|
#include <boost/mpl/aux_/config/workaround.hpp>
|
||||||
@@ -55,7 +56,7 @@
|
|||||||
// and GCC (which issues "unused variable" warnings when static constants are used
|
// and GCC (which issues "unused variable" warnings when static constants are used
|
||||||
// at a function scope)
|
// at a function scope)
|
||||||
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x610)) \
|
#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 }
|
# define BOOST_MPL_AUX_ASSERT_CONSTANT(T, expr) enum { expr }
|
||||||
#else
|
#else
|
||||||
# define BOOST_MPL_AUX_ASSERT_CONSTANT(T, expr) BOOST_STATIC_CONSTANT(T, expr)
|
# define BOOST_MPL_AUX_ASSERT_CONSTANT(T, expr) BOOST_STATIC_CONSTANT(T, expr)
|
||||||
|
35
include/boost/mpl/aux_/config/gpu.hpp
Normal file
35
include/boost/mpl/aux_/config/gpu.hpp
Normal 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
|
@@ -24,6 +24,7 @@
|
|||||||
|| BOOST_WORKAROUND(__EDG_VERSION__, <= 245) \
|
|| BOOST_WORKAROUND(__EDG_VERSION__, <= 245) \
|
||||||
|| BOOST_WORKAROUND(BOOST_MPL_CFG_GCC, <= 0x0295) \
|
|| BOOST_WORKAROUND(BOOST_MPL_CFG_GCC, <= 0x0295) \
|
||||||
|| BOOST_WORKAROUND(__IBMCPP__, BOOST_TESTED_AT(600)) \
|
|| BOOST_WORKAROUND(__IBMCPP__, BOOST_TESTED_AT(600)) \
|
||||||
|
|| BOOST_WORKAROUND(__NVCC__, BOOST_TESTED_AT(1)) \
|
||||||
)
|
)
|
||||||
|
|
||||||
# define BOOST_MPL_CFG_USE_OPERATORS_OVERLOADING
|
# define BOOST_MPL_CFG_USE_OPERATORS_OVERLOADING
|
||||||
|
@@ -16,10 +16,12 @@
|
|||||||
// $Revision$
|
// $Revision$
|
||||||
|
|
||||||
#include <boost/ref.hpp>
|
#include <boost/ref.hpp>
|
||||||
|
#include <boost/mpl/aux_/config/gpu.hpp>
|
||||||
|
|
||||||
namespace boost { namespace mpl { namespace aux {
|
namespace boost { namespace mpl { namespace aux {
|
||||||
|
|
||||||
template< typename F >
|
template< typename F >
|
||||||
|
BOOST_MPL_CFG_GPU_ENABLED
|
||||||
inline
|
inline
|
||||||
F& unwrap(F& f, long)
|
F& unwrap(F& f, long)
|
||||||
{
|
{
|
||||||
@@ -27,6 +29,7 @@ F& unwrap(F& f, long)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template< typename F >
|
template< typename F >
|
||||||
|
BOOST_MPL_CFG_GPU_ENABLED
|
||||||
inline
|
inline
|
||||||
F&
|
F&
|
||||||
unwrap(reference_wrapper<F>& f, int)
|
unwrap(reference_wrapper<F>& f, int)
|
||||||
@@ -35,6 +38,7 @@ unwrap(reference_wrapper<F>& f, int)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template< typename F >
|
template< typename F >
|
||||||
|
BOOST_MPL_CFG_GPU_ENABLED
|
||||||
inline
|
inline
|
||||||
F&
|
F&
|
||||||
unwrap(reference_wrapper<F> const& f, int)
|
unwrap(reference_wrapper<F> const& f, int)
|
||||||
|
@@ -22,6 +22,7 @@
|
|||||||
#include <boost/mpl/deref.hpp>
|
#include <boost/mpl/deref.hpp>
|
||||||
#include <boost/mpl/identity.hpp>
|
#include <boost/mpl/identity.hpp>
|
||||||
#include <boost/mpl/assert.hpp>
|
#include <boost/mpl/assert.hpp>
|
||||||
|
#include <boost/mpl/aux_/config/gpu.hpp>
|
||||||
#include <boost/mpl/aux_/unwrap.hpp>
|
#include <boost/mpl/aux_/unwrap.hpp>
|
||||||
|
|
||||||
#include <boost/type_traits/is_same.hpp>
|
#include <boost/type_traits/is_same.hpp>
|
||||||
@@ -40,6 +41,7 @@ struct for_each_impl
|
|||||||
, typename TransformFunc
|
, typename TransformFunc
|
||||||
, typename F
|
, typename F
|
||||||
>
|
>
|
||||||
|
BOOST_MPL_CFG_GPU_ENABLED
|
||||||
static void execute(
|
static void execute(
|
||||||
Iterator*
|
Iterator*
|
||||||
, LastIterator*
|
, LastIterator*
|
||||||
@@ -59,6 +61,7 @@ struct for_each_impl<false>
|
|||||||
, typename TransformFunc
|
, typename TransformFunc
|
||||||
, typename F
|
, typename F
|
||||||
>
|
>
|
||||||
|
BOOST_MPL_CFG_GPU_ENABLED
|
||||||
static void execute(
|
static void execute(
|
||||||
Iterator*
|
Iterator*
|
||||||
, LastIterator*
|
, LastIterator*
|
||||||
@@ -89,6 +92,7 @@ template<
|
|||||||
, typename TransformOp
|
, typename TransformOp
|
||||||
, typename F
|
, typename F
|
||||||
>
|
>
|
||||||
|
BOOST_MPL_CFG_GPU_ENABLED
|
||||||
inline
|
inline
|
||||||
void for_each(F f, Sequence* = 0, TransformOp* = 0)
|
void for_each(F f, Sequence* = 0, TransformOp* = 0)
|
||||||
{
|
{
|
||||||
@@ -105,6 +109,7 @@ template<
|
|||||||
typename Sequence
|
typename Sequence
|
||||||
, typename F
|
, typename F
|
||||||
>
|
>
|
||||||
|
BOOST_MPL_CFG_GPU_ENABLED
|
||||||
inline
|
inline
|
||||||
void for_each(F f, Sequence* = 0)
|
void for_each(F f, Sequence* = 0)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user