|
26 | 26 | #include "routeBase.h" |
27 | 27 | #include "rsz/Resizer.hh" |
28 | 28 | #include "timingBase.h" |
| 29 | +#include "utl/Environment.h" |
29 | 30 | #include "utl/Logger.h" |
30 | 31 | #include "utl/validation.h" |
31 | 32 |
|
32 | 33 | namespace gpl { |
33 | 34 |
|
34 | 35 | using utl::GPL; |
35 | 36 |
|
36 | | -namespace { |
37 | | -bool envVarTruthy(const char* name) |
38 | | -{ |
39 | | - const char* raw = std::getenv(name); |
40 | | - if (raw == nullptr || *raw == '\0') { |
41 | | - return false; |
42 | | - } |
43 | | - |
44 | | - std::string value(raw); |
45 | | - const size_t start = value.find_first_not_of(" \t\n\r"); |
46 | | - if (start == std::string::npos) { |
47 | | - return false; |
48 | | - } |
49 | | - const size_t end = value.find_last_not_of(" \t\n\r"); |
50 | | - value = value.substr(start, end - start + 1); |
51 | | - std::transform( |
52 | | - value.begin(), value.end(), value.begin(), [](unsigned char c) { |
53 | | - return static_cast<char>(std::tolower(c)); |
54 | | - }); |
55 | | - return value == "1" || value == "true" || value == "yes" || value == "on"; |
56 | | -} |
57 | | - |
58 | | -bool useOrfsNewOpenroad() |
59 | | -{ |
60 | | - return envVarTruthy("ORFS_ENABLE_NEW_OPENROAD"); |
61 | | -} |
62 | | - |
63 | | -std::optional<float> getEnvFloat(const char* name) |
64 | | -{ |
65 | | - const char* raw = std::getenv(name); |
66 | | - if (raw == nullptr || *raw == '\0') { |
67 | | - return std::nullopt; |
68 | | - } |
69 | | - |
70 | | - char* end = nullptr; |
71 | | - const float value = std::strtof(raw, &end); |
72 | | - if (end == raw || (end != nullptr && *end != '\0')) { |
73 | | - return std::nullopt; |
74 | | - } |
75 | | - return value; |
76 | | -} |
77 | | -} // namespace |
78 | | - |
79 | 37 | Replace::Replace(odb::dbDatabase* odb, |
80 | 38 | sta::dbSta* sta, |
81 | 39 | rsz::Resizer* resizer, |
@@ -304,8 +262,9 @@ bool Replace::initNesterovPlace(const PlaceOptions& options, const int threads) |
304 | 262 | tb_ = std::make_shared<TimingBase>(nbc_, rs_, log_); |
305 | 263 | tb_->setTimingNetWeightOverflows(options.timingNetWeightOverflows); |
306 | 264 | float timing_net_weight_max = options.timingNetWeightMax; |
307 | | - if (useOrfsNewOpenroad() && !options.timingNetWeightMaxUserSet) { |
308 | | - if (auto env_max = getEnvFloat("GPL_WEIGHT_MAX")) { |
| 265 | + if (utl::envVarTruthy("ORFS_ENABLE_NEW_OPENROAD") |
| 266 | + && !options.timingNetWeightMaxUserSet) { |
| 267 | + if (auto env_max = utl::getEnvFloat("GPL_WEIGHT_MAX")) { |
309 | 268 | if (*env_max > 0.0f) { |
310 | 269 | timing_net_weight_max = *env_max; |
311 | 270 | } else { |
|
0 commit comments