diff --git a/examples/SolverComparer.cpp b/examples/SolverComparer.cpp index d9dce7181..cc5fdb26d 100644 --- a/examples/SolverComparer.cpp +++ b/examples/SolverComparer.cpp @@ -58,7 +58,8 @@ #include #ifdef GTSAM_USE_TBB -#include // tbb::task_scheduler_init +#include // tbb::task_arena +#include // tbb::task_group #endif using namespace std; @@ -204,10 +205,11 @@ int main(int argc, char *argv[]) { } #ifdef GTSAM_USE_TBB - std::unique_ptr init; + tbb::task_arena arena; + tbb::task_group tg; if(nThreads > 0) { cout << "Using " << nThreads << " threads" << endl; - init.reset(new tbb::task_scheduler_init(nThreads)); + arena.initialize(nThreads); } else cout << "Using threads for all processors" << endl; #else @@ -217,6 +219,10 @@ int main(int argc, char *argv[]) { } #endif +#ifdef GTSAM_USE_TBB + arena.execute([&]{ + tg.run([&]{ +#endif // Run mode if(incremental) runIncremental(); @@ -228,6 +234,10 @@ int main(int argc, char *argv[]) { runPerturb(); else if(stats) runStats(); +#ifdef GTSAM_USE_TBB + }); + }); +#endif return 0; }