File size: 4,717 Bytes
660c0b5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# Using each tools (i.e. OpenDB, RePlAce, OpenDP..) as a submodule

Tool: OpenDB

Subcategory: Usage question

## Conversation

### ApeachM
Now I'd like to use OpenDB Framework and am searching for how to use each tool (i.e. OpenDB, OpenDB, etc) in **the OpenROAD repository** as a submodule for my open-source project.

For example, I'm using the OpenDB Framework as [this repository](https://github.com/ApeachM/EDA-API).
In that repository, I only can know how to use the [legacy one](https://github.com/The-OpenROAD-Project/OpenDB) as a submodule, but couldn't find how to set the OpenROAD repository as a submodule.

I would be very appreciative if there is any recommended way to use each tool (like RePlAce, OpenDP, ..) in the OpenROAD repository which is now updated recently, and if you let me know them.
 
Thank you for reading my question.

Best regards.



### maliberty
We do not offer each tool as a submodule.  It is a lot of overhead to manage submodules (we did that initially).   You could make OR itself a submodule and link to the portions you wish.

### maliberty
You should be able to reference our libraries from your app like

target_link_libraries(<mystuff>
  PUBLIC
    odb

)


you would need to include src/CMakeLists.txt

### maliberty
@QuantamHD what do you think about applying your library separation work to mpl2?

### ApeachM
@QuantamHD 
> @ApeachM I'll ask you for a favor back. If you do end up running mpl2 in your project can you contribute some C++ unit tests back to the project? https://github.com/The-OpenROAD-Project/OpenROAD/pull/3109/files#diff-24b9bab7be8fe0944c3ae7ccbd1d8700449a2e965d33d624fd7f8e3315ebdc9e

I'd like to do the favor that you mentioned, but I have a question for you.
Now I'm struggling to construct the unit test for mpl2, but there are several problems with making it.

### 1. The construction dependency exists. 

At least calling `void MacroPlacer2::init(sta::dbNetwork* network, odb::dbDatabase* db, sta::dbSta* sta, utl::Logger* logger, par::PartitionMgr* tritonpart)` function, I need `sta::dbNetwork` and `sta::dbSta` in the test code like below.

```cpp

#include <unistd.h>



#include <memory>



#include "gtest/gtest.h"

#include "mpl2/rtl_mp.h"

#include "db_sta/dbSta.hh"

#include "par/PartitionMgr.h"

#include "utl/Logger.h"



namespace mpl2 {



TEST(Mpl2, CanConstruct)

{

  MacroPlacer2();

}



TEST(Mpl2, init){

  MacroPlacer2 macro_placer_2{};



  sta::dbSta* db_sta = new sta::dbSta;

  sta::dbNetwork* db_network = db_sta->getDbNetwork();

  odb::dbDatabase* db_database = odb::dbDatabase::create();

  utl::Logger logger;

  par::PartitionMgr partition_mgr;



  /**

   * Construct some data in dbDatabase and dbSta by parsing or calling their methods..

   * */

  partition_mgr.init(db_database, db_network, db_sta, &logger);

  macro_placer_2.init(db_network, db_database, db_sta, &logger, &partition_mgr);

}

};  // namespace mpl2

```



But at `line 21`: `sta::dbSta* db_sta = new sta::dbSta;` an error occurs with the below message.

```shell

OpenROAD/src/mpl2/test/cpp/mpl2_test.cc:21: undefined reference to `sta::dbSta::dbSta()'

```



I think this problem is due to a linking issue; `dbSta_lib` library doesn’t link `dbSta.cc`, but links only `dbSta.hh`.

The `DbSta.cc` file is dependent on `ord::OpenRoad::Observer::Observer()`, so it’s a pretty tricky thing to link with `mpl2_test` library and `sta::dbSta`. 

Is there any proposed method to use `sta::dbSta` in the `OpenROAD/src/mpl2/test/cpp/mpl2_test.cc` file? Unless, I think I can’t make unit test for the one after `mpl2.init(sta::dbNetwork, ..., utl::Logger)`. 



### 2. Unless editing code in mpl2/src/*.cpp, there aren’t many things to make unit test.



For making the unit test for `MacroPlacer2`, I can only call Constructor, Destructor, `init()`, and `place()`. 



Even though the assumption of linking the `mpl2_test` library and `hier_rtlmp.h, hier_rtlmp.cpp`, the `HierRTLMP` has public functions only for setters (`setGlobalFence`, …,`setDebug`) and the top interface (`hierRTLMacroPlacer()`). 



To test whether the `HierRTLMP` is properly working, I think I need to make some accessors to private variables (like `getGlobalFence` …). But I can’t assure you that it’s okay for me to edit the codes in mpl2/src/*.cpp.

### 

### Conclusion

If the first problem is solved, the second problem says there are not so many things to make unit test unless I edit the codes.

I’d like to ask how I can solve problem 1 (the linking issue for `sta::dbSta`), and whether it’s okay or not to edit the code except the test code.



Thank you for reading my questions.