Skip to content

Commit

Permalink
Fix exception handling for execution::seq
Browse files Browse the repository at this point in the history
  • Loading branch information
hkaiser committed Dec 8, 2017
1 parent 82f7b28 commit 78ed5c7
Showing 1 changed file with 21 additions and 25 deletions.
46 changes: 21 additions & 25 deletions hpx/parallel/algorithms/detail/dispatch.hpp
Expand Up @@ -100,33 +100,23 @@ namespace hpx { namespace parallel { inline namespace v1 { namespace detail
>::type
operator()(ExPolicy && policy, Args&&... args) const
{
#if !defined(__CUDA_ARCH__)
try {
#endif
typedef typename
hpx::util::decay<ExPolicy>::type::executor_parameters_type
parameters_type;
typedef typename
hpx::util::decay<ExPolicy>::type::executor_type
executor_type;
typedef typename
hpx::util::decay<ExPolicy>::type::executor_parameters_type
parameters_type;
typedef typename
hpx::util::decay<ExPolicy>::type::executor_type
executor_type;

parallel::util::detail::scoped_executor_parameters_ref<
parameters_type, executor_type
> scoped_param(policy.parameters(), policy.executor());
parallel::util::detail::scoped_executor_parameters_ref<
parameters_type, executor_type
> scoped_param(policy.parameters(), policy.executor());

return parallel::util::detail::algorithm_result<
ExPolicy, local_result_type
>::get(
Derived::sequential(std::forward<ExPolicy>(policy),
std::forward<Args>(args)...)
);
#if !defined(__CUDA_ARCH__)
}
catch(...) {
// this does not return
return detail::handle_exception<ExPolicy, local_result_type>::call();
}
#endif
return parallel::util::detail::algorithm_result<
ExPolicy, local_result_type
>::get(
Derived::sequential(std::forward<ExPolicy>(policy),
std::forward<Args>(args)...)
);
}

///////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -163,6 +153,9 @@ namespace hpx { namespace parallel { inline namespace v1 { namespace detail
return call_execute(std::forward<ExPolicy>(policy),
is_void(), std::forward<Args>(args)...);
}
catch (std::bad_alloc const& ba) {
throw ba;
}
catch (...) {
return detail::handle_exception<ExPolicy, local_result_type>::
call();
Expand All @@ -187,6 +180,9 @@ namespace hpx { namespace parallel { inline namespace v1 { namespace detail
ExPolicy, local_result_type
>::get(std::move(result));
}
catch (std::bad_alloc const& ba) {
throw ba;
}
catch (...) {
return detail::handle_exception<ExPolicy, local_result_type>::
call();
Expand Down

0 comments on commit 78ed5c7

Please sign in to comment.