ISAAC
Overview :: Library Doc :: Server Doc :: JSON Commands

In Situ Animation of Accelerated Computations

isaac_fusion_extension.hpp
Go to the documentation of this file.
1 /* This file is part of ISAAC.
2  *
3  * ISAAC is free software: you can redistribute it and/or modify
4  * it under the terms of the GNU Lesser General Public License as
5  * published by the Free Software Foundation, either version 3 of the
6  * License, or (at your option) any later version.
7  *
8  * ISAAC is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public
14  * License along with ISAAC. If not, see <www.gnu.org/licenses/>. */
15 
16 #pragma once
17 
18 #include <boost/fusion/include/list.hpp>
19 #include <boost/mpl/size.hpp>
20 #include <boost/mpl/begin_end.hpp>
21 #include <boost/mpl/int.hpp>
22 
23 namespace isaac
24 {
25 
26 template<int N,int I>
28 {
30  template<typename I0, typename F, typename... P>
31  ISAAC_HOST_DEVICE_INLINE static void call(I0 const& i0, F const& f, P&... p)
32  {
33  f(N - I,*i0,p...);
34  isaac_for_each_unrolled_params<N,I-1>::call(boost::fusion::next(i0), f, p...);
35  }
36 };
37 
38 template<int N>
40 {
42  template<typename It, typename F, typename... P>
43  ISAAC_HOST_DEVICE_INLINE static void call(It const&, F const&, P&... p)
44  {
45  }
46 };
47 
49 template <typename Sequence, typename F,typename... P>
50 ISAAC_HOST_DEVICE_INLINE void isaac_for_each_params(Sequence& seq, F const& f, P&... p)
51 {
52  typedef typename boost::fusion::result_of::begin<Sequence>::type begin;
53  typedef typename boost::fusion::result_of::end<Sequence>::type end;
55  <
56  boost::fusion::result_of::distance<begin, end>::type::value,
57  boost::fusion::result_of::distance<begin, end>::type::value
58  >::call(boost::fusion::begin(seq), f, p...);
59 }
60 
61 template<int N,int I>
63 {
65  template<typename I0, typename F, typename... P>
66  ISAAC_HOST_DEVICE_INLINE static void call( I0 const& i0, F const& f, P&... p)
67  {
68  boost::mpl::int_<N - I> nr;
69  f(nr,*i0,p...);
70  isaac_for_each_with_mpl_unrolled_params<N,I-1>::call(boost::fusion::next(i0), f, p...);
71  }
72 };
73 
74 template<int N>
76 {
78  template<typename It, typename F, typename... P>
79  ISAAC_HOST_DEVICE_INLINE static void call(It const&, F const&, P&... p)
80  {
81  }
82 };
83 
85 template <typename Sequence, typename F,typename... P>
86 ISAAC_HOST_DEVICE_INLINE void isaac_for_each_with_mpl_params(Sequence& seq, F const& f, P&... p)
87 {
88  typedef typename boost::fusion::result_of::begin<Sequence>::type begin;
89  typedef typename boost::fusion::result_of::end<Sequence>::type end;
91  <
92  boost::fusion::result_of::distance<begin, end>::type::value,
93  boost::fusion::result_of::distance<begin, end>::type::value
94  >::call( boost::fusion::begin(seq), f, p...);
95 }
96 
97 } //namespace isaac;
Definition: isaac.hpp:60
ISAAC_NO_HOST_DEVICE_WARNING ISAAC_HOST_DEVICE_INLINE void isaac_for_each_with_mpl_params(Sequence &seq, F const &f, P &... p)
ISAAC_NO_HOST_DEVICE_WARNING static ISAAC_HOST_DEVICE_INLINE void call(I0 const &i0, F const &f, P &... p)
ISAAC_NO_HOST_DEVICE_WARNING ISAAC_HOST_DEVICE_INLINE void isaac_for_each_params(Sequence &seq, F const &f, P &... p)
ISAAC_NO_HOST_DEVICE_WARNING static ISAAC_HOST_DEVICE_INLINE void call(It const &, F const &, P &... p)
#define ISAAC_HOST_DEVICE_INLINE
ISAAC_NO_HOST_DEVICE_WARNING static ISAAC_HOST_DEVICE_INLINE void call(I0 const &i0, F const &f, P &... p)
#define ISAAC_NO_HOST_DEVICE_WARNING
ISAAC_NO_HOST_DEVICE_WARNING static ISAAC_HOST_DEVICE_INLINE void call(It const &, F const &, P &... p)