replace task_scheduler_init with task arena/group

release/4.3a0
acxz 2020-04-13 11:30:57 -04:00
parent b4b487695d
commit df9cf86cb0
1 changed files with 13 additions and 3 deletions

View File

@ -58,7 +58,8 @@
#include <iostream>
#ifdef GTSAM_USE_TBB
#include <tbb/task_scheduler_init.h> // tbb::task_scheduler_init
#include <tbb/task_arena.h> // tbb::task_arena
#include <tbb/task_group.h> // tbb::task_group
#endif
using namespace std;
@ -204,10 +205,11 @@ int main(int argc, char *argv[]) {
}
#ifdef GTSAM_USE_TBB
std::unique_ptr<tbb::task_scheduler_init> 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;
}