Skip to content

Commit

Permalink
disable tbb when num_threads == 1
Browse files Browse the repository at this point in the history
  • Loading branch information
koide3 committed Sep 22, 2024
1 parent a63ea95 commit 178defd
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ double IntegratedCT_GICPFactor_<TargetFrame, SourceFrame>::error(const gtsam::Va
return error;
};

if (is_omp_default() || num_threads == 1) {
if (is_omp_default() || this->num_threads == 1) {
return scan_matching_reduce_omp(perpoint_task, frame::size(*this->source), this->num_threads, nullptr, nullptr, nullptr, nullptr, nullptr);
} else {
return scan_matching_reduce_tbb(perpoint_task, frame::size(*this->source), nullptr, nullptr, nullptr, nullptr, nullptr);
Expand Down Expand Up @@ -142,7 +142,7 @@ boost::shared_ptr<gtsam::GaussianFactor> IntegratedCT_GICPFactor_<TargetFrame, S
gtsam::Vector6 b_0;
gtsam::Vector6 b_1;

if (is_omp_default() || num_threads == 1) {
if (is_omp_default() || this->num_threads == 1) {
error = scan_matching_reduce_omp(perpoint_task, frame::size(*this->source), this->num_threads, &H_00, &H_11, &H_01, &b_0, &b_1);
} else {
error = scan_matching_reduce_tbb(perpoint_task, frame::size(*this->source), &H_00, &H_11, &H_01, &b_0, &b_1);
Expand Down Expand Up @@ -184,7 +184,7 @@ void IntegratedCT_GICPFactor_<TargetFrame, SourceFrame>::update_correspondences(
}
};

if (is_omp_default() || num_threads == 1) {
if (is_omp_default() || this->num_threads == 1) {
#pragma omp parallel for num_threads(this->num_threads) schedule(guided, 8)
for (int i = 0; i < frame::size(*this->source); i++) {
perpoint_task(i);
Expand Down
2 changes: 1 addition & 1 deletion src/gtsam_points/util/covariance_estimation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ std::vector<Eigen::Matrix4d> estimate_covariances(const Eigen::Vector4d* points,
}
};

if (is_omp_default() || num_threads == 1) {
if (is_omp_default() || params.num_threads == 1) {
#pragma omp parallel for num_threads(params.num_threads) schedule(guided, 8)
for (int i = 0; i < num_points; i++) {
perpoint_task(i);
Expand Down
2 changes: 1 addition & 1 deletion src/test/test_colored_gicp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ TEST_P(ColoredGICPTest, AlignmentTest) {
const auto param = GetParam();
const std::string method = std::get<0>(param);
const std::string parallelism = std::get<1>(param);
const int num_threads = parallelism == "OMP" ? 2 : 1;
const int num_threads = parallelism == "NONE" ? 1 : 2;

if (parallelism == "TBB") {
gtsam_points::set_tbb_as_default();
Expand Down
2 changes: 1 addition & 1 deletion src/test/test_continuous_time.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ TEST_P(ContinuousTimeFactorTest, AlignmentTest) {
const auto param = GetParam();
const std::string method = std::get<0>(param);
const std::string parallelism = std::get<1>(param);
const int num_threads = parallelism == "OMP" ? 2 : 1;
const int num_threads = parallelism == "NONE" ? 1 : 2;

if (parallelism == "TBB") {
gtsam_points::set_tbb_as_default();
Expand Down
2 changes: 1 addition & 1 deletion src/test/test_loam_factors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class LOAMFactorTest : public LOAMTestBase, public testing::WithParamInterface<s
const auto param = GetParam();
const std::string method = std::get<0>(param);
const std::string parallelism = std::get<1>(param);
const int num_threads = parallelism == "OMP" ? 2 : 1;
const int num_threads = parallelism == "NONE" ? 1 : 2;

gtsam::NonlinearFactor::shared_ptr factor;
if (method == "LOAM") {
Expand Down

0 comments on commit 178defd

Please sign in to comment.