Skip to content

Commit

Permalink
add TBB to vcpkg (#970)
Browse files Browse the repository at this point in the history
  • Loading branch information
a-zakir authored Dec 2, 2024
1 parent b714503 commit 0b474d0
Show file tree
Hide file tree
Showing 13 changed files with 39 additions and 22 deletions.
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,7 @@ if (CMAKE_SYSTEM_NAME STREQUAL Linux)
set(THREADS_PREFER_PTHREAD_FLAG ON)
endif ()
find_package(Threads REQUIRED)
find_package(TBB COMPONENTS tbb) # required for ubuntu 22+

find_package(TBB COMPONENTS tbb)
find_package(ZLIB REQUIRED) #Required for CoinUtils

set(GFLAGS_USE_TARGET_NAMESPACE TRUE)
Expand Down
8 changes: 5 additions & 3 deletions src/cpp/benders/benders_by_batch/BendersByBatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,9 @@ void BendersByBatch::GetSubproblemCut(
worker->get_subgradient(
subproblem_data.var_name_and_subgradient); // dual pi_s
auto subpb_cost_under_approx = GetAlpha_i()[ProblemToId(name)];
*batch_subproblems_costs_contribution_in_gap_per_proc += std::max(
subproblem_data.subproblem_cost - subpb_cost_under_approx, 0.0);
// Tbb includes min max define of windows std::numeric_limits<int>::max();
*batch_subproblems_costs_contribution_in_gap_per_proc += (std::max)(
subproblem_data.subproblem_cost - subpb_cost_under_approx, 0.0);
double cut_value_at_x_cut = subproblem_data.subproblem_cost;
for (const auto &[candidate_name, x_cut_candidate_value] : _data.x_cut) {
auto subgradient_at_name =
Expand Down Expand Up @@ -325,7 +326,8 @@ double BendersByBatch::Gap() const {
if (_data.is_in_initial_relaxation) {
return RelaxedGap() * _data.lb;
} else {
return std::max(AbsoluteGap(), RelativeGap() * _data.lb);
// Tbb 2020 includes Windows min max defines
return (std::max)(AbsoluteGap(), RelativeGap() * _data.lb);
}
}
/*!
Expand Down
5 changes: 3 additions & 2 deletions src/cpp/benders/benders_core/BendersBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ void BendersBase::UpdateStoppingCriterion() {
else if (_data.lb + _options.ABSOLUTE_GAP >= _data.best_ub)
_data.stopping_criterion = StoppingCriterion::absolute_gap;
else if (((_data.best_ub - _data.lb) /
std::max(std::abs(_data.best_ub), std::abs(_data.lb))) <=
(std::max)(std::abs(_data.best_ub), std::abs(_data.lb))) <=
_options.RELATIVE_GAP)
_data.stopping_criterion = StoppingCriterion::relative_gap;
}
Expand Down Expand Up @@ -843,7 +843,8 @@ void BendersBase::BoundSimplexIterations(int subproblem_iterations){
void BendersBase::ResetSimplexIterationsBounds()
{
_data.max_simplexiter = 0;
_data.min_simplexiter = std::numeric_limits<int>::max();
// Tbb 2020 includes Windows min max defines that's why we don't write std::numeric_limits<int>::max();
_data.min_simplexiter = (std::numeric_limits<int>::max)();
}
bool BendersBase::IsResumeMode() const { return _options.RESUME; }

Expand Down
6 changes: 3 additions & 3 deletions src/cpp/benders/benders_core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
# Targets
# ===========================================================================

find_package(TBB REQUIRED CONFIG)

add_library(benders_core)
target_sources(benders_core PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/BendersBase.cpp
Expand Down Expand Up @@ -63,9 +65,7 @@ target_link_libraries(benders_core
antaresXpansion::outer_loop_lib
)

if (TBB_FOUND)
target_link_libraries(benders_core PRIVATE tbb)
endif ()
target_link_libraries(benders_core PRIVATE TBB::tbb)

install(DIRECTORY include/antares-xpansion
DESTINATION "include"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <execution>
#include <tbb/tbb.h>
#include <filesystem>
#include <optional>
#include <regex>
Expand Down
4 changes: 1 addition & 3 deletions src/cpp/exe/full_run/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ target_link_libraries(full_run
antaresXpansion::helpers
)

if (TBB_FOUND)
target_link_libraries(full_run PRIVATE tbb)
endif ()
target_link_libraries(full_run PRIVATE TBB::tbb)

install(TARGETS full_run DESTINATION bin)
4 changes: 3 additions & 1 deletion src/cpp/lpnamer/main/ProblemGeneration.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@

#include <execution>
#include <tbb/tbb.h>

#include "antares-xpansion/lpnamer/main/ProblemGeneration.h"

#include <antares/api/solver.h>

#include <execution>
#include <iostream>
#include <utility>

Expand Down
6 changes: 2 additions & 4 deletions src/cpp/lpnamer/problem_modifier/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,10 @@ target_link_libraries(lp_namer_problem_modifier
Antares::antares-solver-simulation
)

if (TBB_FOUND)
target_link_libraries(lp_namer_problem_modifier PRIVATE tbb)
endif ()
target_link_libraries(lp_namer_problem_modifier PRIVATE TBB::tbb)

add_library(${PROJECT_NAME}::lp_namer_problem_modifier ALIAS lp_namer_problem_modifier)

install(DIRECTORY include/antares-xpansion
DESTINATION "include"
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
// Created by marechaljas on 09/01/24.
//

#include <execution>
#include <tbb/tbb.h>

#include "antares-xpansion/lpnamer/problem_modifier/FileProblemsProviderAdapter.h"

#include <execution>

#include "antares-xpansion/lpnamer/problem_modifier/FileProblemProviderAdapter.h"

Expand Down
4 changes: 3 additions & 1 deletion src/cpp/lpnamer/problem_modifier/LinkProblemsGenerator.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#include <execution>
#include <tbb/tbb.h>

#include "antares-xpansion/lpnamer/problem_modifier/LinkProblemsGenerator.h"

#include <algorithm>
#include <execution>
#include <utility>

#include "antares-xpansion/lpnamer/problem_modifier/IProblemProviderPort.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
// Created by marechaljas on 25/11/22.
//

#include <execution>
#include <tbb/tbb.h>

#include "antares-xpansion/lpnamer/problem_modifier/ZipProblemsProviderAdapter.h"

#include <execution>
#include <utility>

#include "antares-xpansion/helpers/ArchiveReader.h"
Expand Down
5 changes: 4 additions & 1 deletion src/cpp/sensitivity/SensitivityStudy.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#include <execution>
#include <tbb/tbb.h>


#include "antares-xpansion/sensitivity/SensitivityStudy.h"

#include <execution>
#include <mutex>
#include <numeric>
#include <utility>
Expand Down
7 changes: 7 additions & 0 deletions vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@
"features": [
"zlib"
]
},
"tbb"
],
"overrides": [
{
"name": "tbb",
"version-string": "2020_U3"
}
]
}

0 comments on commit 0b474d0

Please sign in to comment.