Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions src/mpl/src/SACoreSoftMacro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "SACoreSoftMacro.h"

#include <algorithm>
#include <boost/random/uniform_int_distribution.hpp>
#include <cmath>
#include <map>
#include <set>
Expand Down Expand Up @@ -713,15 +714,17 @@ void SACoreSoftMacro::calNotchPenalty()

void SACoreSoftMacro::resizeOneCluster()
{
// TODO: See for explanation
// https://github.com/The-OpenROAD-Project/OpenROAD/pull/6649
float random_variable_0_1;
do {
random_variable_0_1 = distribution_(generator_);
} while (random_variable_0_1 >= 1.0);

const int idx
= static_cast<int>(std::floor(random_variable_0_1 * pos_seq_.size()));
if (pos_seq_.empty()) {
logger_->error(
utl::MPL,
51,
"Position sequence array is empty, please report this internal error");
}

boost::random::uniform_int_distribution<> index_distribution(
0, pos_seq_.size() - 1);
const int idx = index_distribution(generator_);

macro_id_ = idx;
SoftMacro& src_macro = macros_[idx];
if (src_macro.isMacroCluster()) {
Expand Down
26 changes: 7 additions & 19 deletions src/mpl/src/SimulatedAnnealingCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "SimulatedAnnealingCore.h"

#include <algorithm>
#include <boost/random/uniform_int_distribution.hpp>
#include <cmath>
#include <fstream>
#include <iostream>
Expand Down Expand Up @@ -601,27 +602,14 @@ void SimulatedAnnealingCore<T>::exchangeMacros()
template <class T>
void SimulatedAnnealingCore<T>::generateRandomIndices(int& index1, int& index2)
{
// TODO: See for explanation.
// https://github.com/The-OpenROAD-Project/OpenROAD/pull/6649
// This code is ugly on purpose to incentivize merging the proper
// fix.
float random_variable_0_1_index1;
float random_variable_0_1_index2;
do {
random_variable_0_1_index1 = distribution_(generator_);
random_variable_0_1_index2 = distribution_(generator_);
} while (random_variable_0_1_index1 >= 1.0
|| random_variable_0_1_index2 >= 1.0);

index1 = (int) (std::floor(random_variable_0_1_index1 * pos_seq_.size()));
index2 = (int) (std::floor(random_variable_0_1_index2 * pos_seq_.size()));
boost::random::uniform_int_distribution<> index_distribution(
0, pos_seq_.size() - 1);

while (index1 == index2) {
do {
random_variable_0_1_index2 = distribution_(generator_);
} while (random_variable_0_1_index2 >= 1.0);
index1 = index_distribution(generator_);
index2 = index_distribution(generator_);

index2 = (int) (std::floor(random_variable_0_1_index2 * pos_seq_.size()));
while (index1 == index2) {
index2 = index_distribution(generator_);
}
}

Expand Down
13 changes: 5 additions & 8 deletions src/mpl/src/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "object.h"

#include <algorithm>
#include <boost/random/uniform_int_distribution.hpp>
#include <cmath>
#include <map>
#include <memory>
Expand Down Expand Up @@ -1239,15 +1240,11 @@ void SoftMacro::resizeRandomly(
if (width_list_.empty()) {
return;
}
// TODO: See for explanation
// https://github.com/The-OpenROAD-Project/OpenROAD/pull/6649
float random_variable_0_1;
do {
random_variable_0_1 = distribution(generator);
} while (random_variable_0_1 >= 1.0);

const int idx
= static_cast<int>(std::floor(random_variable_0_1 * width_list_.size()));
boost::random::uniform_int_distribution<> index_distribution(
0, width_list_.size() - 1);
const int idx = index_distribution(generator);

const float min_width = width_list_[idx].first;
const float max_width = width_list_[idx].second;
width_ = min_width + distribution(generator) * (max_width - min_width);
Expand Down
8 changes: 4 additions & 4 deletions src/mpl/test/boundary_push2.defok
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,10 @@ TRACKS Y 140 DO 282 STEP 3200 LAYER metal9 ;
TRACKS X 190 DO 282 STEP 3200 LAYER metal10 ;
TRACKS Y 140 DO 282 STEP 3200 LAYER metal10 ;
COMPONENTS 54 ;
- MACRO_1 HM_100x100_1x1 + FIXED ( 239440 222090 ) S ;
- MACRO_2 HM_100x100_1x1 + FIXED ( 600 222090 ) FS ;
- MACRO_3 HM_100x100_1x1 + FIXED ( 239440 21050 ) FS ;
- MACRO_4 HM_100x100_1x1 + FIXED ( 600 21050 ) FS ;
- MACRO_1 HM_100x100_1x1 + FIXED ( 600 21050 ) S ;
- MACRO_2 HM_100x100_1x1 + FIXED ( 239440 222090 ) FS ;
- MACRO_3 HM_100x100_1x1 + FIXED ( 600 222090 ) FS ;
- MACRO_4 HM_100x100_1x1 + FIXED ( 239440 21050 ) FS ;
- _001_ DFF_X1 + PLACED ( 15591 18600 ) N ;
- _002_ DFF_X1 + PLACED ( 15591 18600 ) N ;
- _003_ DFF_X1 + PLACED ( 15591 18600 ) N ;
Expand Down
8 changes: 4 additions & 4 deletions src/mpl/test/boundary_push3.defok
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,10 @@ TRACKS Y 140 DO 282 STEP 3200 LAYER metal9 ;
TRACKS X 190 DO 282 STEP 3200 LAYER metal10 ;
TRACKS Y 140 DO 282 STEP 3200 LAYER metal10 ;
COMPONENTS 54 ;
- MACRO_1 HM_100x100_1x1 + FIXED ( 19420 242250 ) S ;
- MACRO_2 HM_100x100_1x1 + FIXED ( 19420 890 ) FS ;
- MACRO_3 HM_100x100_1x1 + FIXED ( 220620 242250 ) FS ;
- MACRO_4 HM_100x100_1x1 + FIXED ( 220620 890 ) FS ;
- MACRO_1 HM_100x100_1x1 + FIXED ( 19420 890 ) S ;
- MACRO_2 HM_100x100_1x1 + FIXED ( 19420 242250 ) FS ;
- MACRO_3 HM_100x100_1x1 + FIXED ( 220620 890 ) FS ;
- MACRO_4 HM_100x100_1x1 + FIXED ( 220620 242250 ) FS ;
- _001_ DFF_X1 + PLACED ( 15590 18601 ) N ;
- _002_ DFF_X1 + PLACED ( 15590 18601 ) N ;
- _003_ DFF_X1 + PLACED ( 15590 18601 ) N ;
Expand Down
Loading