replace task_scheduler_init with task arena/group
parent
b4b487695d
commit
df9cf86cb0
|
@ -58,7 +58,8 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#ifdef GTSAM_USE_TBB
|
#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
|
#endif
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
@ -204,10 +205,11 @@ int main(int argc, char *argv[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef GTSAM_USE_TBB
|
#ifdef GTSAM_USE_TBB
|
||||||
std::unique_ptr<tbb::task_scheduler_init> init;
|
tbb::task_arena arena;
|
||||||
|
tbb::task_group tg;
|
||||||
if(nThreads > 0) {
|
if(nThreads > 0) {
|
||||||
cout << "Using " << nThreads << " threads" << endl;
|
cout << "Using " << nThreads << " threads" << endl;
|
||||||
init.reset(new tbb::task_scheduler_init(nThreads));
|
arena.initialize(nThreads);
|
||||||
} else
|
} else
|
||||||
cout << "Using threads for all processors" << endl;
|
cout << "Using threads for all processors" << endl;
|
||||||
#else
|
#else
|
||||||
|
@ -217,6 +219,10 @@ int main(int argc, char *argv[]) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef GTSAM_USE_TBB
|
||||||
|
arena.execute([&]{
|
||||||
|
tg.run([&]{
|
||||||
|
#endif
|
||||||
// Run mode
|
// Run mode
|
||||||
if(incremental)
|
if(incremental)
|
||||||
runIncremental();
|
runIncremental();
|
||||||
|
@ -228,6 +234,10 @@ int main(int argc, char *argv[]) {
|
||||||
runPerturb();
|
runPerturb();
|
||||||
else if(stats)
|
else if(stats)
|
||||||
runStats();
|
runStats();
|
||||||
|
#ifdef GTSAM_USE_TBB
|
||||||
|
});
|
||||||
|
});
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue