MCPcopy Create free account
hub / github.com/NVlabs/AutoDMP / write

Method write

dreamplace/ops/place_io/src/DefWriter.cpp:11–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9#include <fstream>
10
11DREAMPLACE_BEGIN_NAMESPACE
12
13bool DefWriter::write(std::string const& outFile, std::string const& inFile,
14 std::vector<Node> const& vNode, std::vector<PlaceDB::index_type> const& vNodeIndex,
15 PlaceDB::coordinate_type const* x, PlaceDB::coordinate_type const* y) const
16{
17 std::ifstream in (inFile.c_str());
18 FILE* out = fopen(outFile.c_str(), "w");
19 std::string line;
20 std::string nodeName;
21 std::size_t pos1, pos2;
22 bool flag = false; // whether in COMPONENTS block
23 std::size_t rowCount = 0;
24
25 dreamplacePrint(kINFO, "writing placement to %s\n", outFile.c_str());
26
27 if (!in.good())
28 {
29 dreamplacePrint(kERROR, "unable to open %s for read\n", inFile.c_str());
30 return false;
31 }
32 if (out == NULL)
33 {
34 dreamplacePrint(kERROR, "unable to open %s for write\n", outFile.c_str());
35 return false;
36 }
37
38 while (getline(in, line))
39 {
40 line = trim(line);
41 pos1 = line.find("END");
42 pos2 = line.find("COMPONENTS");
43 if (pos1 != std::string::npos &&
44 pos2 != std::string::npos) // match "END COMPONENTS"
45 {
46 // found "END COMPONENTS"
47 // dump positions here
48 writeCompBlock(out, vNode, vNodeIndex, x, y);
49
50 flag = false;
51 continue;
52 }
53 else if (pos2 != std::string::npos) // match "COMPONENTS"
54 {
55 flag = true;
56 continue;
57 }
58
59 if (flag) {/* skip everything in a COMPONENTS block */}
60 else
61 {
62 if (line.substr(0, 3) == "ROW") // match "ROW" entry, it does not hurt even if not matched; mainly for modification of benchmarks
63 {
64 Row const& row = m_db.row(rowCount);
65 fprintf(out, "ROW %s %s %d %d %s DO %u BY %u STEP %d %d ",
66 row.name().c_str(), row.macroName().c_str(),
67 row.xl(), row.yl(), std::string(row.orient()).c_str(),
68 row.numSites(kX), (row.step(kY) == 0)? 1 : row.numSites(kY), row.step(kX), row.step(kY));

Callers

nothing calls this directly

Calls 5

dreamplacePrintFunction · 0.85
nameMethod · 0.80
xlMethod · 0.80
ylMethod · 0.80
stepMethod · 0.80

Tested by

no test coverage detected