-
Notifications
You must be signed in to change notification settings - Fork 329
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds in a class for performing parallel operations with particular th…
…read counts.
- Loading branch information
Russell
authored and
Russell
committed
Oct 7, 2024
1 parent
2fe9204
commit ee9adc2
Showing
5 changed files
with
58 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include "Parallel.hpp" | ||
|
||
namespace kiss_icp::parallel { | ||
NParallel::NParallel(int num_threads) : number_of_threads_(num_threads), arena_(number_of_threads_) {} | ||
|
||
auto NParallel::get_max_threads() -> int { | ||
return number_of_threads_; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include <tbb/parallel_for.h> | ||
#include <tbb/parallel_reduce.h> | ||
#include <tbb/task_arena.h> | ||
|
||
namespace kiss_icp::parallel { | ||
|
||
class NParallel{ | ||
public: | ||
NParallel(int n); | ||
auto get_max_threads() -> int; | ||
|
||
template <typename Index, typename Function> | ||
void n_for(Index begin, Index end, const Function& func); | ||
|
||
template <typename Index, typename Function> | ||
void n_reduce(Index begin, Index end, const Function& func); | ||
|
||
private: | ||
int number_of_threads_; | ||
tbb::task_arena arena_; | ||
} | ||
|
||
template <typename Index, typename Function> | ||
void NParallel::n_for()(Index begin, Index end, const Function& func) { | ||
arena_.execute([&]() { | ||
tbb::parallel_for(begin, end, func); | ||
}); | ||
} | ||
|
||
template <typename Index, typename Function> | ||
Value NParallel::n_reduce()(const Range& range, const Value& identity, const RealBody& real_body, const Reduction& reduction); { | ||
return arena_.execute([&]() -> Value { | ||
return tbb::parallel_reduce(range, identity, real_body, reduction); | ||
}); | ||
} | ||
|
||
} // namespace kiss_icp::parallel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters