Commit f8766c7e by ZhiangWang033

add fast cpp implementation

parent 5bed6913
{
"files.associations": {
"array": "cpp",
"atomic": "cpp",
"*.tcc": "cpp",
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"deque": "cpp",
"unordered_map": "cpp",
"vector": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"iterator": "cpp",
"map": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"optional": "cpp",
"random": "cpp",
"string": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"fstream": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"new": "cpp",
"ostream": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"typeinfo": "cpp"
}
}
\ No newline at end of file
...@@ -1057,15 +1057,15 @@ class PBFNetlist: ...@@ -1057,15 +1057,15 @@ class PBFNetlist:
y_dir = 0 y_dir = 0
src_width = src_ux - src_lx src_width = src_ux - src_lx
src_height = src_uy - src_ly src_height = src_uy - src_ly
target_width = target_ux - target_lx target_width = target_ux - target_lx
target_height = target_uy - target_ly target_height = target_uy - target_ly
src_cx = (src_lx + src_ux) / 2.0 src_cx = (src_lx + src_ux) / 2.0
src_cy = (src_ly + src_uy) / 2.0 src_cy = (src_ly + src_uy) / 2.0
target_cx = (target_lx + target_ux) / 2.0 target_cx = (target_lx + target_ux) / 2.0
target_cy = (target_ly + target_uy) / 2.0 target_cy = (target_ly + target_uy) / 2.0
min_dist = 1e-4 min_dist = 1e-4
x_min_dist = (src_width + target_width) / 2.0 x_min_dist = (src_width + target_width) / 2.0
y_min_dist = (src_height + target_height) / 2.0 y_min_dist = (src_height + target_height) / 2.0
...@@ -1075,8 +1075,8 @@ class PBFNetlist: ...@@ -1075,8 +1075,8 @@ class PBFNetlist:
if (abs(target_cy - src_cy) > (y_min_dist - min_dist)): if (abs(target_cy - src_cy) > (y_min_dist - min_dist)):
# there is no overlap # there is no overlap
return None, None return None, None
# there is no overlap # there is no overlap
if (src_cx == target_cx and src_cy == target_cy): if (src_cx == target_cx and src_cy == target_cy):
# fully overlap # fully overlap
x_dir = -1.0 x_dir = -1.0
......
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"C_Cpp.errorSquiggles": "disabled"
}
\ No newline at end of file
...@@ -6,23 +6,27 @@ int main(int argc, char* argv[]) { ...@@ -6,23 +6,27 @@ int main(int argc, char* argv[]) {
std::string netlist_file = argv[1]; std::string netlist_file = argv[1];
std::string plc_file = argv[2]; std::string plc_file = argv[2];
PBFNetlist design(netlist_file); PBFNetlist design(netlist_file);
std::string new_netlist_file = netlist_file + ".new"; std::string new_netlist_file = netlist_file + ".os_cpp.txt";
design.WriteNetlist(new_netlist_file); design.WriteNetlist(new_netlist_file);
design.RestorePlacement(plc_file); design.RestorePlacement(plc_file);
const float io_factor = 1.0; const float io_factor = 1.0;
const std::vector<int> num_steps { 10, 10, 10 };
const std::vector<float> attract_factor { 100, 1.0e-3, 1.0e-5 }; const std::vector<int> num_steps { 100, 100, 100 };
const std::vector<float> repel_factor { 0.0, 1.0e6, 1.0e6 }; const std::vector<float> attract_factor { 100.0, 1.0e-3, 1.0e-5 };
const std::vector<float> repel_factor { 0.0, 1.0e6, 1.0e7 };
const std::vector<float> move_distance_factor { 1.0, 1.0, 1.0 }; const std::vector<float> move_distance_factor { 1.0, 1.0, 1.0 };
const bool use_current_loc = false; const bool use_current_loc = false;
const bool debug_mode = false; const bool debug_mode = true;
auto start_timestamp_global = std::chrono::high_resolution_clock::now(); auto start_timestamp_global = std::chrono::high_resolution_clock::now();
design.FDPlacer(io_factor, num_steps, design.FDPlacer(io_factor, num_steps,
move_distance_factor, move_distance_factor,
attract_factor, attract_factor,
repel_factor, repel_factor,
use_current_loc, use_current_loc,
debug_mode); debug_mode);
auto end_timestamp_global = std::chrono::high_resolution_clock::now(); auto end_timestamp_global = std::chrono::high_resolution_clock::now();
double total_global_time double total_global_time
= std::chrono::duration_cast<std::chrono::nanoseconds>( = std::chrono::duration_cast<std::chrono::nanoseconds>(
...@@ -30,6 +34,6 @@ int main(int argc, char* argv[]) { ...@@ -30,6 +34,6 @@ int main(int argc, char* argv[]) {
.count(); .count();
total_global_time *= 1e-9; total_global_time *= 1e-9;
std::cout << "Runtime of FDPlacer : " << total_global_time << std::endl; std::cout << "Runtime of FDPlacer : " << total_global_time << std::endl;
design.WritePlcFile(plc_file + ".new"); design.WritePlcFile(plc_file + ".os_cpp.txt");
return 0; return 0;
} }
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