Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions ql/methods/lattices/lattice.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,13 @@ namespace QuantLib {
template <class Impl>
void TreeLattice<Impl>::stepback(Size i, const Array& values,
Array& newValues) const {
#pragma omp parallel for
for (long j=0; j<(long)this->impl().size(i); j++) {
// Only parallelise when the tree is wide enough to amortise
// OMP fork/join overhead (~2-5 us). num_threads caps thread
// participation so each thread gets >= 256 iterations.
#pragma omp parallel for \
if(!omp_in_parallel() && this->impl().size(i) >= 1024) \
num_threads((int)(this->impl().size(i) / 256))
for (Size j=0; j<this->impl().size(i); j++) {
Real value = 0.0;
for (Size l=0; l<n_; l++) {
value += this->impl().probability(i,j,l) *
Expand Down