Closed agerlach closed 9 years ago
In principle it should work. Can you give us the compiler output?
In file included from /usr/local/include/boost/numeric/odeint/util/ublas_wrapper.hpp:30:0,
from /usr/local/include/boost/numeric/odeint.hpp:25,
from ../adam.cpp:6:
/usr/local/include/boost/numeric/odeint/algebra/default_operations.hpp: In member function ‘void boost::numeric::odeint::default_operations::rel_error
/usr/local/include/boost/numeric/odeint/stepper/controlled_runge_kutta.hpp:209:48: instantiated from ‘boost::numeric::odeint::controlled_step_result boost::numeric::odeint::controlled_runge_kutta<ErrorStepper, ErrorChecker, Resizer, boost::numeric::odeint::explicit_error_stepper_tag>::try_step(System, StateInOut&, boost::numeric::odeint::controlled_runge_kutta<ErrorStepper, ErrorChecker, Resizer, boost::numeric::odeint::explicit_error_stepper_tag>::time_type&, boost::numeric::odeint::controlled_runge_kutta<ErrorStepper, ErrorChecker, Resizer, boost::numeric::odeint::explicit_error_stepper_tag>::time_type&) [with System = sys_func, StateInOut = vex::multivector<double, 3ul>, ErrorStepper = boost::numeric::odeint::runge_kutta_cash_karp54<vex::multivector<double, 3ul> >, ErrorChecker = boost::numeric::odeint::default_error_checker<double, boost::numeric::odeint::vector_space_algebra, boost::numeric::odeint::default_operations>, Resizer = boost::numeric::odeint::initially_resizer, boost::numeric::odeint::controlled_runge_kutta<ErrorStepper, ErrorChecker, Resizer, boost::numeric::odeint::explicit_error_stepper_tag>::time_type = double]’
/usr/local/include/boost/numeric/odeint/integrate/detail/integrate_adaptive.hpp:101:13: instantiated from ‘size_t boost::numeric::odeint::detail::integrate_adaptive(Stepper, System, State&, Time&, Time, Time&, Observer, boost::numeric::odeint::controlled_stepper_tag) [with Stepper = boost::numeric::odeint::controlled_runge_kutta<boost::numeric::odeint::runge_kutta_cash_karp54<vex::multivector<double, 3ul> >, boost::numeric::odeint::default_error_checker<double, boost::numeric::odeint::vector_space_algebra, boost::numeric::odeint::default_operations>, boost::numeric::odeint::initially_resizer, boost::numeric::odeint::explicit_error_stepper_tag>, System = sys_func, State = vex::multivector<double, 3ul>, Time = double, Observer = boost::numeric::odeint::null_observer, size_t = long unsigned int]’
/usr/local/include/boost/numeric/odeint/integrate/integrate_adaptive.hpp:45:43: instantiated from ‘size_t boost::numeric::odeint::integrate_adaptive(Stepper, System, State&, Time, Time, Time, Observer) [with Stepper = boost::numeric::odeint::controlled_runge_kutta<boost::numeric::odeint::runge_kutta_cash_karp54<vex::multivector<double, 3ul> >, boost::numeric::odeint::default_error_checker<double, boost::numeric::odeint::vector_space_algebra, boost::numeric::odeint::default_operations>, boost::numeric::odeint::initially_resizer, boost::numeric::odeint::explicit_error_stepper_tag>, System = sys_func, State = vex::multivector<double, 3ul>, Time = double, Observer = boost::numeric::odeint::null_observer, size_t = long unsigned int]’
/usr/local/include/boost/numeric/odeint/integrate/integrate_adaptive.hpp:83:110: instantiated from ‘size_t boost::numeric::odeint::integrate_adaptive(Stepper, System, State&, Time, Time, Time) [with Stepper = boost::numeric::odeint::controlled_runge_kutta<boost::numeric::odeint::runge_kutta_cash_karp54<vex::multivector<double, 3ul> >, boost::numeric::odeint::default_error_checker<double, boost::numeric::odeint::vector_space_algebra, boost::numeric::odeint::default_operations>, boost::numeric::odeint::initially_resizer, boost::numeric::odeint::explicit_error_stepper_tag>, System = sys_func, State = vex::multivector<double, 3ul>, Time = double, size_t = long unsigned int]’
../adam.cpp:71:109: instantiated from here
/usr/local/include/boost/iterator/iterator_categories.hpp:159:8: error: no type named ‘iterator_category’ in ‘struct boost::detail::iterator_traits<vex::multivector<double, 3ul>::iterator_type<const vex::multivector<double, 3ul>, vex::multivector<double, 3ul>::const_element> >’
In file included from /usr/local/include/boost/range/algorithm/equal.hpp:14:0,
from /usr/local/include/boost/range/iterator_range_core.hpp:31,
from /usr/local/include/boost/lexical_cast.hpp:174,
from /usr/local/include/boost/math/constants/constants.hpp:18,
from /home/agerlach/git/vexcl/vexcl/constants.hpp:41,
from /home/agerlach/git/vexcl/vexcl/vexcl.hpp:35,
from ../adam.cpp:4:
/usr/local/include/boost/range/concepts.hpp: In instantiation of ‘boost::range_detail::IncrementableIteratorConcept<vex::multivector<double, 3ul>::iterator_type<const vex::multivector<double, 3ul>, vex::multivector<double, 3ul>::const_element> >’:
/usr/local/include/boost/range/concepts.hpp:135:16: instantiated from ‘boost::range_detail::SinglePassIteratorConcept<vex::multivector<double, 3ul>::iterator_type<const vex::multivector<double, 3ul>, vex::multivector<double, 3ul>::const_element> >’
/usr/local/include/boost/concept/detail/has_constraints.hpp:42:5: instantiated from ‘const bool boost::concepts::not_satisfied<boost::range_detail::SinglePassIteratorConcept<vex::multivector<double, 3ul>::iterator_type<const vex::multivector<double, 3ul>, vex::multivector<double, 3ul>::const_element> > >::value’
/usr/local/include/boost/concept/detail/has_constraints.hpp:45:31: instantiated from ‘boost::concepts::not_satisfied<boost::range_detail::SinglePassIteratorConcept<vex::multivector<double, 3ul>::iterator_type<const vex::multivector<double, 3ul>, vex::multivector<double, 3ul>::constelement> > >’
/usr/local/include/boost/mpl/if.hpp:67:11: instantiated from ‘boost::mpl::if<boost::concepts::not_satisfied<boost::range_detail::SinglePassIteratorConcept<vex::multivector<double, 3ul>::iterator_type<const vex::multivector<double, 3ul>, vex::multivector<double, 3ul>::const_element> > >, boost::concepts::constraint<boost::range_detail::SinglePassIteratorConcept<vex::multivector<double, 3ul>::iterator_type<const vex::multivector<double, 3ul>, vex::multivector<double, 3ul>::const_element> > >, boost::concepts::requirement<boost::concepts::failed**** boost::range_detail::SinglePassIteratorConcept<vex::multivector<double, 3ul>::iterator_type<const vex::multivector<double, 3ul>, vex::multivector<double, 3ul>::constelement> >::***> >’
/usr/local/include/boost/concept/detail/general.hpp:50:8: instantiated from ‘boost::concepts::requirement<void ()(boost::range_detail::SinglePassIteratorConcept<vex::multivector<double, 3ul>::iterator_type<const vex::multivector<double, 3ul>, vex::multivector<double, 3ul>::const_element> >)>’
/usr/local/include/boost/range/concepts.hpp:259:1: [ skipping 10 instantiation contexts ]
/usr/local/include/boost/numeric/odeint/stepper/controlled_runge_kutta.hpp:430:59: instantiated from ‘boost::numeric::odeint::controlled_step_result boost::numeric::odeint::controlled_runge_kutta<ErrorStepper, ErrorChecker, Resizer, boost::numeric::odeint::explicit_error_stepper_tag>::try_step_v1(System, StateInOut&, boost::numeric::odeint::controlled_runge_kutta<ErrorStepper, ErrorChecker, Resizer, boost::numeric::odeint::explicit_error_stepper_tag>::time_type&, boost::numeric::odeint::controlled_runge_kutta<ErrorStepper, ErrorChecker, Resizer, boost::numeric::odeint::explicit_error_stepper_tag>::time_type&) [with System = sys_func, StateInOut = vex::multivector<double, 3ul>, ErrorStepper = boost::numeric::odeint::runge_kutta_cash_karp54<vex::multivector<double, 3ul> >, ErrorChecker = boost::numeric::odeint::default_error_checker<double, boost::numeric::odeint::vector_space_algebra, boost::numeric::odeint::default_operations>, Resizer = boost::numeric::odeint::initially_resizer, boost::numeric::odeint::controlled_runge_kutta<ErrorStepper, ErrorChecker, Resizer, boost::numeric::odeint::explicit_error_stepper_tag>::time_type = double]’
/usr/local/include/boost/numeric/odeint/stepper/controlled_runge_kutta.hpp:209:48: instantiated from ‘boost::numeric::odeint::controlled_step_result boost::numeric::odeint::controlled_runge_kutta<ErrorStepper, ErrorChecker, Resizer, boost::numeric::odeint::explicit_error_stepper_tag>::try_step(System, StateInOut&, boost::numeric::odeint::controlled_runge_kutta<ErrorStepper, ErrorChecker, Resizer, boost::numeric::odeint::explicit_error_stepper_tag>::time_type&, boost::numeric::odeint::controlled_runge_kutta<ErrorStepper, ErrorChecker, Resizer, boost::numeric::odeint::explicit_error_stepper_tag>::time_type&) [with System = sys_func, StateInOut = vex::multivector<double, 3ul>, ErrorStepper = boost::numeric::odeint::runge_kutta_cash_karp54<vex::multivector<double, 3ul> >, ErrorChecker = boost::numeric::odeint::default_error_checker<double, boost::numeric::odeint::vector_space_algebra, boost::numeric::odeint::default_operations>, Resizer = boost::numeric::odeint::initially_resizer, boost::numeric::odeint::controlled_runge_kutta<ErrorStepper, ErrorChecker, Resizer, boost::numeric::odeint::explicit_error_stepper_tag>::time_type = double]’
/usr/local/include/boost/numeric/odeint/integrate/detail/integrate_adaptive.hpp:101:13: instantiated from ‘size_t boost::numeric::odeint::detail::integrate_adaptive(Stepper, System, State&, Time&, Time, Time&, Observer, boost::numeric::odeint::controlled_stepper_tag) [with Stepper = boost::numeric::odeint::controlled_runge_kutta<boost::numeric::odeint::runge_kutta_cash_karp54<vex::multivector<double, 3ul> >, boost::numeric::odeint::default_error_checker<double, boost::numeric::odeint::vector_space_algebra, boost::numeric::odeint::default_operations>, boost::numeric::odeint::initially_resizer, boost::numeric::odeint::explicit_error_stepper_tag>, System = sys_func, State = vex::multivector<double, 3ul>, Time = double, Observer = boost::numeric::odeint::null_observer, size_t = long unsigned int]’
/usr/local/include/boost/numeric/odeint/integrate/integrate_adaptive.hpp:45:43: instantiated from ‘size_t boost::numeric::odeint::integrate_adaptive(Stepper, System, State&, Time, Time, Time, Observer) [with Stepper = boost::numeric::odeint::controlled_runge_kutta<boost::numeric::odeint::runge_kutta_cash_karp54<vex::multivector<double, 3ul> >, boost::numeric::odeint::default_error_checker<double, boost::numeric::odeint::vector_space_algebra, boost::numeric::odeint::default_operations>, boost::numeric::odeint::initially_resizer, boost::numeric::odeint::explicit_error_stepper_tag>, System = sys_func, State = vex::multivector<double, 3ul>, Time = double, Observer = boost::numeric::odeint::null_observer, size_t = long unsigned int]’
/usr/local/include/boost/numeric/odeint/integrate/integrate_adaptive.hpp:83:110: instantiated from ‘size_t boost::numeric::odeint::integrate_adaptive(Stepper, System, State&, Time, Time, Time) [with Stepper = boost::numeric::odeint::controlled_runge_kutta<boost::numeric::odeint::runge_kutta_cash_karp54<vex::multivector<double, 3ul> >, boost::numeric::odeint::default_error_checker<double, boost::numeric::odeint::vector_space_algebra, boost::numeric::odeint::default_operations>, boost::numeric::odeint::initially_resizer, boost::numeric::odeint::explicit_error_stepper_tag>, System = sys_func, State = vex::multivector<double, 3ul>, Time = double, size_t = long unsigned int]’
../adam.cpp:71:109: instantiated from here
/usr/local/include/boost/range/concepts.hpp:116:79: error: no type named ‘type’ in ‘struct boost::iterator_traversal<vex::multivector<double, 3ul>::iterator_type<const vex::multivector<double, 3ul>, vex::multivector<double, 3ul>::const_element> >’
/usr/local/include/boost/range/concepts.hpp:122:1: error: no type named ‘type’ in ‘struct boost::iterator_traversal<vex::multivector<double, 3ul>::iterator_type<const vex::multivector<double, 3ul>, vex::multivector<double, 3ul>::const_element> >’
/usr/local/include/boost/range/concepts.hpp: In destructor ‘boost::range_detail::SinglePassIteratorConcept
It looks like a specification of boost::numeric::odeint::detail::get_unit_value_impl
for vexcl types is required. @headmyshoulder, if that correct, I could provide it.
But even if adaptive stepper will work, I think it would make same steps for all of the systems in the parameter study. Would that be acceptable?
For me, it seems that abs() is not implemented for vex::multivector<>. get_unit_value simply return the argument that has been passed (by value, maybe this is not good for performance). But then, there is no abs() function. And abs() must be the elementwise abs function.
I am not sure if adaptive_stepper increases the performance. I can imagine situations where it might make sense, for example if you have intermittent dynamics for large parameter regions, or if your solutions are mostly regular. But of course it depends on the problem. Nevertheless, I assume that you will not loose too much if you use integrate_const.
The problem with abs
is that OpenCL only provides it for integral types. With floating point types one should use fabs
. VexCL provides an overload of abs
for vector expressions that tries to do the right thing depending on the result type of the expression. For multivector expressions this is not possible in general case. But I could provide such overload just for multivectors (so that abs(x)
works and abs(2 * x)
does not). The other way would be to replace a call to abs
with a call to fabs
in odeint's code. But I am not sure if that is acceptable.
On 10/31/2013 11:35 AM, Denis Demidov wrote:
The problem with |abs| is that OpenCL only provides it for integral types. With floating point types one should use |fabs|. VexCL provides an overload of |abs| for vector expressions that tries to do the right thing depending on the result type of the expression. For multivector expressions this is not possible in general case. But I could provide such overload just for multivectors (so that |abs(x)| works and |abs(2 * x)| does not). The other way would be to replace a call to |abs| with a call to |fabs| in odeint's code. But I am not sure if that is acceptable.
abs must return a vexcl vector or a vexcl expression, hence x = abs( y ) means that x[i] = abs( y[i] ) for all i.
I understand that, its just direct translation to OpenCL code is impossible:
x[i] = abs(y[i]);
will result in OpenCL kernel compile error if y is a vector of float
/double
values.
@agerlach, could you please check if the code compiles with 29cb4d8adc6df3a794419a29f216eae273df136c? You can get the patched odeint version by
git clone -b vexcl-mvec-abs https://github.com/ddemidov/odeint-v2
If that does not, could you please provide a minimal but complete example that should compile, but leads to compile errors?
@ddemidov , I'm still gettting many errors. They are included below. For an example, make the following changes to https://github.com/headmyshoulder/odeint-v2/blob/master/libs/numeric/odeint/examples/vexcl/lorenz_ensemble.cpp
Change line 76 from
runge_kutta4< state_type > stepper;
to
typedef runge_kutta_cash_karp54<state_type> error_stepper_type;
And line 79 from
integrate_const( stepper , sys_func( R ) , X , 0.0 , t_max , dt );
to
size_t steps = integrate_adaptive(make_controlled<error_stepper_type>(1.0e-10,1.0e-6),sys_func(R),X,0.0,t_max,dt);
Errors: Description Resource Path Location Type no ‘operator++(int)’ declared for postfix ‘++’ [-fpermissive] vexclTry line 155, external location: /usr/local/include/boost/range/concepts.hpp C/C++ Problem no type named ‘reference’ in ‘struct boost::detail::iterator_traits<vex::multivector<double, 3ul>::iterator_type<const vex::multivector<double, 3ul>, vex::multivector<double, 3ul>::const_element> >’ vexclTry line 157, external location: /usr/local/include/boost/range/concepts.hpp C/C++ Problem [ skipping 6 instantiation contexts ] vexclTry line 50, external location: /usr/local/include/boost/concept/detail/general.hpp C/C++ Problem no type named ‘reference’ in ‘struct boost::detail::iterator_traits<vex::multivector<double, 3ul>::iterator_type<const vex::multivector<double, 3ul>, vex::multivector<double, 3ul>::const_element> >’ vexclTry line 160, external location: /usr/local/include/boost/range/concepts.hpp C/C++ Problem [ skipping 13 instantiation contexts ] vexclTry line 45, external location: /usr/local/include/boost/concept/detail/has_constraints.hpp C/C++ Problem no ‘operator++(int)’ declared for postfix ‘++’ [-fpermissive] vexclTry line 127, external location: /usr/local/include/boost/range/concepts.hpp C/C++ Problem [ skipping 2 instantiation contexts ] vexclTry line 66, external location: /usr/local/include/boost/numeric/odeint/util/copy.hpp C/C++ Problem no type named ‘value_type’ in ‘struct std::iterator_traits<vex::multivector<double, 3ul>::iterator_type<const vex::multivector<double, 3ul>, vex::multivector<double, 3ul>::const_element> >’ vexclTry line 381, external location: /usr/include/c++/4.6/bits/stl_algobase.h C/C++ Problem no type named ‘iterator_category’ in ‘struct std::iterator_traits<vex::multivector<double, 3ul>::iterator_type<const vex::multivector<double, 3ul>, vex::multivector<double, 3ul>::const_element> >’ vexclTry line 377, external location: /usr/include/c++/4.6/bits/stl_algobase.h C/C++ Problem no type named ‘value_type’ in ‘struct std::iterator_traits<vex::multivector<double, 3ul>::iterator_type<vex::multivector<double, 3ul>, vex::multivector<double, 3ul>::element> >’ vexclTry line 376, external location: /usr/include/c++/4.6/bits/stl_algobase.h C/C++ Problem no type named ‘value_type’ in ‘struct std::iterator_traits<vex::multivector<double, 3ul>::iterator_type<const vex::multivector<double, 3ul>, vex::multivector<double, 3ul>::const_element> >’ vexclTry line 375, external location: /usr/include/c++/4.6/bits/stl_algobase.h C/C++ Problem [ skipping 11 instantiation contexts ] vexclTry line 50, external location: /usr/local/include/boost/concept/detail/general.hpp C/C++ Problem make: *\ [adam.o] Error 1 vexclTry C/C++ Problem no type named ‘iterator_category’ in ‘struct boost::detail::iterator_traits<vex::multivector<double, 3ul>::iterator_type<const vex::multivector<double, 3ul>, vex::multivector<double, 3ul>::const_element> >’ vexclTry line 159, external location: /usr/local/include/boost/iterator/iterator_categories.hpp C/C++ Problem no type named ‘iterator_category’ in ‘struct std::iterator_traits<vex::multivector<double, 3ul>::iterator_type<const vex::multivector<double, 3ul>, vex::multivector<double, 3ul>::const_element> >’ vexclTry line 384, external location: /usr/include/c++/4.6/bits/stl_algobase.h C/C++ Problem [ skipping 10 instantiation contexts ] vexclTry line 259, external location: /usr/local/include/boost/range/concepts.hpp C/C++ Problem no type named ‘type’ in ‘struct boost::iterator_traversal<vex::multivector<double, 3ul>::iterator_type<const vex::multivector<double, 3ul>, vex::multivector<double, 3ul>::const_element> >’ vexclTry line 122, external location: /usr/local/include/boost/range/concepts.hpp C/C++ Problem no type named ‘type’ in ‘struct boost::iterator_traversal<vex::multivector<double, 3ul>::iterator_type<const vex::multivector<double, 3ul>, vex::multivector<double, 3ul>::const_element> >’ vexclTry line 116, external location: /usr/local/include/boost/range/concepts.hpp C/C++ Problem
I am able to compile and run the modified lorenz_ensemble example with 2099a1224f45d2703910d13dfa4acb30e2cabc48.
git clone -b vexcl-mvec-copy https://github.com/ddemidov/odeint-v2
Does this output meaningful results for your problem?
On 10/31/2013 01:17 PM, Denis Demidov wrote:
I understand that, its just direct translation to OpenCL code is impossible:
x[i] = abs(y[i]); will result in OpenCL kernel compile error if y is a vector of |float|/|double| values.
We could provide a method elementwise_abs (maybe with a better name) with a default implementation like
template< typename T > T elementwise_abs( T a ) { using std::abs; return abs( a ); }
This one could then be specialized by vexcl or other libraries and even be used with expression templates. @ddemidov would this be sufficient for you to adapt the controlled steppers?
I have already provided the specialization of abs
that works with vex:multivector
in 29cb4d8adc6df3a794419a29f216eae273df136c. Those seem to work fine, so I don't think it is worth adding elementwise_abs()
and making odeint use it.
On 10/31/2013 05:00 PM, Denis Demidov wrote:
I have already provided the specialization of |abs| that works with |vex:multivector| in 29cb4d8 https://github.com/headmyshoulder/odeint-v2/commit/29cb4d8adc6df3a794419a29f216eae273df136c. Those seem to work fine, so I don't think it is worth adding |elementwise_abs()| and making odeint use it.
Ok, I see. My idea with elementwise_abs is to make it an odeint function which can and should be overloaded. The problem might be that an library overloads or implements abs in the L2 sense and then it can't be used with odeint anymore, at least not in the controlled steppers.
Well, if you decide to go with an elementwise_abs()
, I'll be happy to provide a vexcl specialization for it :).
I am able to compile and run the modified lorenz_ensemble example with 2099a12.
git clone -b vexcl-mvec-copy https://github.com/ddemidov/odeint-v2 Does this output meaningful results for your problem?
This seems to be working and, on initial inspection, the results are as expected.
I've made a pull request containing the necessary changes (#108).
I am trying to migrate some code from Thrust + odeint to VexCL + odeint. I am doing parameters studies on ensembles of systems with many states and the need for nested zip_iterators when using thrust has caused me to look for a better solution.
I have VexCL working when I use integrate_const(), but I get compilation errors when trying integrate_adaptive(). Does integrate_adaptive() support VexCL?
Working:
Not Working:
Thanks.