1#ifndef OPENFPM_FOR_EACH_HPP_INCLUDED
2#define OPENFPM_FOR_EACH_HPP_INCLUDED
18#include "util/cuda_util.hpp"
19#include <boost/mpl/is_sequence.hpp>
20#include <boost/mpl/begin_end.hpp>
21#include <boost/mpl/apply.hpp>
22#include <boost/mpl/bool.hpp>
23#include <boost/mpl/next_prior.hpp>
24#include <boost/mpl/deref.hpp>
25#include <boost/mpl/identity.hpp>
26#include <boost/mpl/assert.hpp>
27#include <boost/mpl/aux_/unwrap.hpp>
29#include <boost/type_traits/is_same.hpp>
30#include <boost/utility/value_init.hpp>
32#if defined(__NVCC__) && !defined(__INTEL_COMPILER)
33#pragma hd_warning_disable
36namespace boost {
namespace mpl {
40template<
bool done = true >
45 ,
typename LastIterator
46 ,
typename TransformFunc
49 BOOST_GPU_ENABLED
static void execute(
64 ,
typename LastIterator
65 ,
typename TransformFunc
68 BOOST_GPU_ENABLED
static void execute(
75 typedef typename deref<Iterator>::type item;
76 typedef typename apply1<TransformFunc,item>::type arg;
80 value_initialized<arg> x;
81 aux::unwrap(f, 0)(boost::get(x));
83 typedef typename mpl::next<Iterator>::type iter;
85 ::execute(
static_cast<iter*
>(0),
static_cast<LastIterator*
>(0),
static_cast<TransformFunc*
>(0), f);
89template<
bool done = true >
94 ,
typename LastIterator
95 ,
typename TransformFunc
113 ,
typename LastIterator
114 ,
typename TransformFunc
124 typedef typename deref<Iterator>::type item;
125 typedef typename apply1<TransformFunc,item>::type arg;
129 value_initialized<arg> x;
130 aux::unwrap(f, 0)(boost::get(x));
132 typedef typename mpl::next<Iterator>::type iter;
134 ::execute(
static_cast<iter*
>(0),
static_cast<LastIterator*
>(0),
static_cast<TransformFunc*
>(0), f);
144 ,
typename TransformOp
147BOOST_GPU_ENABLED
inline void for_each_ref(
F & f, Sequence* = 0, TransformOp* = 0)
149 BOOST_MPL_ASSERT(( is_sequence<Sequence> ));
151 typedef typename begin<Sequence>::type first;
152 typedef typename end<Sequence>::type last;
155 ::execute(
static_cast<first*
>(0),
static_cast<last*
>(0),
static_cast<TransformOp*
>(0), f);
162BOOST_GPU_ENABLED
inline
163void for_each_ref(
F & f, Sequence* = 0)
165 for_each_ref<Sequence, identity<> >(f);
172 ,
typename TransformOp
175inline void for_each_cpu_ref(
F & f, Sequence* = 0, TransformOp* = 0)
177 BOOST_MPL_ASSERT(( is_sequence<Sequence> ));
179 typedef typename begin<Sequence>::type first;
180 typedef typename end<Sequence>::type last;
182 aux::for_each_ref_impl< boost::is_same<first,last>::value >
183 ::execute(
static_cast<first*
>(0),
static_cast<last*
>(0),
static_cast<TransformOp*
>(0), f);
191void for_each_cpu_ref(
F & f, Sequence* = 0)
193 for_each_ref<Sequence, identity<> >(f);
[v_transform metafunction]