Skip to content

Commit

Permalink
Parallelize motion model update (#34)
Browse files Browse the repository at this point in the history
This patch parallelizes the motion model update step using standard C++ execution policies.
  • Loading branch information
nahueespinosa authored Jan 2, 2023
1 parent 7e8073c commit 421cd7d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions beluga/include/beluga/algorithm/particle_filter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,16 @@ struct BootstrapParticleFilter : public Mixin {
}

void sample() {
auto states = views::states(particles_);
ranges::transform(
states, std::begin(states), [this](const auto& state) { return this->self().apply_motion(state); });
const auto states = views::states(particles_);
std::transform(
std::execution::par, std::begin(states), std::end(states), std::begin(states),
[this](const auto& state) { return this->self().apply_motion(state); });
}

void importance_sample() {
const auto states = views::states(particles_);
std::transform(
std::execution::par, states.begin(), states.end(), views::weights(particles_).begin(),
std::execution::par, std::begin(states), std::end(states), std::begin(views::weights(particles_)),
[this](const auto& state) { return this->self().importance_weight(state); });
}

Expand Down

0 comments on commit 421cd7d

Please sign in to comment.