palaniappan-r's picture
Add markdown sources
d59bb1b verified

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. In that repository, I only can know how to use the legacy one 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( 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.

#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.

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.