diff --git a/gtsam/inference/JunctionTree-inst.h b/gtsam/inference/JunctionTree-inst.h index 92cd40665..f805b4859 100644 --- a/gtsam/inference/JunctionTree-inst.h +++ b/gtsam/inference/JunctionTree-inst.h @@ -291,9 +291,12 @@ namespace gtsam { boost::shared_ptr result = boost::make_shared(); EliminationData rootsContainer(0, roots_.size()); EliminationPostOrderVisitor visitorPost(function, result->nodes_); - //tbb::task_scheduler_init init(1); - treeTraversal::DepthFirstForest/*Parallel*/(*this, rootsContainer, - eliminationPreOrderVisitor, visitorPost/*, 10*/); +#ifdef ENABLE_TIMING + // In timing mode, use a single thread only, timing outline is not thread-safe. + tbb::task_scheduler_init init(1); +#endif + treeTraversal::DepthFirstForestParallel(*this, rootsContainer, + eliminationPreOrderVisitor, visitorPost, 10); // Create BayesTree from roots stored in the dummy BayesTree node. result->roots_.insert(result->roots_.end(), rootsContainer.bayesTreeNode->children.begin(), rootsContainer.bayesTreeNode->children.end());