2 parents 557cf6d + b2ba234 commit 9a71406Copy full SHA for 9a71406
1 file changed
ql/methods/lattices/lattice.hpp
@@ -166,7 +166,11 @@ namespace QuantLib {
166
template <class Impl>
167
void TreeLattice<Impl>::stepback(Size i, const Array& values,
168
Array& newValues) const {
169
- #pragma omp parallel for
+ // Early tree steps can have very few nodes, where the cost of
170
+ // spawning an OpenMP thread team outweighs the work being
171
+ // parallelized. Only parallelize once there's enough work to
172
+ // amortize that overhead.
173
+ #pragma omp parallel for if(this->impl().size(i) >= 1024)
174
for (long j=0; j<(long)this->impl().size(i); j++) {
175
Real value = 0.0;
176
for (Size l=0; l<n_; l++) {
0 commit comments