3 #ifndef OPENCL_CONVERTER_H
4 #define OPENCL_CONVERTER_H
25 #if ( SETTING_OPENCL != 0 )
76 template<
typename t_Type >
79 typedef typename t_Type::OpenCLType Type;
81 static Type Convert( t_Type
const& source ) {
83 return source.OpenCLConvert();
89 template<
typename t_Type >
90 inline typename Converter< t_Type >::Type
Convert( t_Type
const& source ) {
115 template<
typename t_Type,
size_t t_Size >
118 typedef std::array< typename Converter< t_Type >::Type, t_Size > Type;
120 static Type Convert( std::array< t_Type, t_Size >
const& source ) {
123 for (
size_t ii = 0; ii < t_Size; ++ii )
139 #define OPENCL_COMMA ,
142 #define OPENCL_CONVERTER1( ss, dd ) \
144 struct Converter< ss > { \
146 static Type Convert( ss const& source ) { \
152 #define OPENCL_CONVERTER2( ss, dd ) \
154 struct Converter< ss > { \
156 static Type Convert( ss const& source ) { \
157 Type const result = { { source[ 0 ], source[ 1 ] } }; \
163 #define OPENCL_CONVERTER3( ss, dd ) \
165 struct Converter< ss > { \
167 static Type Convert( ss const& source ) { \
168 Type const result = { { source[ 0 ], source[ 1 ], source[ 2 ] } }; \
174 #define OPENCL_CONVERTER4( ss, dd ) \
176 struct Converter< ss > { \
178 static Type Convert( ss const& source ) { \
179 Type const result = { { source[ 0 ], source[ 1 ], source[ 2 ], source[ 3 ] } }; \
185 #define OPENCL_CONVERTER8( ss, dd ) \
187 struct Converter< ss > { \
189 static Type Convert( ss const& source ) { \
190 Type const result = { { source[ 0 ], source[ 1 ], source[ 2 ], source[ 3 ], source[ 4 ], source[ 5 ], source[ 6 ], source[ 7 ] } }; \
196 #define OPENCL_CONVERTER16( ss, dd ) \
198 struct Converter< ss > { \
200 static Type Convert( ss const& source ) { \
201 Type const result = { { source[ 0 ], source[ 1 ], source[ 2 ], source[ 3 ], source[ 4 ], source[ 5 ], source[ 6 ], source[ 7 ], source[ 8 ], source[ 9 ], source[ 10 ], source[ 11 ], source[ 12 ], source[ 13 ], source[ 14 ], source[ 15 ] } }; \
207 #define OPENCL_CONVERTER( ss, dd ) \
208 OPENCL_CONVERTER1( ss, dd ) \
209 OPENCL_CONVERTER2( Vector< ss OPENCL_COMMA 2 >, dd##2 ) \
210 OPENCL_CONVERTER3( Vector< ss OPENCL_COMMA 3 >, dd##3 ) \
211 OPENCL_CONVERTER4( Vector< ss OPENCL_COMMA 4 >, dd##4 ) \
212 OPENCL_CONVERTER8( Vector< ss OPENCL_COMMA 8 >, dd##8 ) \
213 OPENCL_CONVERTER16( Vector< ss OPENCL_COMMA 16 >, dd##16 )
229 #undef OPENCL_CONVERTER1
230 #undef OPENCL_CONVERTER2
231 #undef OPENCL_CONVERTER3
232 #undef OPENCL_CONVERTER4
233 #undef OPENCL_CONVERTER8
234 #undef OPENCL_CONVERTER16
235 #undef OPENCL_CONVERTER
245 #endif // SETTING_OPENCL
250 #endif // OPENCL_CONVERTER_H