Commit 36623716 by ZhiangWang033

add file

Signed-off-by: ZhiangWang033 <zhw033@ucsd.edu>
parent a04eedcc
......@@ -35,10 +35,11 @@ int main(int argc, char* argv[]) {
PBFNetlist design(netlist_file);
std::string new_netlist_file = run_dir + "/" + design_name + ".pb.txt.final";
std::string new_plc_file = run_dir + "/" + design_name + ".plc.final";
std::string sa_plc_file = run_dir + "/" + design_name;
design.RestorePlacement(plc_file);
auto start_timestamp_global = std::chrono::high_resolution_clock::now();
design.SimulatedAnnealing(action_probs, num_actions, max_temperature,
num_iters, seed, spiral_flag, summary_file);
num_iters, seed, spiral_flag, summary_file, sa_plc_file);
//design.CalcCost();
auto end_timestamp_global = std::chrono::high_resolution_clock::now();
double total_global_time
......
......@@ -58,7 +58,8 @@ class PBFNetlist {
unsigned int num_iters,
int seed,
bool spiral_flag,
std::string summary_file);
std::string summary_file,
std::string plc_file);
// calculate the cost
float CalcCost(bool debug_mode = false);
......
......@@ -424,7 +424,8 @@ void PBFNetlist::SimulatedAnnealing(std::vector<float> action_probs,
unsigned int num_iters,
int seed,
bool spiral_flag,
std::string summary_file) {
std::string summary_file,
std::string plc_file) {
// Initialization
action_probs_ = action_probs;
for (size_t i = 1; i < action_probs_.size(); i++)
......@@ -451,17 +452,17 @@ void PBFNetlist::SimulatedAnnealing(std::vector<float> action_probs,
const float t_factor = std::log(t_min / max_temperature);
float t = max_temperature;
float cur_cost = 0.0;
float min_cost = 0.0;
std::vector<float> cost_list; // we need to plot the cost curve
CallFDPlacer();
cur_cost = CalcCost();
min_cost = cur_cost;
std::ofstream f;
f.open(summary_file);
f.close();
for (int num_iter = 0; num_iter < num_iters; num_iter++) {
// call FDPlacer to update the cost
CallFDPlacer();
cur_cost = CalcCost();
for (int step = 0; step < N; step++) {
if (Action() == true) {
const float new_cost = CalcCostIncr(false);
......@@ -477,13 +478,15 @@ void PBFNetlist::SimulatedAnnealing(std::vector<float> action_probs,
}
cost_list.push_back(cur_cost);
}
if ((num_iter + 1) % 5 == 0) {
CallFDPlacer();
cur_cost = CalcCost();
if ((num_iter + 1) % 100 == 0) {
f.open(summary_file, std::ios::out | std::ios::app);
for (auto& value : cost_list)
f << value << std::endl;
f.close();
cost_list.clear();
WritePlcFile(plc_file + "_step_" + std::to_string(num_iter + 1) + "_cost_" + std::to_string(cur_cost) + ".plc");
}
// update the temperature
t = max_temperature * std::exp(t_factor * num_iter / num_iters);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment