#include "common/common.h" #include "common/db/Database.h" #include "io_parser/gp/GPDatabase.h" #include "gputimer/db/GTDatabase.h" #include "gputimer/core/GPUTimer.h" #include using namespace Flute; namespace Xplace { std::shared_ptr create_gputimer(const py::dict& kwargs, std::shared_ptr rawdb, std::shared_ptr gpdb, std::shared_ptr timing_raw_db) { if (!rawdb->liberty_read) { throw std::invalid_argument("Liberty file not found. Please check!"); } std::shared_ptr gtdb = std::make_shared(rawdb, gpdb, timing_raw_db); auto sdc = std::make_shared(); try { if (kwargs.contains("sdc")) sdc->read(kwargs["sdc"].cast()); } catch (std::exception& e) { logger.error("%s\n", e.what()); } gtdb->ExtractTimingGraph(); gtdb->readSdc(*sdc); std::shared_ptr gputimer = std::make_shared(gtdb, timing_raw_db); readLUT("thirdparty/flute_mp/lut.ICCAD2015/POWV9.dat", "thirdparty/flute_mp/lut.ICCAD2015/POST9.dat"); return gputimer; } PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { pybind11::class_>(m, "GPUTimer") .def(pybind11::init, std::shared_ptr>()) .def("time_unit", >::GPUTimer::time_unit) .def("read_spef", >::GPUTimer::read_spef) .def("init", >::GPUTimer::initialize) .def("levelize", >::GPUTimer::levelize) .def("update_rc", >::GPUTimer::update_rc_timing) .def("update_rc_flute", >::GPUTimer::update_rc_timing_flute) .def("update_rc_spef", >::GPUTimer::update_rc_timing_spef) .def("update_states", >::GPUTimer::update_states) .def("update_timing", >::GPUTimer::update_timing) .def("update_endpoints", >::GPUTimer::update_endpoints) .def("report_wns", >::GPUTimer::report_wns) .def("report_tns_elw", >::GPUTimer::report_tns_elw) .def("report_wns_and_tns", >::GPUTimer::report_wns_and_tns) .def("report_pin_slack", >::GPUTimer::report_pin_slack, py::return_value_policy::move) .def("report_pin_at", >::GPUTimer::report_pin_at, py::return_value_policy::move) .def("report_pin_rat", >::GPUTimer::report_pin_rat, py::return_value_policy::move) .def("report_pin_slew", >::GPUTimer::report_pin_slew, py::return_value_policy::move) .def("report_pin_load", >::GPUTimer::report_pin_load, py::return_value_policy::move) .def("report_endpoint_slack", >::GPUTimer::report_endpoint_slack, py::return_value_policy::move) .def("endpoints_index", >::GPUTimer::endpoints_index, py::return_value_policy::copy) .def("report_path", >::GPUTimer::report_path, py::return_value_policy::copy) .def("report_K_path", >::GPUTimer::report_K_path, py::return_value_policy::copy) .def("report_criticality", >::GPUTimer::report_criticality, py::return_value_policy::copy) .def("report_criticality_threshold", >::GPUTimer::report_criticality_threshold, py::return_value_policy::copy) ; pybind11::class_>(m, "TimingTorchRawDB") .def(pybind11::init()) .def("commit_from", >::TimingTorchRawDB::commit_from) .def("get_curr_cposx", >::TimingTorchRawDB::get_curr_cposx, py::return_value_policy::move) .def("get_curr_cposy", >::TimingTorchRawDB::get_curr_cposy, py::return_value_policy::move) .def("get_curr_lposx", >::TimingTorchRawDB::get_curr_lposx, py::return_value_policy::move) .def("get_curr_lposy", >::TimingTorchRawDB::get_curr_lposy, py::return_value_policy::move); pybind11::class_>(m, "GTDatabase") .def(pybind11::init, std::shared_ptr, std::shared_ptr>()); m.def("create_gputimer", &create_gputimer, "Create gputimer object"); m.def("create_timing_rawdb", [](torch::Tensor node_lpos_init_, torch::Tensor node_size_, torch::Tensor pin_rel_lpos_, torch::Tensor pin_id2node_id_, torch::Tensor pin_id2net_id_, torch::Tensor node2pin_list_, torch::Tensor node2pin_list_end_, torch::Tensor hyperedge_list_, torch::Tensor hyperedge_list_end_, torch::Tensor net_mask_, int num_movable_nodes_, float scale_factor_, int microns_, float wire_resistance_per_micron_, float wire_capacitance_per_micron_) { return std::make_shared(node_lpos_init_, node_size_, pin_rel_lpos_, pin_id2node_id_, pin_id2net_id_, node2pin_list_, node2pin_list_end_, hyperedge_list_, hyperedge_list_end_, net_mask_, num_movable_nodes_, scale_factor_, microns_, wire_resistance_per_micron_, wire_capacitance_per_micron_); }); } } // namespace Xplace