Skip to content

Commit 43c1589

Browse files
Merge pull request #2901 from verilog-to-routing/remove_defines_in_vpr_types
Remove some defines in vpr types in favor of standard library constants
2 parents ceae587 + f5d0586 commit 43c1589

File tree

4 files changed

+15
-17
lines changed

4 files changed

+15
-17
lines changed

vpr/src/base/vpr_types.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,6 @@ constexpr bool VTR_ENABLE_DEBUG_LOGGING_CONST_EXPR = true;
9393
constexpr bool VTR_ENABLE_DEBUG_LOGGING_CONST_EXPR = false;
9494
#endif
9595

96-
/* Values large enough to be way out of range for any data, but small enough
97-
* to allow a small number to be added to them without going out of range. */
98-
#define HUGE_POSITIVE_FLOAT 1.e30
99-
100-
/* Used to avoid floating-point errors when comparing values close to 0 */
101-
#define EPSILON 1.e-15
102-
10396
/*
10497
* Files
10598
*/

vpr/src/pack/cluster_placement.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ bool get_next_primitive_list(t_intra_cluster_placement_stats* cluster_placement_
210210

211211
// Intialize variables
212212
bool found_best = false;
213-
lowest_cost = HUGE_POSITIVE_FLOAT;
213+
lowest_cost = std::numeric_limits<float>::max();
214214

215215
// Iterate over each primitive block type in the current cluster_placement_stats
216216
for (int i = 0; i < cluster_placement_stats->num_pb_types; i++) {
@@ -241,7 +241,7 @@ bool get_next_primitive_list(t_intra_cluster_placement_stats* cluster_placement_
241241
it->second->pb_graph_node,
242242
primitives_list,
243243
prepacker);
244-
if (cost < HUGE_POSITIVE_FLOAT) {
244+
if (cost < std::numeric_limits<float>::max()) {
245245
cluster_placement_stats->move_primitive_to_inflight(i, it);
246246
return true;
247247
} else {
@@ -481,7 +481,7 @@ static float try_place_molecule(t_intra_cluster_placement_stats* cluster_placeme
481481
t_pb_graph_node* root,
482482
t_pb_graph_node** primitives_list,
483483
const Prepacker& prepacker) {
484-
float cost = HUGE_POSITIVE_FLOAT;
484+
float cost = std::numeric_limits<float>::max();
485485
const t_pack_molecule& molecule = prepacker.get_molecule(molecule_id);
486486
size_t list_size = molecule.atom_block_ids.size();
487487

@@ -502,15 +502,15 @@ static float try_place_molecule(t_intra_cluster_placement_stats* cluster_placeme
502502
primitives_list,
503503
prepacker,
504504
&cost)) {
505-
return HUGE_POSITIVE_FLOAT;
505+
return std::numeric_limits<float>::max();
506506
}
507507
}
508508
for (size_t i = 0; i < list_size; i++) {
509509
VTR_ASSERT((primitives_list[i] == nullptr) == (!molecule.atom_block_ids[i]));
510510
for (size_t j = 0; j < list_size; j++) {
511511
if (i != j) {
512512
if (primitives_list[i] != nullptr && primitives_list[i] == primitives_list[j]) {
513-
return HUGE_POSITIVE_FLOAT;
513+
return std::numeric_limits<float>::max();
514514
}
515515
}
516516
}
@@ -728,4 +728,3 @@ bool exists_free_primitive_for_atom_block(t_intra_cluster_placement_stats* clust
728728
void reset_tried_but_unused_cluster_placements(t_intra_cluster_placement_stats* cluster_placement_stats) {
729729
cluster_placement_stats->flush_intermediate_queues();
730730
}
731-

vpr/src/place/annealer.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,11 @@ PlacementAnnealer::PlacementAnnealer(const t_placer_opts& placer_opts,
259259
// Get the first range limiter
260260
placer_state_.mutable_move().first_rlim = (float)std::max(device_ctx.grid.width() - 1, device_ctx.grid.height() - 1);
261261

262-
annealing_state_ = t_annealing_state(EPSILON, // Set the temperature low to ensure that initial placement quality will be preserved
262+
// In automatic schedule we do a number of random moves before starting the main annealer
263+
// to get an estimate for the initial temperature. We set this temperature low
264+
// to ensure that initial placement quality will be preserved
265+
constexpr float pre_annealing_temp = 1.e-15f;
266+
annealing_state_ = t_annealing_state(pre_annealing_temp,
263267
placer_state_.move().first_rlim,
264268
first_move_lim,
265269
first_crit_exponent);

vpr/src/timing/read_sdc.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "read_sdc.h"
22

3+
#include <limits>
34
#include <regex>
45

56
#include "vtr_log.h"
@@ -741,13 +742,14 @@ class SdcParseCallback : public sdcparse::Callback {
741742
VTR_ASSERT_MSG(capture_clock.period >= 0., "Clock period must be positive");
742743

743744
float constraint = std::numeric_limits<float>::quiet_NaN();
744-
745-
if (std::fabs(launch_clock.period - capture_clock.period) < EPSILON && std::fabs(launch_clock.rise_edge - capture_clock.rise_edge) < EPSILON && std::fabs(launch_clock.fall_edge - capture_clock.fall_edge) < EPSILON) {
745+
if (vtr::isclose(launch_clock.period, capture_clock.period) &&
746+
vtr::isclose(launch_clock.rise_edge, capture_clock.rise_edge) &&
747+
vtr::isclose(launch_clock.fall_edge, capture_clock.fall_edge)) {
746748
//The source and sink domains have the same period and edges, the constraint is the common clock period.
747749

748750
constraint = launch_clock.period;
749751

750-
} else if (launch_clock.period < EPSILON || capture_clock.period < EPSILON) {
752+
} else if (vtr::isclose(launch_clock.period, 0.0) || vtr::isclose(capture_clock.period, 0.0)) {
751753
//If either period is 0, the constraint is 0
752754
constraint = 0.;
753755

0 commit comments

Comments
 (0)