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
4 changes: 4 additions & 0 deletions src/rmp/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ cc_library(
name = "rmp",
srcs = [
"src/Restructure.cpp",
"src/annealing_strategy.cpp",
"src/annealing_strategy.h",
"src/delay_optimization_strategy.cpp",
"src/delay_optimization_strategy.h",
"src/logic_optimization_strategy.h",
"src/resynthesis_strategy.h",
"src/utils.cpp",
"src/utils.h",
"src/zero_slack_strategy.cpp",
"src/zero_slack_strategy.h",
],
Expand Down
30 changes: 30 additions & 0 deletions src/rmp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,36 @@ resynth
| ----- | ----- |
| `-corner` | Process corner to use. |

### Resynth with simulated annealing

Resynthesize parts of the design with an ABC script found via simulated annealing.
The script is a series of operations on ABC's internal AIG data structure.
A neighboring solution is a script with one operation added, removed, or two operations swapped.
The optimization function is defined as the worst slack.

```tcl
resynth_annealing
[-corner corner]
[-slack_threshold slack_threshold]
[-seed seed]
[-temp temp]
[-iters iters]
[-revert_after revert_after]
[-initial_ops initial_ops]
```

#### Options

| Switch Name | Description |
| ----- | ----- |
| `-corner` | Process corner to use. |
| `-slack_threshold` | Specifies a (setup) timing slack value below which timing paths need to be analyzed for restructuring. The default value is `0`. |
| `-seed` | Seed to use for randomness in simulated annealing. |
| `-temp` | Initial temperature for simulated annealing. The default is the required arrival time on the worst slack endpoint. |
| `-iters` | Number of iterations to run simulated annealing for. |
| `-revert_after` | After the given number of iterations that worsen slack, revert to best found solution. |
| `-initial_ops` | Size of the initial random solution (number of commands in the script for ABC). |

## Example scripts

Example scripts on running `rmp` for a sample design of `gcd` as follows:
Expand Down
18 changes: 18 additions & 0 deletions src/rmp/include/rmp/Restructure.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,22 @@ class Restructure

void reset();
void resynth(sta::Corner* corner);
void resynthAnnealing(sta::Corner* corner);
void run(char* liberty_file_name,
float slack_threshold,
unsigned max_depth,
char* workdir_name,
char* abc_logfile);

void setAnnealingSeed(uint64_t seed) { annealing_seed_ = seed; }
void setAnnealingTemp(float temp) { annealing_temp_ = temp; }
void setAnnealingIters(unsigned iters) { annealing_iters_ = iters; }
void setAnnealingRevertAfter(unsigned revert_after)
{
annealing_revert_after_ = revert_after;
}
void setAnnealingInitialOps(unsigned ops) { annealing_init_ops_ = ops; }
void setSlackThreshold(sta::Slack thresh) { slack_threshold_ = thresh; }
void setMode(const char* mode_name);
void setTieLoPort(sta::LibertyPort* loport);
void setTieHiPort(sta::LibertyPort* hiport);
Expand Down Expand Up @@ -106,6 +116,14 @@ class Restructure
est::EstimateParasitics* estimate_parasitics_;
odb::dbBlock* block_ = nullptr;

// Annealing
std::optional<uint64_t> annealing_seed_;
std::optional<float> annealing_temp_;
unsigned annealing_iters_ = 100;
std::optional<unsigned> annealing_revert_after_;
unsigned annealing_init_ops_ = 10;
sta::Slack slack_threshold_ = 0;

std::string input_blif_file_name_;
std::string output_blif_file_name_;
std::vector<std::string> lib_file_names_;
Expand Down
11 changes: 9 additions & 2 deletions src/rmp/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,17 @@ swig_lib(NAME rmp

add_library(rmp_lib
Restructure.cpp
annealing_strategy.cpp
delay_optimization_strategy.cpp
utils.cpp
zero_slack_strategy.cpp
)

# For ABC headers
set_source_files_properties(annealing_strategy.cpp
PROPERTIES COMPILE_FLAGS "-Wno-error=redundant-decls -Wno-error=unused-variable -Wno-error=unused-but-set-variable"
)

target_sources(rmp
PRIVATE
MakeRestructure.cpp
Expand All @@ -42,7 +49,7 @@ target_include_directories(rmp_lib
PUBLIC
../include
)

target_link_libraries(rmp_lib
PUBLIC
odb
Expand All @@ -58,7 +65,7 @@ target_link_libraries(rmp
PRIVATE
rmp_lib
)

if (Python3_FOUND AND BUILD_PYTHON)
swig_lib(NAME rmp_py
NAMESPACE rmp
Expand Down
14 changes: 14 additions & 0 deletions src/rmp/src/Restructure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <utility>
#include <vector>

#include "annealing_strategy.h"
#include "base/abc/abc.h"
#include "base/main/abcapis.h"
#include "cut/abc_init.h"
Expand Down Expand Up @@ -87,6 +88,19 @@ void Restructure::resynth(sta::Corner* corner)
open_sta_, name_generator_, resizer_, logger_);
}

void Restructure::resynthAnnealing(sta::Corner* corner)
{
AnnealingStrategy annealing_strategy(corner,
slack_threshold_,
annealing_seed_,
annealing_temp_,
annealing_iters_,
annealing_revert_after_,
annealing_init_ops_);
annealing_strategy.OptimizeDesign(
open_sta_, name_generator_, resizer_, logger_);
}

void Restructure::run(char* liberty_file_name,
float slack_threshold,
unsigned max_depth,
Expand Down
Loading