mirror of
https://github.com/ceres-solver/ceres-solver.git
synced 2026-08-29 16:40:38 +08:00
Adds a ParallelFor wrapper for tbb::parallel_for.
This is in preparation for adding support for a c++11 based parallel for implementation. The parallel for abstraction does not have the ability to constrain the total number of threads in nested for loops. This is solved by distributing the number of threads evenly between the nested for loops. Adds a TODO to consolidate the next for loops into a single loop that can be properly split between threads. Tested by building with TBB and running tests. Change-Id: I546973b9a4d19b9cdd53caff55d1c80bac8ea953
This commit is contained in:
@@ -31,8 +31,7 @@
|
||||
#include "ceres/coordinate_descent_minimizer.h"
|
||||
|
||||
#ifdef CERES_USE_TBB
|
||||
#include <tbb/parallel_for.h>
|
||||
#include <tbb/task_arena.h>
|
||||
#include "ceres/parallel_for.h"
|
||||
#endif
|
||||
|
||||
#include <iterator>
|
||||
@@ -174,12 +173,10 @@ void CoordinateDescentMinimizer::Minimize(
|
||||
j < independent_set_offsets_[i + 1];
|
||||
++j) {
|
||||
#else
|
||||
tbb::task_arena task_arena(num_inner_iteration_threads);
|
||||
|
||||
task_arena.execute([&]{
|
||||
tbb::parallel_for(independent_set_offsets_[i],
|
||||
independent_set_offsets_[i + 1],
|
||||
[&](int j) {
|
||||
ParallelFor(independent_set_offsets_[i],
|
||||
independent_set_offsets_[i + 1],
|
||||
num_inner_iteration_threads,
|
||||
[&](int j) {
|
||||
#endif // !CERES_USE_TBB
|
||||
|
||||
const ScopedThreadToken scoped_thread_token(&thread_token_provider);
|
||||
@@ -217,7 +214,6 @@ void CoordinateDescentMinimizer::Minimize(
|
||||
}
|
||||
#ifdef CERES_USE_TBB
|
||||
);
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user