]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/numeric/odeint/include/boost/numeric/odeint/external/thrust/thrust_resize.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / numeric / odeint / include / boost / numeric / odeint / external / thrust / thrust_resize.hpp
1 /*
2 [auto_generated]
3 boost/numeric/odeint/external/thrust/thrust_resize.hpp
4
5 [begin_description]
6 Enable resizing for thrusts device and host_vector.
7 [end_description]
8
9 Copyright 2010-2014 Mario Mulansky
10 Copyright 2010-2011 Karsten Ahnert
11
12 Distributed under the Boost Software License, Version 1.0.
13 (See accompanying file LICENSE_1_0.txt or
14 copy at http://www.boost.org/LICENSE_1_0.txt)
15 */
16
17
18 #ifndef BOOST_NUMERIC_ODEINT_EXTERNAL_THRUST_THRUST_RESIZE_HPP_INCLUDED
19 #define BOOST_NUMERIC_ODEINT_EXTERNAL_THRUST_THRUST_RESIZE_HPP_INCLUDED
20
21 #include <boost/range.hpp>
22
23 #include <thrust/device_vector.h>
24 #include <thrust/host_vector.h>
25 #include <thrust/distance.h>
26
27 #include <boost/numeric/odeint/util/resize.hpp>
28 #include <boost/numeric/odeint/util/same_size.hpp>
29 #include <boost/numeric/odeint/util/copy.hpp>
30
31 namespace boost {
32 namespace numeric {
33 namespace odeint {
34
35 // some macros that define the necessary utilities
36
37 #define ODEINT_THRUST_VECTOR_IS_RESIZEABLE( THRUST_VECTOR ) \
38 template< class T , class A > \
39 struct is_resizeable< THRUST_VECTOR<T,A> > \
40 { \
41 struct type : public boost::true_type { }; \
42 const static bool value = type::value; \
43 }; \
44
45 #define ODEINT_TRHUST_VECTOR_RESIZE_IMPL( THRUST_VECTOR ) \
46 template< class T, class A > \
47 struct resize_impl< THRUST_VECTOR<T,A> , THRUST_VECTOR<T,A> > \
48 { \
49 static void resize( THRUST_VECTOR<T,A> &x , \
50 const THRUST_VECTOR<T,A> &y ) \
51 { \
52 x.resize( y.size() ); \
53 } \
54 }; \
55 template< class T, class A, typename Range > \
56 struct resize_impl< THRUST_VECTOR<T,A> , Range > \
57 { \
58 static void resize( THRUST_VECTOR<T,A> &x , \
59 const Range &y ) \
60 { \
61 x.resize( thrust::distance(boost::begin(y), \
62 boost::end(y))); \
63 } \
64 }; \
65
66
67 #define ODEINT_THRUST_SAME_SIZE_IMPL( THRUST_VECTOR ) \
68 template< class T , class A > \
69 struct same_size_impl< THRUST_VECTOR<T,A> , THRUST_VECTOR<T,A> > \
70 { \
71 static bool same_size( const THRUST_VECTOR<T,A> &x , \
72 const THRUST_VECTOR<T,A> &y ) \
73 { \
74 return x.size() == y.size(); \
75 } \
76 }; \
77 template< class T , class A, typename Range > \
78 struct same_size_impl< THRUST_VECTOR<T,A> , Range > \
79 { \
80 static bool same_size( const THRUST_VECTOR<T,A> &x , \
81 const Range &y ) \
82 { \
83 return x.size() == thrust::distance(boost::begin(y), \
84 boost::end(y)); \
85 } \
86 }; \
87
88
89 #define ODEINT_THRUST_COPY_IMPL( THRUST_VECTOR ) \
90 template< class Container1 , class T , class A > \
91 struct copy_impl< Container1 , THRUST_VECTOR<T,A> > \
92 { \
93 static void copy( const Container1 &from , THRUST_VECTOR<T,A> &to ) \
94 { \
95 thrust::copy( boost::begin( from ) , boost::end( from ) , \
96 boost::begin( to ) ); \
97 } \
98 }; \
99 \
100 template< class T , class A , class Container2 > \
101 struct copy_impl< THRUST_VECTOR<T,A> , Container2 > \
102 { \
103 static void copy( const THRUST_VECTOR<T,A> &from , Container2 &to ) \
104 { \
105 thrust::copy( boost::begin( from ) , boost::end( from ) , \
106 boost::begin( to ) ); \
107 } \
108 }; \
109 \
110 template< class T , class A > \
111 struct copy_impl< THRUST_VECTOR<T,A> , THRUST_VECTOR<T,A> > \
112 { \
113 static void copy( const THRUST_VECTOR<T,A> &from , \
114 THRUST_VECTOR<T,A> &to ) \
115 { \
116 thrust::copy( boost::begin( from ) , boost::end( from ) , \
117 boost::begin( to ) ); \
118 } \
119 }; \
120
121 // add support for the standard thrust containers
122
123 ODEINT_THRUST_VECTOR_IS_RESIZEABLE( thrust::device_vector )
124 ODEINT_TRHUST_VECTOR_RESIZE_IMPL( thrust::device_vector )
125 ODEINT_THRUST_SAME_SIZE_IMPL( thrust::device_vector )
126 ODEINT_THRUST_COPY_IMPL( thrust::device_vector )
127
128
129 ODEINT_THRUST_VECTOR_IS_RESIZEABLE( thrust::host_vector )
130 ODEINT_TRHUST_VECTOR_RESIZE_IMPL( thrust::host_vector )
131 ODEINT_THRUST_SAME_SIZE_IMPL( thrust::host_vector )
132 ODEINT_THRUST_COPY_IMPL( thrust::host_vector )
133
134
135 } // odeint
136 } // numeric
137 } // boost
138
139 // add support for thrust backend vectors, if available
140
141 #include <thrust/version.h>
142
143 #if THRUST_VERSION >= 100600
144
145 #include <thrust/system/cpp/vector.h>
146 namespace boost { namespace numeric { namespace odeint {
147 ODEINT_THRUST_VECTOR_IS_RESIZEABLE( thrust::cpp::vector )
148 ODEINT_TRHUST_VECTOR_RESIZE_IMPL( thrust::cpp::vector )
149 ODEINT_THRUST_SAME_SIZE_IMPL( thrust::cpp::vector )
150 ODEINT_THRUST_COPY_IMPL( thrust::cpp::vector )
151 } } }
152
153 #ifdef _OPENMP
154 #include <thrust/system/omp/vector.h>
155 namespace boost { namespace numeric { namespace odeint {
156 ODEINT_THRUST_VECTOR_IS_RESIZEABLE( thrust::omp::vector )
157 ODEINT_TRHUST_VECTOR_RESIZE_IMPL( thrust::omp::vector )
158 ODEINT_THRUST_SAME_SIZE_IMPL( thrust::omp::vector )
159 ODEINT_THRUST_COPY_IMPL( thrust::omp::vector )
160 } } }
161 #endif // _OPENMP
162
163 #ifdef TBB_VERSION_MAJOR
164 #include <thrust/system/tbb/vector.h>
165 namespace boost { namespace numeric { namespace odeint {
166 ODEINT_THRUST_VECTOR_IS_RESIZEABLE( thrust::tbb::vector )
167 ODEINT_TRHUST_VECTOR_RESIZE_IMPL( thrust::tbb::vector )
168 ODEINT_THRUST_SAME_SIZE_IMPL( thrust::tbb::vector )
169 ODEINT_THRUST_COPY_IMPL( thrust::tbb::vector )
170 } } }
171 #endif // TBB_VERSION_MAJOR
172
173 #ifdef __CUDACC__
174 #include <thrust/system/cuda/vector.h>
175 namespace boost { namespace numeric { namespace odeint {
176 ODEINT_THRUST_VECTOR_IS_RESIZEABLE( thrust::cuda::vector )
177 ODEINT_TRHUST_VECTOR_RESIZE_IMPL( thrust::cuda::vector )
178 ODEINT_THRUST_SAME_SIZE_IMPL( thrust::cuda::vector )
179 ODEINT_THRUST_COPY_IMPL( thrust::cuda::vector )
180 } } }
181 #endif // __CUDACC__
182
183 #endif // THRUST_VERSION >= 100600
184
185 #endif // BOOST_NUMERIC_ODEINT_EXTERNAL_THRUST_THRUST_RESIZE_HPP_INCLUDED