refine code structure to accelerate compilation time

This commit is contained in:
liulixinkerry 2024-11-23 13:09:12 +08:00
parent af663f475c
commit 500ed28a7f
51 changed files with 729 additions and 420 deletions

View File

@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.12) cmake_minimum_required(VERSION 3.18)
project(xplace C CXX) project(xplace LANGUAGES C CXX CUDA)
if(NOT CMAKE_BUILD_TYPE) if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release) set(CMAKE_BUILD_TYPE Release)
@ -48,7 +48,25 @@ find_package(Cairo)
message(STATUS "CAIRO_INCLUDE_DIRS: ${CAIRO_INCLUDE_DIRS}") message(STATUS "CAIRO_INCLUDE_DIRS: ${CAIRO_INCLUDE_DIRS}")
message(STATUS "CAIRO_LIBRARIES: ${CAIRO_LIBRARIES}") message(STATUS "CAIRO_LIBRARIES: ${CAIRO_LIBRARIES}")
# Get Torch info # CUDA
# set cuda arch and nvcc flags
if (NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
set(CMAKE_CUDA_ARCHITECTURES 80 86 CACHE STRING "CUDA architectures" FORCE)
endif()
message(STATUS "CMAKE_CUDA_ARCHITECTURES: ${CMAKE_CUDA_ARCHITECTURES}")
find_package(CUDAToolkit)
# set nvcc flags
set(CUDA_USE_STATIC_CUDA_RUNTIME OFF)
set(CMAKE_CUDA17_EXTENSION_COMPILE_OPTION "-std=c++17")
list(APPEND BASIC_CUDA_FLAGS --compiler-options;-fPIC;-std=c++17)
list(APPEND BASIC_CUDA_FLAGS --expt-relaxed-constexpr) # suppress warning from pytorch
message(STATUS "BASIC_CUDA_FLAGS: ${BASIC_CUDA_FLAGS}")
add_compile_options(
"$<$<COMPILE_LANGUAGE:CUDA>:${BASIC_CUDA_FLAGS}>"
)
# Torch
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c execute_process(COMMAND ${PYTHON_EXECUTABLE} -c
"import torch; print(torch.__path__[0]); print(int(torch.cuda.is_available())); print(torch.__version__);" "import torch; print(torch.__path__[0]); print(int(torch.cuda.is_available())); print(torch.__version__);"
OUTPUT_VARIABLE TORCH_OUTPUT OUTPUT_STRIP_TRAILING_WHITESPACE) OUTPUT_VARIABLE TORCH_OUTPUT OUTPUT_STRIP_TRAILING_WHITESPACE)
@ -61,35 +79,10 @@ list(GET TORCH_VERSION_LIST 0 TORCH_VERSION_MAJOR)
list(GET TORCH_VERSION_LIST 1 TORCH_VERSION_MINOR) list(GET TORCH_VERSION_LIST 1 TORCH_VERSION_MINOR)
message(STATUS TORCH_INSTALL_PREFIX=${TORCH_INSTALL_PREFIX}) message(STATUS TORCH_INSTALL_PREFIX=${TORCH_INSTALL_PREFIX})
message(STATUS TORCH_VERSION=${TORCH_VERSION_MAJOR}.${TORCH_VERSION_MINOR}) message(STATUS TORCH_VERSION=${TORCH_VERSION_MAJOR}.${TORCH_VERSION_MINOR})
# find CUDA
if (TORCH_ENABLE_CUDA)
find_package(CUDA 11.4)
find_package(CUDAToolkit)
if (NOT CUDA_FOUND)
set(TORCH_ENABLE_CUDA 0 CACHE BOOL "Whether enable CUDA" FORCE)
message(FATAL_ERROR "Xplace only supports CUDA mode, CMake will exit." )
endif(NOT CUDA_FOUND)
endif()
message(STATUS TORCH_ENABLE_CUDA=${TORCH_ENABLE_CUDA}) message(STATUS TORCH_ENABLE_CUDA=${TORCH_ENABLE_CUDA})
if (NOT TORCH_ENABLE_CUDA)
# set cuda arch and nvcc flags message(FATAL_ERROR "Xplace only supports Torch-CUDA mode, exit CMAKE." )
if (CUDA_FOUND) endif()
if (NOT CUDA_ARCH_LIST)
set(CUDA_ARCH_LIST 6.0 6.1 7.0 7.5 8.0 8.6)
endif(NOT CUDA_ARCH_LIST)
# for cuda_add_library
cuda_select_nvcc_arch_flags(CUDA_ARCH_FLAGS ${CUDA_ARCH_LIST})
message(STATUS "CUDA_ARCH_FLAGS: ${CUDA_ARCH_FLAGS}")
# set nvcc flags
set(CUDA_USE_STATIC_CUDA_RUNTIME OFF)
set(CMAKE_CUDA17_EXTENSION_COMPILE_OPTION "-std=c++17")
list(APPEND CUDA_NVCC_FLAGS ${CUDA_ARCH_FLAGS} --compiler-options;-fPIC;-std=c++17)
list(APPEND CUDA_NVCC_FLAGS ${CUDA_ARCH_FLAGS} --extended-lambda)
list(APPEND TORCH_NVCC_FLAGS --expt-relaxed-constexpr)
list(APPEND CUDA_NVCC_FLAGS ${TORCH_NVCC_FLAGS})
message(STATUS "CUDA_NVCC_FLAGS: ${CUDA_NVCC_FLAGS}")
endif(CUDA_FOUND)
# set torch lib # set torch lib
add_library(torch STATIC IMPORTED) add_library(torch STATIC IMPORTED)
@ -131,7 +124,7 @@ function(add_pytorch_extension target_name)
set(CUDA_SRCS "${ARG_UNPARSED_ARGUMENTS}") set(CUDA_SRCS "${ARG_UNPARSED_ARGUMENTS}")
list(FILTER CUDA_SRCS INCLUDE REGEX ".*cu$") list(FILTER CUDA_SRCS INCLUDE REGEX ".*cu$")
if (CUDA_SRCS) if (CUDA_SRCS)
cuda_add_library(${target_name}_cuda_tmp STATIC ${CUDA_SRCS}) add_library(${target_name}_cuda_tmp STATIC ${CUDA_SRCS})
target_include_directories(${target_name}_cuda_tmp PRIVATE ${ARG_EXTRA_INCLUDE_DIRS} ${TORCH_INCLUDE_DIRS}) target_include_directories(${target_name}_cuda_tmp PRIVATE ${ARG_EXTRA_INCLUDE_DIRS} ${TORCH_INCLUDE_DIRS})
target_link_libraries(${target_name}_cuda_tmp ${ARG_EXTRA_LINK_LIBRARIES} ${TORCH_LIBRARY}) target_link_libraries(${target_name}_cuda_tmp ${ARG_EXTRA_LINK_LIBRARIES} ${TORCH_LIBRARY})
target_compile_definitions(${target_name}_cuda_tmp PRIVATE target_compile_definitions(${target_name}_cuda_tmp PRIVATE

View File

@ -59,7 +59,7 @@ make -j40 && make install
``` ```
### 1.1. Dependencies ### 1.1. Dependencies
- [CMake](https://cmake.org/) >= 3.17 - [CMake](https://cmake.org/) >= 3.18
- [GCC](https://gcc.gnu.org/) >= 7.5.0 - [GCC](https://gcc.gnu.org/) >= 7.5.0
- [Boost](https://www.boost.org/) >= 1.56.0 - [Boost](https://www.boost.org/) >= 1.56.0
- [CUDA](https://developer.nvidia.com/cuda-toolkit) >= 11.3 - [CUDA](https://developer.nvidia.com/cuda-toolkit) >= 11.3

View File

@ -1,6 +1,10 @@
#pragma once #pragma once
#include <vector>
namespace db { namespace db {
using std::vector;
class BsRouteInfo { class BsRouteInfo {
// specially restore ICCAD2012/DAC2012 bookshelf routing info // specially restore ICCAD2012/DAC2012 bookshelf routing info
public: public:

View File

@ -1,4 +1,9 @@
#include "Database.h" #include "Cell.h"
#include "DatabaseClass.h"
#include "Geometry.h"
#include "Pin.h"
using namespace db; using namespace db;
/***** Cell *****/ /***** Cell *****/
@ -37,9 +42,7 @@ void Cell::ctype(CellType* t) {
int Cell::lx() const { return _lx; } int Cell::lx() const { return _lx; }
int Cell::ly() const { return _ly; } int Cell::ly() const { return _ly; }
int Cell::orient() const { int Cell::orient() const { return _orient; }
return _orient;
}
bool Cell::placed() const { return (lx() != INT_MIN) && (ly() != INT_MIN); } bool Cell::placed() const { return (lx() != INT_MIN) && (ly() != INT_MIN); }
// int Cell::siteWidth() const { return width() / database.siteW; } // int Cell::siteWidth() const { return width() / database.siteW; }

View File

@ -1,6 +1,24 @@
#pragma once #pragma once
#include <iostream>
#include <string>
#include <vector>
#include "Geometry.h"
namespace db { namespace db {
using std::string;
using std::vector;
class CellType;
class Cell;
class Database;
class Rectangle;
class Geometry;
class Pin;
class Region;
class Net;
class PinType;
class CellType { class CellType {
friend class Database; friend class Database;

View File

@ -1,11 +1,32 @@
#include "Database.h" #include "Database.h"
#include "BsRouteInfo.h"
#include "Cell.h"
#include "DatabaseClass.h"
#include "DesignRule.h"
#include "GCellGrid.h"
#include "Geometry.h"
#include "Layer.h"
#include "Net.h"
#include "Pin.h"
#include "Region.h"
#include "Row.h"
#include "SNet.h"
#include "Site.h"
#include "SiteMap.h"
#include "Via.h"
using namespace db; using namespace db;
/***** Database *****/ /***** Database *****/
Database::Database() { Database::Database() {
clear(); clear();
_buffer = new char[_bufferCapacity]; _buffer = new char[_bufferCapacity];
powerNet = new PowerNet();
siteMap = new SiteMap();
gcellgrid = new GCellGrid();
bsRouteInfo = new BsRouteInfo();
edgetypes = new EdgeTypes();
} }
Database::~Database() { Database::~Database() {
@ -72,16 +93,15 @@ void Database::reset() {
name_viatypes.clear(); name_viatypes.clear();
layers.clear(); layers.clear();
sites.clear();
routeBlockages.clear(); routeBlockages.clear();
placeBlockages.clear(); placeBlockages.clear();
powerNet = PowerNet(); powerNet = new PowerNet();
siteMap = new SiteMap();
siteMap = SiteMap(); gcellgrid = new GCellGrid();
gcellgrid = GCellGrid(); bsRouteInfo = new BsRouteInfo();
edgetypes = EdgeTypes(); edgetypes = new EdgeTypes();
dbIssues.clear(); dbIssues.clear();
dieLX = 0; dieLX = 0;
@ -114,6 +134,11 @@ void Database::clearTechnology() {
CLEAR_POINTER_MAP(ndrs); CLEAR_POINTER_MAP(ndrs);
} }
void Database::clearLibrary() {
CLEAR_POINTER_LIST(lefsites);
CLEAR_POINTER_LIST(celltypes);
}
void Database::clearDesign() { void Database::clearDesign() {
CLEAR_POINTER_LIST(cells); CLEAR_POINTER_LIST(cells);
CLEAR_POINTER_LIST(iopins); CLEAR_POINTER_LIST(iopins);
@ -126,6 +151,22 @@ void Database::clearDesign() {
DBU_Micron = -1.0; DBU_Micron = -1.0;
designName = ""; designName = "";
regions.push_back(new Region("default")); regions.push_back(new Region("default"));
if (!powerNet) {
delete powerNet;
}
if (!siteMap) {
delete siteMap;
}
if (!gcellgrid) {
delete gcellgrid;
}
if (!bsRouteInfo) {
delete bsRouteInfo;
}
if (!edgetypes) {
delete edgetypes;
}
} }
void Database::save(const std::string& given_prefix) { void Database::save(const std::string& given_prefix) {
@ -246,17 +287,17 @@ void Database::SetupFloorplan() {
coreHY = std::max(row->y() + siteH, coreHY); coreHY = std::max(row->y() + siteH, coreHY);
} }
for (Site& site : sites) { for (Site* lefsite : lefsites) {
if (site.siteClassName() == "CORE") { if (lefsite->siteClassName() == "CORE") {
if (siteW != (unsigned)site.width()) { if (siteW != (unsigned)lefsite->width()) {
logger.warning("siteW %d in DEF is inconsistent with siteW %d in LEF.", logger.warning("siteW %d in DEF is inconsistent with siteW %d in LEF.",
static_cast<int>(siteW), static_cast<int>(siteW),
static_cast<int>(site.width())); static_cast<int>(lefsite->width()));
} }
if (siteH != site.height()) { if (siteH != lefsite->height()) {
logger.warning("siteH %d in DEF is inconsistent with siteH %d in LEF.", logger.warning("siteH %d in DEF is inconsistent with siteH %d in LEF.",
static_cast<int>(siteH), static_cast<int>(siteH),
static_cast<int>(site.height())); static_cast<int>(lefsite->height()));
} }
break; break;
} }
@ -319,15 +360,15 @@ void Database::SetupRegions() {
void Database::SetupSiteMap() { void Database::SetupSiteMap() {
// set up site map // set up site map
siteMap.siteL = coreLX; siteMap->siteL = coreLX;
siteMap.siteR = coreHX; siteMap->siteR = coreHX;
siteMap.siteB = coreLY; siteMap->siteB = coreLY;
siteMap.siteT = coreHY; siteMap->siteT = coreHY;
siteMap.siteStepX = siteW; siteMap->siteStepX = siteW;
siteMap.siteStepY = siteH; siteMap->siteStepY = siteH;
siteMap.siteNX = nSitesX; siteMap->siteNX = nSitesX;
siteMap.siteNY = nSitesY; siteMap->siteNY = nSitesY;
siteMap.initSiteMap(nSitesX, nSitesY); siteMap->initSiteMap(nSitesX, nSitesY);
// mark site partially overlapped by fence // mark site partially overlapped by fence
int nRegions = regions.size(); int nRegions = regions.size();
@ -342,20 +383,20 @@ void Database::SetupSiteMap() {
for (int j = 0; j < (int)hSlices.size(); j++) { for (int j = 0; j < (int)hSlices.size(); j++) {
int lx = hSlices[j].lx; int lx = hSlices[j].lx;
int hx = hSlices[j].hx; int hx = hSlices[j].hx;
int olx = binOverlappedL(lx, siteMap.siteL, siteMap.siteR, siteMap.siteStepX); int olx = binOverlappedL(lx, siteMap->siteL, siteMap->siteR, siteMap->siteStepX);
int ohx = binOverlappedR(hx, siteMap.siteL, siteMap.siteR, siteMap.siteStepX); int ohx = binOverlappedR(hx, siteMap->siteL, siteMap->siteR, siteMap->siteStepX);
int clx = binContainedL(lx, siteMap.siteL, siteMap.siteR, siteMap.siteStepX); int clx = binContainedL(lx, siteMap->siteL, siteMap->siteR, siteMap->siteStepX);
int chx = binContainedR(hx, siteMap.siteL, siteMap.siteR, siteMap.siteStepX); int chx = binContainedR(hx, siteMap->siteL, siteMap->siteR, siteMap->siteStepX);
int sly = binOverlappedL(hSlices[j].ly, siteMap.siteB, siteMap.siteT, siteMap.siteStepY); int sly = binOverlappedL(hSlices[j].ly, siteMap->siteB, siteMap->siteT, siteMap->siteStepY);
int shy = binOverlappedR(hSlices[j].hy, siteMap.siteB, siteMap.siteT, siteMap.siteStepY); int shy = binOverlappedR(hSlices[j].hy, siteMap->siteB, siteMap->siteT, siteMap->siteStepY);
if (olx != clx) { if (olx != clx) {
for (int y = sly; y <= shy; y++) { for (int y = sly; y <= shy; y++) {
siteMap.blockRegion(olx, y); siteMap->blockRegion(olx, y);
} }
} }
if (ohx != chx) { if (ohx != chx) {
for (int y = sly; y <= shy; y++) { for (int y = sly; y <= shy; y++) {
siteMap.blockRegion(ohx, y); siteMap->blockRegion(ohx, y);
} }
} }
} }
@ -365,34 +406,34 @@ void Database::SetupSiteMap() {
for (const Rectangle& vSlice : vSlices) { for (const Rectangle& vSlice : vSlices) {
int ly = vSlice.ly; int ly = vSlice.ly;
int hy = vSlice.hy; int hy = vSlice.hy;
const unsigned oly = binOverlappedL(ly, siteMap.siteB, siteMap.siteT, siteMap.siteStepY); const unsigned oly = binOverlappedL(ly, siteMap->siteB, siteMap->siteT, siteMap->siteStepY);
const unsigned ohy = binOverlappedR(hy, siteMap.siteB, siteMap.siteT, siteMap.siteStepY); const unsigned ohy = binOverlappedR(hy, siteMap->siteB, siteMap->siteT, siteMap->siteStepY);
const int cly = binContainedL(ly, siteMap.siteB, siteMap.siteT, siteMap.siteStepY); const int cly = binContainedL(ly, siteMap->siteB, siteMap->siteT, siteMap->siteStepY);
const int chy = binContainedR(hy, siteMap.siteB, siteMap.siteT, siteMap.siteStepY); const int chy = binContainedR(hy, siteMap->siteB, siteMap->siteT, siteMap->siteStepY);
const unsigned slx = binOverlappedL(vSlice.lx, siteMap.siteL, siteMap.siteR, siteMap.siteStepX); const unsigned slx = binOverlappedL(vSlice.lx, siteMap->siteL, siteMap->siteR, siteMap->siteStepX);
const unsigned shx = binOverlappedR(vSlice.hx, siteMap.siteL, siteMap.siteR, siteMap.siteStepX); const unsigned shx = binOverlappedR(vSlice.hx, siteMap->siteL, siteMap->siteR, siteMap->siteStepX);
if ((int)oly != cly) { if ((int)oly != cly) {
for (unsigned x = slx; x <= shx; ++x) { for (unsigned x = slx; x <= shx; ++x) {
siteMap.blockRegion(x, oly); siteMap->blockRegion(x, oly);
} }
} }
if ((int)ohy != chy) { if ((int)ohy != chy) {
for (unsigned x = slx; x <= shx; ++x) { for (unsigned x = slx; x <= shx; ++x) {
siteMap.blockRegion(x, ohy); siteMap->blockRegion(x, ohy);
} }
} }
} }
for (const Rectangle& rect : hSlices) { for (const Rectangle& rect : hSlices) {
siteMap.setRegion(rect.lx, rect.ly, rect.hx, rect.hy, region->id); siteMap->setRegion(rect.lx, rect.ly, rect.hx, rect.hy, region->id);
} }
for (const Rectangle& rect : vSlices) { for (const Rectangle& rect : vSlices) {
siteMap.setRegion(rect.lx, rect.ly, rect.hx, rect.hy, region->id); siteMap->setRegion(rect.lx, rect.ly, rect.hx, rect.hy, region->id);
} }
} }
// mark all sites blocked // mark all sites blocked
siteMap.setSites(coreLX, coreLY, coreHX, coreHY, SiteMap::SiteBlocked); siteMap->setSites(coreLX, coreLY, coreHX, coreHY, SiteMap::SiteBlocked);
// mark rows as non-blocked // mark rows as non-blocked
for (const Row* row : rows) { for (const Row* row : rows) {
@ -400,7 +441,7 @@ void Database::SetupSiteMap() {
int ly = row->y(); int ly = row->y();
int hx = row->x() + row->width(); int hx = row->x() + row->width();
int hy = row->y() + siteH; int hy = row->y() + siteH;
siteMap.unsetSites(lx, ly, hx, hy, SiteMap::SiteBlocked); siteMap->unsetSites(lx, ly, hx, hy, SiteMap::SiteBlocked);
} }
// mark blocked sites // mark blocked sites
@ -413,8 +454,8 @@ void Database::SetupSiteMap() {
int hx = cell->hx(); int hx = cell->hx();
int hy = cell->hy(); int hy = cell->hy();
siteMap.setSites(lx, ly, hx, hy, SiteMap::SiteBlocked); siteMap->setSites(lx, ly, hx, hy, SiteMap::SiteBlocked);
siteMap.blockRegion(lx, ly, hx, hy); siteMap->blockRegion(lx, ly, hx, hy);
} }
for (const Rectangle& placeBlockage : placeBlockages) { for (const Rectangle& placeBlockage : placeBlockages) {
@ -422,8 +463,8 @@ void Database::SetupSiteMap() {
int ly = placeBlockage.ly; int ly = placeBlockage.ly;
int hx = placeBlockage.hx; int hx = placeBlockage.hx;
int hy = placeBlockage.hy; int hy = placeBlockage.hy;
siteMap.setSites(lx, ly, hx, hy, SiteMap::SiteBlocked); siteMap->setSites(lx, ly, hx, hy, SiteMap::SiteBlocked);
siteMap.blockRegion(lx, ly, hx, hy); siteMap->blockRegion(lx, ly, hx, hy);
} }
for (const SNet* snet : snets) { for (const SNet* snet : snets) {
@ -431,11 +472,11 @@ void Database::SetupSiteMap() {
switch (geo.layer.rIndex) { switch (geo.layer.rIndex) {
case 1: case 1:
if (geo.layer.direction == 'v') { if (geo.layer.direction == 'v') {
siteMap.setSites(geo.lx, geo.ly, geo.hx, geo.hy, SiteMap::SiteM2Blocked); siteMap->setSites(geo.lx, geo.ly, geo.hx, geo.hy, SiteMap::SiteM2Blocked);
} }
break; break;
case 2: case 2:
siteMap.setSites(geo.lx, geo.ly, geo.hx, geo.hy, SiteMap::SiteM3Blocked); siteMap->setSites(geo.lx, geo.ly, geo.hx, geo.hy, SiteMap::SiteM3Blocked);
break; break;
default: default:
break; break;
@ -449,7 +490,7 @@ void Database::SetupSiteMap() {
case 0: case 0:
break; break;
case 1: case 1:
siteMap.setSites(shape.lx + iopin->x, siteMap->setSites(shape.lx + iopin->x,
shape.ly + iopin->y, shape.ly + iopin->y,
shape.hx + iopin->x, shape.hx + iopin->x,
shape.hy + iopin->y, shape.hy + iopin->y,
@ -463,31 +504,31 @@ void Database::SetupSiteMap() {
} }
} }
siteMap.nSites = siteMap.siteNX * siteMap.siteNY; siteMap->nSites = siteMap->siteNX * siteMap->siteNY;
siteMap.nPlaceable = 0; siteMap->nPlaceable = 0;
siteMap.nRegionSites.resize(regions.size(), 0); siteMap->nRegionSites.resize(regions.size(), 0);
for (int y = 0; y < siteMap.siteNY; y++) { for (int y = 0; y < siteMap->siteNY; y++) {
for (int x = 0; x < siteMap.siteNX; x++) { for (int x = 0; x < siteMap->siteNX; x++) {
if (siteMap.getSiteMap(x, y, SiteMap::SiteBlocked) || siteMap.getSiteMap(x, y, SiteMap::SiteM2Blocked) || if (siteMap->getSiteMap(x, y, SiteMap::SiteBlocked) || siteMap->getSiteMap(x, y, SiteMap::SiteM2Blocked) ||
siteMap.getSiteMap(x, y, SiteMap::SiteM2BlockedIOPin)) { siteMap->getSiteMap(x, y, SiteMap::SiteM2BlockedIOPin)) {
continue; continue;
} }
siteMap.nPlaceable++; siteMap->nPlaceable++;
unsigned char region = siteMap.getRegion(x, y); unsigned char region = siteMap->getRegion(x, y);
if (region != Region::InvalidRegion) { if (region != Region::InvalidRegion) {
siteMap.nRegionSites[region]++; siteMap->nRegionSites[region]++;
} }
} }
} }
logger.verbose("core area: %ld", siteMap.nSites); logger.verbose("core area: %ld", siteMap->nSites);
logger.verbose( logger.verbose(
"placeable: %ld (%lf%%)", siteMap.nPlaceable, (double)siteMap.nPlaceable / (double)siteMap.nSites * 100.0); "placeable: %ld (%lf%%)", siteMap->nPlaceable, (double)siteMap->nPlaceable / (double)siteMap->nSites * 100.0);
for (int i = 0; i < (int)regions.size(); i++) { for (int i = 0; i < (int)regions.size(); i++) {
logger.verbose("region %d : %ld (%lf%%)", logger.verbose("region %d : %ld (%lf%%)",
i, i,
siteMap.nRegionSites[i], siteMap->nRegionSites[i],
(double)siteMap.nRegionSites[i] / (double)siteMap.nPlaceable); (double)siteMap->nRegionSites[i] / (double)siteMap->nPlaceable);
} }
} }
@ -499,7 +540,8 @@ void Database::SetupRows() {
for (Row* row : rows) { for (Row* row : rows) {
char isFlip = (row->flip() ? 1 : 2); char isFlip = (row->flip() ? 1 : 2);
int y = (row->y() - coreLY) / siteH; int y = (row->y() - coreLY) / siteH;
orients[y] = row->orient(); // TODO: how to handle multiple ROW definitions on same y? orients[y] = row->orient(); // TODO: how to handle multiple ROW
// definitions on same y?
if (flip[y] == 0) { if (flip[y] == 0) {
flip[y] = isFlip; flip[y] = isFlip;
} else if (flip[y] != isFlip) { } else if (flip[y] != isFlip) {
@ -543,27 +585,42 @@ void Database::SetupRows() {
Row* row = rows[y]; Row* row = rows[y];
int ly = row->y(); int ly = row->y();
int hy = row->y() + siteH; int hy = row->y() + siteH;
if (!powerNet.getRowPower(ly, hy, row->_topPower, row->_botPower)) { if (!powerNet->getRowPower(ly, hy, row->_topPower, row->_botPower)) {
if (topNormal && row->topPower() == 'x') { if (topNormal && row->topPower() == 'x') {
if (y + 1 == nSitesY) { if (y + 1 == nSitesY) {
logger.warning("Top power rail of the row at y=%d is not connected to power rail", row->y()); logger.warning(
"Top power rail of the row at y=%d is not connected to "
"power rail",
row->y());
} else { } else {
logger.error("Top power rail of the row at y=%d is not connected to power rail", row->y()); logger.error(
"Top power rail of the row at y=%d is not connected to "
"power rail",
row->y());
topNormal = false; topNormal = false;
} }
} }
if (botNormal && row->botPower() == 'x') { if (botNormal && row->botPower() == 'x') {
if (y) { if (y) {
logger.error("Bottom power rail of the row at y=%d is not connected to power rail", row->y()); logger.error(
"Bottom power rail of the row at y=%d is not connected "
"to power rail",
row->y());
botNormal = false; botNormal = false;
} else { } else {
logger.warning("Bottom power rail of the row at y=%d is not connected to power rail", row->y()); logger.warning(
"Bottom power rail of the row at y=%d is not connected "
"to power rail",
row->y());
} }
} }
} }
if (shrNormal && row->topPower() == row->botPower()) { if (shrNormal && row->topPower() == row->botPower()) {
logger.error( logger.error(
"Top and Bottom power rail of the row at y=%d share the same power %c", row->y(), row->topPower()); "Top and Bottom power rail of the row at y=%d share the same "
"power %c",
row->y(),
row->topPower());
shrNormal = false; shrNormal = false;
} }
} }
@ -584,15 +641,15 @@ void Database::SetupRowSegments() {
b2 = true; b2 = true;
r2 = NULL; r2 = NULL;
} else { } else {
b2 = siteMap.getSiteMap(x, y, SiteMap::SiteBlocked); b2 = siteMap->getSiteMap(x, y, SiteMap::SiteBlocked);
if (setting.EnablePG) { if (setting.EnablePG) {
b2 = b2 || siteMap.getSiteMap(x, y, SiteMap::SiteM2Blocked); b2 = b2 || siteMap->getSiteMap(x, y, SiteMap::SiteM2Blocked);
} }
if (setting.EnableIOPin) { if (setting.EnableIOPin) {
b2 = b2 || siteMap.getSiteMap(x, y, SiteMap::SiteM2BlockedIOPin); b2 = b2 || siteMap->getSiteMap(x, y, SiteMap::SiteM2BlockedIOPin);
} }
if (setting.EnableFence) { if (setting.EnableFence) {
r2 = getRegion(siteMap.getRegion(x, y)); r2 = getRegion(siteMap->getRegion(x, y));
} else { } else {
r2 = regions[0]; r2 = regions[0];
} }
@ -650,15 +707,16 @@ Layer& Database::addLayer(const string& name, const char type) {
return newlayer; return newlayer;
} }
Site& Database::addSite(const string& name, const string& siteClassName, const int w, const int h) { Site* Database::addSite(const string& name, const string& siteClassName, const int w, const int h) {
for (unsigned i = 0; i < sites.size(); i++) { for (unsigned i = 0; i < lefsites.size(); i++) {
if (name == sites[i].name()) { if (name == lefsites[i]->name()) {
logger.warning("site re-defined: %s", name.c_str()); logger.warning("site re-defined: %s", name.c_str());
return sites[i]; return lefsites[i];
} }
} }
sites.emplace_back(name, siteClassName, w, h); Site* site = new Site(name, siteClassName, w, h);
return sites.back(); lefsites.push_back(site);
return site;
} }
ViaType* Database::addViaType(const string& name, bool isDef) { ViaType* Database::addViaType(const string& name, bool isDef) {
@ -793,7 +851,7 @@ long long Database::getFreeArea(Region* region) const {
if (region && region != regions[i]) { if (region && region != regions[i]) {
continue; continue;
} }
freeArea += siteMap.nRegionSites[i]; freeArea += siteMap->nRegionSites[i];
} }
return freeArea; return freeArea;
} }
@ -919,6 +977,12 @@ ViaType* Database::getViaType(const string& name) const {
return mi->second; return mi->second;
} }
int Database::getCellTypeSpace(const CellType* L, const CellType* R) const {
return edgetypes->getEdgeSpace(L->edgetypeR, R->edgetypeL);
}
int Database::getCellTypeSpace(const Cell* L, const Cell* R) const { return getCellTypeSpace(L->ctype(), R->ctype()); }
int Database::getContainedSites( int Database::getContainedSites(
const int lx, const int ly, const int hx, const int hy, int& slx, int& sly, int& shx, int& shy) const { const int lx, const int ly, const int hx, const int hy, int& slx, int& sly, int& shx, int& shy) const {
slx = binContainedL(lx, coreLX, coreHX, siteW); slx = binContainedL(lx, coreLX, coreHX, siteW);
@ -963,6 +1027,8 @@ unsigned Database::getNumCLayers() const {
return numCLayers; return numCLayers;
} }
unsigned Database::getNumLayers() const { return layers.size(); }
void Database::errorCheck(bool autoFix) { void Database::errorCheck(bool autoFix) {
vector<Row*>::iterator ri = rows.begin(); vector<Row*>::iterator ri = rows.begin();
vector<Row*>::iterator re = rows.end(); vector<Row*>::iterator re = rows.end();

View File

@ -1,54 +1,7 @@
#pragma once #pragma once
#include "DatabaseClass.h"
#include "Setting.h" #include "Setting.h"
#include "common/common.h"
namespace db {
using std::string;
using std::vector;
class Rectangle;
class Geometry;
class GeoMap;
class Cell;
class CellType;
class Pin;
class PinType;
class IOPin;
class CellPin;
class Net;
class Row;
class RowSegment;
class Track;
class Layer;
class Via;
class ViaRule;
class ViaType;
class Region;
class NDR;
class SNet;
class Site;
class PowerNet;
class EdgeTypes;
class GCellGrid;
class BsRouteInfo;
} // namespace db
#include "BsRouteInfo.h"
#include "Cell.h"
#include "DesignRule.h"
#include "GCellGrid.h"
#include "Geometry.h"
#include "Layer.h"
#include "Net.h"
#include "Pin.h"
#include "Region.h"
#include "Row.h"
#include "SNet.h"
#include "Site.h"
#include "SiteMap.h"
#include "Via.h"
namespace db { namespace db {
@ -86,7 +39,7 @@ public:
robin_hood::unordered_map<string, ViaType*> name_viatypes; robin_hood::unordered_map<string, ViaType*> name_viatypes;
vector<Layer> layers; vector<Layer> layers;
vector<Site> sites; vector<Site*> lefsites;
vector<ViaType*> viatypes; vector<ViaType*> viatypes;
vector<CellType*> celltypes; vector<CellType*> celltypes;
@ -102,7 +55,7 @@ public:
vector<Geometry> routeBlockages; vector<Geometry> routeBlockages;
vector<Rectangle> placeBlockages; vector<Rectangle> placeBlockages;
PowerNet powerNet; PowerNet* powerNet = nullptr;
private: private:
static const size_t _bufferCapacity = 128 * 1024; static const size_t _bufferCapacity = 128 * 1024;
@ -115,11 +68,11 @@ public:
unsigned nSitesX = 0; unsigned nSitesX = 0;
unsigned nSitesY = 0; unsigned nSitesY = 0;
SiteMap siteMap; SiteMap* siteMap = nullptr;
GCellGrid gcellgrid; GCellGrid* gcellgrid = nullptr;
BsRouteInfo bsRouteInfo; BsRouteInfo* bsRouteInfo = nullptr;
EdgeTypes edgetypes; EdgeTypes* edgetypes = nullptr;
int dieLX, dieLY, dieHX, dieHY; int dieLX, dieLY, dieHX, dieHY;
int coreLX, coreLY, coreHX, coreHY; int coreLX, coreLY, coreHX, coreHY;
@ -139,13 +92,13 @@ public:
~Database(); ~Database();
void clear(); void clear();
void clearTechnology(); void clearTechnology();
inline void clearLibrary() { CLEAR_POINTER_LIST(celltypes); } void clearLibrary();
void clearDesign(); void clearDesign();
Layer& addLayer(const string& name, const char type = 'x'); Layer& addLayer(const string& name, const char type = 'x');
Site& addSite(const string& name, const string& siteClassName, const int w, const int h); Site* addSite(const string& name, const string& siteClassName, const int w, const int h);
ViaType* addViaType(const string& name, bool isDef); ViaType* addViaType(const string& name, bool isDef);
inline ViaType* addViaType(const string& name) { return addViaType(name, false); } ViaType* addViaType(const string& name) { return addViaType(name, false); }
CellType* addCellType(const string& name, unsigned libcell); CellType* addCellType(const string& name, unsigned libcell);
void reserveCells(const size_t n) { cells.reserve(n); } void reserveCells(const size_t n) { cells.reserve(n); }
Cell* addCell(const string& name, CellType* type = nullptr); Cell* addCell(const string& name, CellType* type = nullptr);
@ -183,17 +136,15 @@ public:
unsigned getNumRLayers() const; unsigned getNumRLayers() const;
unsigned getNumCLayers() const; unsigned getNumCLayers() const;
inline unsigned getNumLayers() const { return layers.size(); } unsigned getNumLayers() const;
inline unsigned getNumCells() const { return cells.size(); } unsigned getNumCells() const { return cells.size(); }
inline unsigned getNumNets() const { return nets.size(); } unsigned getNumNets() const { return nets.size(); }
inline unsigned getNumRegions() const { return regions.size(); } unsigned getNumRegions() const { return regions.size(); }
inline unsigned getNumIOPins() const { return iopins.size(); } unsigned getNumIOPins() const { return iopins.size(); }
inline unsigned getNumCellTypes() const { return celltypes.size(); } unsigned getNumCellTypes() const { return celltypes.size(); }
inline int getCellTypeSpace(const CellType* L, const CellType* R) const { int getCellTypeSpace(const CellType* L, const CellType* R) const;
return edgetypes.getEdgeSpace(L->edgetypeR, R->edgetypeL); int getCellTypeSpace(const Cell* L, const Cell* R) const;
}
inline int getCellTypeSpace(const Cell* L, const Cell* R) const { return getCellTypeSpace(L->ctype(), R->ctype()); }
int getContainedSites( int getContainedSites(
const int lx, const int ly, const int hx, const int hy, int& slx, int& sly, int& shx, int& shy) const; const int lx, const int ly, const int hx, const int hy, int& slx, int& sly, int& shx, int& shy) const;
int getOverlappedSites( int getOverlappedSites(

View File

@ -0,0 +1,45 @@
#include <climits>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#include "common/utils/utils.h"
using utils::assert_msg;
using utils::logger;
namespace db {
using std::string;
using std::vector;
class Database;
class Rectangle;
class Geometry;
class GeoMap;
class Cell;
class CellType;
class Pin;
class PinType;
class IOPin;
class CellPin;
class Net;
class Row;
class RowSegment;
class Track;
class Layer;
class Via;
class ViaRule;
class ViaType;
class Region;
class NDR;
class SNet;
class Site;
class SiteMap;
class PowerNet;
class EdgeTypes;
class GCellGrid;
class BsRouteInfo;
} // namespace db

View File

@ -1,4 +1,7 @@
#include "Database.h" #include "DesignRule.h"
#include "DatabaseClass.h"
using namespace db; using namespace db;
/***** EdgeTypes *****/ /***** EdgeTypes *****/

View File

@ -1,6 +1,15 @@
#pragma once #pragma once
#include <string>
#include <vector>
namespace db { namespace db {
class Layer;
class ViaType;
using std::string;
using std::vector;
class WireRule { class WireRule {
private: private:
const Layer* _layer; const Layer* _layer;

View File

@ -1,4 +1,5 @@
#pragma once #pragma once
#include <vector>
namespace db { namespace db {

View File

@ -1,4 +1,7 @@
#include "Database.h" #include "DatabaseClass.h"
#include "Geometry.h"
#include "Layer.h"
using namespace db; using namespace db;
/***** Rectangle *****/ /***** Rectangle *****/

View File

@ -1,6 +1,15 @@
#pragma once #pragma once
#include <climits>
#include <iostream>
#include <map>
#include <vector>
namespace db { namespace db {
using std::vector;
class Layer;
class Rectangle { class Rectangle {
public: public:
int lx = INT_MAX; int lx = INT_MAX;
@ -47,7 +56,7 @@ public:
: Rectangle(lx, ly, hx, hy), layer(layer) {} : Rectangle(lx, ly, hx, hy), layer(layer) {}
Geometry(const Geometry& geom) : Rectangle(geom), layer(geom.layer) {} Geometry(const Geometry& geom) : Rectangle(geom), layer(geom.layer) {}
inline bool operator==(const Geometry& rhs) const; bool operator==(const Geometry& rhs) const;
}; };
class GeoMap : public Rectangle { class GeoMap : public Rectangle {

View File

@ -1,4 +1,7 @@
#include "Database.h" #include "Layer.h"
#include "DatabaseClass.h"
using namespace db; using namespace db;
/***** Track *****/ /***** Track *****/

View File

@ -1,6 +1,17 @@
#pragma once #pragma once
#include <string>
#include <vector>
#include <tuple>
#include <climits>
namespace db { namespace db {
using std::string;
using std::vector;
class Layer;
class Track;
class Track { class Track {
// contain DEF track info // contain DEF track info
// support multi layer track DEF definition // support multi layer track DEF definition

View File

@ -1,4 +1,12 @@
#include "Database.h" #include "Net.h"
#include "DatabaseClass.h"
#include "DesignRule.h"
#include "Layer.h"
#include "SNet.h"
#include "Via.h"
#include "Geometry.h"
using namespace db; using namespace db;
/***** NetRouteNode *****/ /***** NetRouteNode *****/
@ -6,6 +14,10 @@ using namespace db;
NetRouteNode::NetRouteNode(const Layer* layer, const int x, const int y, const int z) NetRouteNode::NetRouteNode(const Layer* layer, const int x, const int y, const int z)
: _layer(layer), x(x), y(y), z(z) {} : _layer(layer), x(x), y(y), z(z) {}
bool NetRouteNode::operator==(const NetRouteNode& r) const {
return _layer == r._layer && x == r.x && y == r.y && z == r.z;
}
/***** NetRouteSegment *****/ /***** NetRouteSegment *****/
NetRouteSegment::NetRouteSegment(const unsigned fromi, const unsigned toi, const char dir, const unsigned len) NetRouteSegment::NetRouteSegment(const unsigned fromi, const unsigned toi, const char dir, const unsigned len)
@ -94,6 +106,9 @@ long long NetRouting::length() const {
/***** Net *****/ /***** Net *****/
Net::Net(const string& name, const NDR* ndr) : name(name), ndr(ndr) {}
Net::Net(const Net& net) : _routing(net._routing), name(net.name), pins(net.pins), ndr(net.ndr) {}
void Net::addPin(Pin* pin) { void Net::addPin(Pin* pin) {
// if (pin->type->direction() == 'o' && pins.size()) { // if (pin->type->direction() == 'o' && pins.size()) {
// Pin* firstPin = pins[0]; // Pin* firstPin = pins[0];
@ -111,12 +126,13 @@ void Net::addPin(Pin* pin) {
void PowerNet::addRail(SNet* snet, int lx, int hx, int y) { void PowerNet::addRail(SNet* snet, int lx, int hx, int y) {
std::map<int, SNet*>::iterator rail = rails.find(y); std::map<int, SNet*>::iterator rail = rails.find(y);
if (rail != rails.end() && rail->second != snet) { if (rail != rails.end() && rail->second != snet) {
logger.error("rail %s already exists at y=%d , new rail %s is from %d to %d", rail->second->name.c_str(), logger.error("rail %s already exists at y=%d , new rail %s is from %d to %d",
y, snet->name.c_str(), rail->second->name.c_str(),
y,
snet->name.c_str(),
lx, lx,
hx); hx);
return; return;
} }
rails.emplace(y, snet); rails.emplace(y, snet);
} }
@ -139,4 +155,3 @@ bool PowerNet::getRowPower(int ly, int hy, char& topPower, char& botPower) {
} }
return valid; return valid;
} }

View File

@ -1,7 +1,24 @@
#pragma once #pragma once
#include <map>
#include <string>
#include <vector>
#include <climits>
namespace db { namespace db {
using std::string;
using std::vector;
class Layer;
class Pin;
class Cell;
class NDR;
class NetRouteNode;
class NetRouteSegment;
class NetRouting;
class Net;
class SNet;
class NetRouteNode { class NetRouteNode {
private: private:
const Layer* _layer = nullptr; const Layer* _layer = nullptr;
@ -11,12 +28,9 @@ public:
int y = 0; int y = 0;
int z = 0; int z = 0;
Pin* pin; Pin* pin;
NetRouteNode(const Layer* layer = nullptr, const int x = 0, const int y = 0, const int z = 0); NetRouteNode(const Layer* layer = nullptr, const int x = 0, const int y = 0, const int z = 0);
inline bool operator==(const NetRouteNode& r) const { bool operator==(const NetRouteNode& r) const;
return _layer == r._layer && x == r.x && y == r.y && z == r.z;
}
}; };
class NetRouteSegment { class NetRouteSegment {
@ -62,8 +76,8 @@ public:
const NDR* ndr = nullptr; const NDR* ndr = nullptr;
int gpdb_id = -1; int gpdb_id = -1;
Net(const string& name, const NDR* ndr = nullptr) : name(name), ndr(ndr) {} Net(const string& name, const NDR* ndr = nullptr);
Net(const Net& net) : _routing(net._routing), name(net.name), pins(net.pins), ndr(net.ndr) {} Net(const Net& net);
bool globalRouted() const { return gRouted; } bool globalRouted() const { return gRouted; }
bool detailedRouted() const { return dRouted; } bool detailedRouted() const { return dRouted; }
@ -100,6 +114,7 @@ private:
std::map<int, SNet*> rails; std::map<int, SNet*> rails;
public: public:
~PowerNet() { rails.clear(); }
void addRail(SNet* snet, int lx, int hx, int y); void addRail(SNet* snet, int lx, int hx, int y);
bool getRowPower(int ly, int hy, char& topPower, char& botPower); bool getRowPower(int ly, int hy, char& topPower, char& botPower);
}; };

View File

@ -1,4 +1,12 @@
#include "Database.h" #include "Pin.h"
#include "Cell.h"
#include "DatabaseClass.h"
#include "Geometry.h"
#include "Layer.h"
#include "Net.h"
#include "common/utils/utils.h"
using namespace db; using namespace db;
/***** PinSTA *****/ /***** PinSTA *****/
@ -38,6 +46,11 @@ void IOPin::getBounds(int& lx, int& ly, int& hx, int& hy, int& rIndex) const {
/***** Pin *****/ /***** Pin *****/
Pin::Pin(const PinType* type) : type(type) {}
Pin::Pin(Cell* cell, int i) : cell(cell), type(cell->ctype()->pins[i]), parentCellPinId(i) {}
Pin::Pin(IOPin* iopin) : iopin(iopin), type(iopin->type) {}
Pin::Pin(const Pin& pin) : cell(pin.cell), net(pin.net), type(pin.type) {}
void Pin::getPinCenter(int& x, int& y) { void Pin::getPinCenter(int& x, int& y) {
int lx, ly, hx, hy; int lx, ly, hx, hy;
type->getBounds(lx, ly, hx, hy); type->getBounds(lx, ly, hx, hy);
@ -160,3 +173,8 @@ bool PinType::comparePin(vector<PinType*> pins1, vector<PinType*> pins2) {
} }
return true; return true;
} }
bool PinType::operator==(const PinType& r) const {
return _type == r._type && boundLX == r.boundLX && boundLY == r.boundLY && boundHX == r.boundHX &&
boundHY == r.boundHY && shapes[0].layer.rIndex == r.shapes[0].layer.rIndex;
}

View File

@ -1,6 +1,30 @@
#pragma once #pragma once
#include <string>
#include <vector>
#include <climits>
namespace utils {
template <class T>
class BoxT;
template <class T>
class PointT;
} // namespace utils
namespace db { namespace db {
using std::string;
using std::vector;
class Geometry;
class Layer;
class PinType;
class IOPin;
class Pin;
class PinSTA;
class Cell;
class Net;
class PinType { class PinType {
private: private:
string _name = ""; string _name = "";
@ -30,10 +54,7 @@ public:
unsigned getW() const { return boundHX - boundLX; } unsigned getW() const { return boundHX - boundLX; }
unsigned getH() const { return boundHY - boundLY; } unsigned getH() const { return boundHY - boundLY; }
void getBounds(int& lx, int& ly, int& hx, int& hy) const; void getBounds(int& lx, int& ly, int& hx, int& hy) const;
bool operator==(const PinType& r) const { bool operator==(const PinType& r) const;
return _type == r._type && boundLX == r.boundLX && boundLY == r.boundLY && boundHX == r.boundHX &&
boundHY == r.boundHY && shapes[0].layer.rIndex == r.shapes[0].layer.rIndex;
}
bool operator!=(const PinType& r) const { return !(*this == r); } bool operator!=(const PinType& r) const { return !(*this == r); }
bool operator<(const PinType& r) const; bool operator<(const PinType& r) const;
bool operator>(const PinType& r) const { return r < *this; } bool operator>(const PinType& r) const { return r < *this; }
@ -95,10 +116,10 @@ public:
PinSTA* staInfo = nullptr; PinSTA* staInfo = nullptr;
Pin(const PinType* type = nullptr) : type(type) {} Pin(const PinType* type = nullptr);
Pin(Cell* cell, int i) : cell(cell), type(cell->ctype()->pins[i]), parentCellPinId(i) {} Pin(Cell* cell, int i);
Pin(IOPin* iopin) : iopin(iopin), type(iopin->type) {} Pin(IOPin* iopin);
Pin(const Pin& pin) : cell(pin.cell), net(pin.net), type(pin.type) {} Pin(const Pin& pin);
void getPinCenter(int& x, int& y); void getPinCenter(int& x, int& y);
void getPinBounds(int& lx, int& ly, int& hx, int& hy, int& rIndex); void getPinBounds(int& lx, int& ly, int& hx, int& hy, int& rIndex);

View File

@ -1,4 +1,4 @@
#include "Database.h" #include "Region.h"
using namespace db; using namespace db;
/***** Region *****/ /***** Region *****/

View File

@ -1,6 +1,14 @@
#pragma once #pragma once
#include <string>
#include <vector>
#include "Geometry.h"
namespace db { namespace db {
using std::string;
using std::vector;
class Region : public Rectangle { class Region : public Rectangle {
private: private:
string _name = ""; string _name = "";
@ -19,12 +27,10 @@ public:
Region(const string& name = "", const char type = 'x') Region(const string& name = "", const char type = 'x')
: Rectangle(INT_MAX, INT_MAX, INT_MIN, INT_MIN), _name(name), _type(type) {} : Rectangle(INT_MAX, INT_MAX, INT_MIN, INT_MIN), _name(name), _type(type) {}
inline const string& name() const { return _name; } const string& name() const { return _name; }
inline char type() const { return _type; } char type() const { return _type; }
void addRect(const int xl, const int yl, const int xh, const int yh); void addRect(const int xl, const int yl, const int xh, const int yh);
void resetRects() { sliceH(rects); } void resetRects() { sliceH(rects); }
}; };
} // namespace db } // namespace db

View File

@ -1,6 +1,16 @@
#pragma once #pragma once
#include <string>
#include <vector>
namespace db { namespace db {
class Region;
class Row;
class RowSegment;
using std::string;
using std::vector;
class Row { class Row {
friend class Database; friend class Database;
@ -71,7 +81,6 @@ public:
void shiftY(const int value) { _y += value; } void shiftY(const int value) { _y += value; }
void shrinkXNum(const int value) { _xNum -= value; } void shrinkXNum(const int value) { _xNum -= value; }
void shrinkYNum(const int value) { _yNum -= value; } void shrinkYNum(const int value) { _yNum -= value; }
}; };
class RowSegment { class RowSegment {
@ -81,4 +90,3 @@ public:
Region* region = nullptr; Region* region = nullptr;
}; };
} // namespace db } // namespace db

View File

@ -1,6 +1,14 @@
#pragma once #pragma once
#include <vector>
#include "Via.h"
namespace db { namespace db {
using std::vector;
class Geometry;
class SNet { class SNet {
public: public:
string name; string name;
@ -19,7 +27,5 @@ public:
void addVia(Args&&... args) { void addVia(Args&&... args) {
vias.emplace_back(args...); vias.emplace_back(args...);
} }
}; };
} } // namespace db

View File

@ -1,5 +1,6 @@
#pragma once #pragma once
#include "common/common.h" #include <string>
#include <vector>
namespace db { namespace db {

View File

@ -1,5 +1,10 @@
#pragma once #pragma once
#include <string>
namespace db { namespace db {
using std::string;
class Site { class Site {
private: private:
string _name = ""; string _name = "";

View File

@ -1,4 +1,9 @@
#include "Database.h" #include "SiteMap.h"
#include "DatabaseClass.h"
#include "Region.h"
#include "common/utils/utils.h"
using namespace db; using namespace db;
/***** SiteMap *****/ /***** SiteMap *****/
@ -10,6 +15,18 @@ void SiteMap::initSiteMap(unsigned nx, unsigned ny) {
regions.resize(nx, vector<unsigned char>(ny)); regions.resize(nx, vector<unsigned char>(ny));
} }
void SiteMap::setSiteMap(const unsigned x, const unsigned y, const unsigned char property) {
setBit(sites[x][y], property);
}
void SiteMap::unsetSiteMap(const unsigned x, const unsigned y, const unsigned char property) {
unsetBit(sites[x][y], property);
}
bool SiteMap::getSiteMap(const unsigned x, const unsigned y, const unsigned char property) const {
return (getBit(sites[x][y], property) == property);
}
void SiteMap::getSiteBound(int x, int y, int &lx, int &ly, int &hx, int &hy) const { void SiteMap::getSiteBound(int x, int y, int &lx, int &ly, int &hx, int &hy) const {
lx = siteL + x * siteStepX; lx = siteL + x * siteStepX;
ly = siteB + y * siteStepY; ly = siteB + y * siteStepY;

View File

@ -1,6 +1,11 @@
#pragma once #pragma once
#include <vector>
namespace db { namespace db {
using std::vector;
class SiteMap { class SiteMap {
private: private:
unsigned nx = 0; unsigned nx = 0;
@ -24,13 +29,9 @@ public:
void initSiteMap(unsigned nx, unsigned ny); void initSiteMap(unsigned nx, unsigned ny);
void setSiteMap(const unsigned x, const unsigned y, const unsigned char property) { setBit(sites[x][y], property); } void setSiteMap(const unsigned x, const unsigned y, const unsigned char property);
inline void unsetSiteMap(const unsigned x, const unsigned y, const unsigned char property) { void unsetSiteMap(const unsigned x, const unsigned y, const unsigned char property);
unsetBit(sites[x][y], property); bool getSiteMap(const unsigned x, const unsigned y, const unsigned char property) const;
}
inline bool getSiteMap(const unsigned x, const unsigned y, const unsigned char property) const {
return (getBit(sites[x][y], property) == property);
}
unsigned char getSiteMap(int x, int y) const { return sites[x][y]; } unsigned char getSiteMap(int x, int y) const { return sites[x][y]; }
void getSiteBound(int x, int y, int& lx, int& ly, int& hx, int& hy) const; void getSiteBound(int x, int y, int& lx, int& ly, int& hx, int& hy) const;

View File

@ -1,8 +1,18 @@
#pragma once #pragma once
#include <set> #include <set>
#include <string>
#include <utility>
namespace db { namespace db {
using std::string;
class Geometry;
class Via;
class ViaRule;
class ViaType;
class Via { class Via {
public: public:
int x; int x;

View File

@ -1,4 +1,16 @@
#include <fstream>
#include <iomanip>
#include <iostream>
#include <sstream>
#include "common/db/BsRouteInfo.h"
#include "common/db/Cell.h"
#include "common/db/Database.h" #include "common/db/Database.h"
#include "common/db/GCellGrid.h"
#include "common/db/Layer.h"
#include "common/db/Net.h"
#include "common/db/Pin.h"
#include "common/db/Row.h"
using namespace db; using namespace db;
@ -463,7 +475,8 @@ bool Database::readBSAux(const std::string& auxFile, const std::string& plFile)
if (minRowXStep != bsData.siteWidth) { if (minRowXStep != bsData.siteWidth) {
if (bsData.siteWidth % minRowXStep == 0) { if (bsData.siteWidth % minRowXStep == 0) {
logger.warning( logger.warning(
"estimated siteWidth %d is not equal to the min rowXStep %d, but is a multiple of min rowXStep. Set " "estimated siteWidth %d is not equal to the min rowXStep %d, "
"but is a multiple of min rowXStep. Set "
"estimated siteWidth as %d.", "estimated siteWidth as %d.",
bsData.siteWidth, bsData.siteWidth,
minRowXStep, minRowXStep,
@ -471,7 +484,10 @@ bool Database::readBSAux(const std::string& auxFile, const std::string& plFile)
bsData.siteWidth = minRowXStep; bsData.siteWidth = minRowXStep;
} else { } else {
logger.error( logger.error(
"estimated siteWidth %d is not equal to the minimum rowXStep %d.", bsData.siteWidth, minRowXStep); "estimated siteWidth %d is not equal to the minimum rowXStep "
"%d.",
bsData.siteWidth,
minRowXStep);
} }
} }
@ -481,17 +497,17 @@ bool Database::readBSAux(const std::string& auxFile, const std::string& plFile)
if (bsData.format == "dac2012") { if (bsData.format == "dac2012") {
isDac2012 = true; isDac2012 = true;
nLayers = bsData.gridNZ; nLayers = bsData.gridNZ;
this->gcellgrid.numX = {bsData.gridNX + 1}; this->gcellgrid->numX = {bsData.gridNX + 1};
this->gcellgrid.numY = {bsData.gridNY + 1}; this->gcellgrid->numY = {bsData.gridNY + 1};
this->gcellgrid.startX = {bsData.gridOriginX}; this->gcellgrid->startX = {bsData.gridOriginX};
this->gcellgrid.startY = {bsData.gridOriginY}; this->gcellgrid->startY = {bsData.gridOriginY};
this->gcellgrid.stepX = {bsData.tileW}; this->gcellgrid->stepX = {bsData.tileW};
this->gcellgrid.stepY = {bsData.tileH}; this->gcellgrid->stepY = {bsData.tileH};
this->bsRouteInfo.hasInfo = true; this->bsRouteInfo->hasInfo = true;
this->bsRouteInfo.capV = std::move(bsData.capV); this->bsRouteInfo->capV = std::move(bsData.capV);
this->bsRouteInfo.capH = std::move(bsData.capH); this->bsRouteInfo->capH = std::move(bsData.capH);
this->bsRouteInfo.viaSpace = std::move(bsData.viaSpace); this->bsRouteInfo->viaSpace = std::move(bsData.viaSpace);
this->bsRouteInfo.blockagePorosity = bsData.blockagePorosity; this->bsRouteInfo->blockagePorosity = bsData.blockagePorosity;
// this->grGrid.gcellNX = bsData.gridNX; // this->grGrid.gcellNX = bsData.gridNX;
// this->grGrid.gcellNY = bsData.gridNY; // this->grGrid.gcellNY = bsData.gridNY;
// this->grGrid.gcellL = bsData.gridOriginX; // this->grGrid.gcellL = bsData.gridOriginX;
@ -505,13 +521,15 @@ bool Database::readBSAux(const std::string& auxFile, const std::string& plFile)
// this->grGrid.viaSpacing = std::move(bsData.viaSpace); // this->grGrid.viaSpacing = std::move(bsData.viaSpace);
// this->grGrid.minPitch.resize(nLayers); // this->grGrid.minPitch.resize(nLayers);
// for (int i = 0; i < nLayers; i++) { // for (int i = 0; i < nLayers; i++) {
// this->grGrid.minPitch[i] = this->grGrid.minWireWidth[i] + this->grGrid.minWireSpacing[i]; // this->grGrid.minPitch[i] = this->grGrid.minWireWidth[i] +
// this->grGrid.minWireSpacing[i];
// } // }
} }
// NOTE: ICCAD/DAC 2012 does not define trackPitch and the capacity of each GCell // NOTE: ICCAD/DAC 2012 does not define trackPitch and the capacity of each
// cannot be directly computed by tracks. We restore the bookshelf capacity value // GCell cannot be directly computed by tracks. We restore the bookshelf
// in Database::Others::capV(H) and will handle them in GRDatabase. // capacity value in Database::Others::capV(H) and will handle them in
// GRDatabase.
logger.info("parsing layers"); logger.info("parsing layers");
int defaultPitch = bsData.siteWidth; int defaultPitch = bsData.siteWidth;
int defaultWidth = bsData.siteWidth / 2; int defaultWidth = bsData.siteWidth / 2;
@ -519,8 +537,8 @@ bool Database::readBSAux(const std::string& auxFile, const std::string& plFile)
char m1direction = 'h'; // M1 Route layer, rIndex == 0 char m1direction = 'h'; // M1 Route layer, rIndex == 0
char m2direction = 'v'; // M2 Route layer, rIndex == 1 char m2direction = 'v'; // M2 Route layer, rIndex == 1
if ((nLayers > 1) && (bsData.format == "dac2012")) { if ((nLayers > 1) && (bsData.format == "dac2012")) {
m1direction = (this->bsRouteInfo.capV[1] > 0) ? 'h' : 'v'; m1direction = (this->bsRouteInfo->capV[1] > 0) ? 'h' : 'v';
m2direction = (this->bsRouteInfo.capV[1] > 0) ? 'v' : 'h'; m2direction = (this->bsRouteInfo->capV[1] > 0) ? 'v' : 'h';
} }
for (unsigned i = 0; i != nLayers; ++i) { for (unsigned i = 0; i != nLayers; ++i) {
Layer& layer = this->addLayer(string("M").append(std::to_string(i + 1)), 'r'); Layer& layer = this->addLayer(string("M").append(std::to_string(i + 1)), 'r');
@ -579,7 +597,8 @@ bool Database::readBSAux(const std::string& auxFile, const std::string& plFile)
direction = 'o'; direction = 'o';
break; break;
case 'B': case 'B':
// We temporarily use 'x' to represent pin direction B in Bookshelf // We temporarily use 'x' to represent pin direction B in
// Bookshelf
direction = 'x'; direction = 'x';
break; break;
default: default:
@ -620,7 +639,8 @@ bool Database::readBSAux(const std::string& auxFile, const std::string& plFile)
} else { } else {
string celltypename(bsData.typeName[typeID]); string celltypename(bsData.typeName[typeID]);
Cell* cell = this->addCell(bsData.cellName[i], this->getCellType(celltypename)); Cell* cell = this->addCell(bsData.cellName[i], this->getCellType(celltypename));
// In Bookshelf, we don't need to consider the cell orient, set it as -1 // In Bookshelf, we don't need to consider the cell orient, set it
// as -1
cell->place(bsData.cellX[i], bsData.cellY[i], -1); cell->place(bsData.cellX[i], bsData.cellY[i], -1);
// cout<<cell->x<<","<<cell->y<<endl; // cout<<cell->x<<","<<cell->y<<endl;
cell->fixed((bsData.cellFixed[i] == (char)1)); cell->fixed((bsData.cellFixed[i] == (char)1));
@ -717,7 +737,8 @@ bool Database::readBSNodes(const std::string& file) {
cType = tokens[3]; cType = tokens[3];
} }
// if (cWidth == 0 || cHeight == 0) { // if (cWidth == 0 || cHeight == 0) {
// logger.warning("Node %s (Type %s) has irregular shape: width %d height %d.", // logger.warning("Node %s (Type %s) has irregular shape: width
// %d height %d.",
// cName.c_str(), // cName.c_str(),
// cType.c_str(), // cType.c_str(),
// cWidth, // cWidth,
@ -810,11 +831,14 @@ bool Database::readBSNets(const std::string& file) {
pinY = bsData.typeHeight[typeID] * 0.5 + (double)atof(tokens[3].c_str()); pinY = bsData.typeHeight[typeID] * 0.5 + (double)atof(tokens[3].c_str());
/* /*
if(tokens.size() >= 6){ if(tokens.size() >= 6){
//pinX = (int)round(atof(tokens[4].c_str())*bsData.siteWidth); //pinX =
//pinY = (int)round(atof(tokens[5].c_str())*bsData.siteWidth); (int)round(atof(tokens[4].c_str())*bsData.siteWidth);
}else{ //pinY =
pinX = bsData.typeWidth[typeID] * 0.5 + (int)round(atof(tokens[2].c_str())); (int)round(atof(tokens[5].c_str())*bsData.siteWidth); }else{
pinY = bsData.typeHeight[typeID] * 0.5 + (int)round(atof(tokens[3].c_str())); pinX = bsData.typeWidth[typeID] * 0.5 +
(int)round(atof(tokens[2].c_str())); pinY =
bsData.typeHeight[typeID] * 0.5 +
(int)round(atof(tokens[3].c_str()));
} }
*/ */
string pinName = (tokens.size() < 7) ? "" : tokens[6]; string pinName = (tokens.size() < 7) ? "" : tokens[6];
@ -953,7 +977,8 @@ bool Database::readBSRoute(const std::string& file) {
bsData.tileH = atoi(tokens[2].c_str()); bsData.tileH = atoi(tokens[2].c_str());
} else if (tokens[0] == "BlockagePorosity") { } else if (tokens[0] == "BlockagePorosity") {
bsData.blockagePorosity = atof(tokens[1].c_str()); bsData.blockagePorosity = atof(tokens[1].c_str());
// assert_msg(bsData.blockagePorosity == 0, "We haven't yet supported non-zero blockagePorosity"); // assert_msg(bsData.blockagePorosity == 0, "We haven't yet
// supported non-zero blockagePorosity");
} else if (tokens[0] == "NumNiTerminals") { } else if (tokens[0] == "NumNiTerminals") {
status = ReadingPinLayer; status = ReadingPinLayer;
} else if (tokens[0] == "NumBlockageNodes") { } else if (tokens[0] == "NumBlockageNodes") {
@ -994,7 +1019,8 @@ bool Database::readBSRoute(const std::string& file) {
int ty = atoi(tokens[4].c_str()); int ty = atoi(tokens[4].c_str());
int tz = atoi(tokens[5].c_str()); int tz = atoi(tokens[5].c_str());
int cap = atoi(tokens[6].c_str()); int cap = atoi(tokens[6].c_str());
cout<<fx<<" "<<fy<<" "<<fz<<" "<<tx<<" "<<ty<<" "<<tz<<" "<<cap<<endl; cout<<fx<<" "<<fy<<" "<<fz<<" "<<tx<<" "<<ty<<" "<<tz<<"
"<<cap<<endl;
*/ */
} }
} }

View File

@ -1,4 +1,8 @@
#include "common/db/Cell.h"
#include "common/db/Database.h" #include "common/db/Database.h"
#include "common/db/DatabaseClass.h"
#include "common/db/Layer.h"
#include "common/db/Row.h"
using namespace db; using namespace db;

View File

@ -1,4 +1,24 @@
#include <fstream>
#include <iomanip>
#include <iostream>
#include <sstream>
#include "common/db/BsRouteInfo.h"
#include "common/db/Cell.h"
#include "common/db/Database.h" #include "common/db/Database.h"
#include "common/db/DatabaseClass.h"
#include "common/db/DesignRule.h"
#include "common/db/GCellGrid.h"
#include "common/db/Geometry.h"
#include "common/db/Layer.h"
#include "common/db/Net.h"
#include "common/db/Pin.h"
#include "common/db/Region.h"
#include "common/db/Row.h"
#include "common/db/SNet.h"
#include "common/db/Site.h"
#include "common/db/SiteMap.h"
#include "common/db/Via.h"
// tcl have another definition of EXTERN // tcl have another definition of EXTERN
#undef EXTERN #undef EXTERN
@ -349,7 +369,7 @@ bool Database::readDEFPG(const std::string& file) {
} }
// snet->addShape(*layer, lx, ly, hx, hy); // snet->addShape(*layer, lx, ly, hx, hy);
if ((layer->rIndex == 0 || layer->rIndex == 1) && direction == 'h') { if ((layer->rIndex == 0 || layer->rIndex == 1) && direction == 'h') {
// db->powerNet.addRail(snet, lx, hx, fy); // db->powerNet->addRail(snet, lx, hx, fy);
} }
} }
} }
@ -385,17 +405,20 @@ bool Database::writeComponents(std::ofstream& ofs) {
std::ofstream& oss = ofs; std::ofstream& oss = ofs;
#endif #endif
oss << " - " << cell->name() << " " << cell->ctype()->name << std::endl; oss << " - " << cell->name() << " " << cell->ctype()->name << std::endl;
// ofs << " - " << cell->name() << " " << cell->ctype()->name << std::endl; // ofs << " - " << cell->name() << " " << cell->ctype()->name <<
// std::endl;
if (cell->fixed()) { if (cell->fixed()) {
oss << " + FIXED ( " << cell->lx() << " " << cell->ly() << " ) " << getOrient(cell->orient()) << " ;" oss << " + FIXED ( " << cell->lx() << " " << cell->ly() << " ) " << getOrient(cell->orient()) << " ;"
<< std::endl; << std::endl;
// ofs << " + FIXED ( " << cell->lx() << " " << cell->ly() << " ) " // ofs << " + FIXED ( " << cell->lx() << " " << cell->ly() << "
// ) "
// << getOrient(cell->orient()) // << getOrient(cell->orient())
// << " ;" << std::endl; // << " ;" << std::endl;
} else if (cell->placed()) { } else if (cell->placed()) {
oss << " + PLACED ( " << cell->lx() << " " << cell->ly() << " ) " << getOrient(cell->orient()) << " ;" oss << " + PLACED ( " << cell->lx() << " " << cell->ly() << " ) " << getOrient(cell->orient()) << " ;"
<< std::endl; << std::endl;
// ofs << " + PLACED ( " << cell->lx() << " " << cell->ly() << " ) " // ofs << " + PLACED ( " << cell->lx() << " " << cell->ly() <<
// " ) "
// << getOrient(cell->orient()) // << getOrient(cell->orient())
// << " ;" << std::endl; // << " ;" << std::endl;
} else { } else {
@ -463,7 +486,8 @@ bool Database::writeICCAD2017(const string& outputDef) {
} }
logger.info("writing %s", outputDef.c_str()); logger.info("writing %s", outputDef.c_str());
writeComponents(ofs); // just replace the information of components, while others keep remain. writeComponents(ofs); // just replace the information of components, while
// others keep remain.
ofs << "END DESIGN\n\n" << std::endl; ofs << "END DESIGN\n\n" << std::endl;
@ -620,7 +644,9 @@ bool Database::writeBuffer(std::ofstream& ofs, const string& line) {
b += nw; b += nw;
} }
ofs.write(_buffer, _bufferCapacity); // From _buffer write _bufferCapacity charcters to ostream ofs.write(_buffer,
_bufferCapacity); // From _buffer write _bufferCapacity
// charcters to ostream
_bufferSize = 0; _bufferSize = 0;
} }
@ -698,36 +724,36 @@ int readLefProp(lefrCallbackType_e c, lefiProp* prop, lefiUserData ud) {
if (setting.EdgeSpacing) { if (setting.EdgeSpacing) {
dbdist = (int)round(microndist * db->LefConvertFactor); dbdist = (int)round(microndist * db->LefConvertFactor);
} }
int type1_idx = db->edgetypes.getEdgeType(type1); int type1_idx = db->edgetypes->getEdgeType(type1);
int type2_idx = db->edgetypes.getEdgeType(type2); int type2_idx = db->edgetypes->getEdgeType(type2);
if (type1_idx < 0) { if (type1_idx < 0) {
type1_idx = db->edgetypes.types.size(); type1_idx = db->edgetypes->types.size();
db->edgetypes.types.push_back(type1); db->edgetypes->types.push_back(type1);
} }
if (type2_idx < 0) { if (type2_idx < 0) {
type2_idx = db->edgetypes.types.size(); type2_idx = db->edgetypes->types.size();
db->edgetypes.types.push_back(type2); db->edgetypes->types.push_back(type2);
} }
int numEdgeTypes = db->edgetypes.types.size(); int numEdgeTypes = db->edgetypes->types.size();
if (numEdgeTypes > (int)db->edgetypes.distTable.size()) { if (numEdgeTypes > (int)db->edgetypes->distTable.size()) {
db->edgetypes.distTable.resize(numEdgeTypes); db->edgetypes->distTable.resize(numEdgeTypes);
} }
for (int i = 0; i < numEdgeTypes; i++) { for (int i = 0; i < numEdgeTypes; i++) {
db->edgetypes.distTable[i].resize(numEdgeTypes, 0); db->edgetypes->distTable[i].resize(numEdgeTypes, 0);
} }
db->edgetypes.distTable[type1_idx][type2_idx] = dbdist; db->edgetypes->distTable[type1_idx][type2_idx] = dbdist;
db->edgetypes.distTable[type2_idx][type1_idx] = dbdist; db->edgetypes->distTable[type2_idx][type1_idx] = dbdist;
} }
if (buffer == ";") { if (buffer == ";") {
break; break;
} }
} }
// default edge type dist // default edge type dist
for (unsigned i = 0; i < db->edgetypes.types.size(); i++) { for (unsigned i = 0; i < db->edgetypes->types.size(); i++) {
db->edgetypes.distTable[0][i] = 0; db->edgetypes->distTable[0][i] = 0;
db->edgetypes.distTable[i][0] = 0; db->edgetypes->distTable[i][0] = 0;
} }
} }
return 0; return 0;
@ -820,7 +846,8 @@ int readLefLayer(lefrCallbackType_e c, lefiLayer* leflayer, lefiUserData ud) {
if (leflayer->lefiLayer::hasSpacingNumber()) { if (leflayer->lefiLayer::hasSpacingNumber()) {
for (int i = 0; i < leflayer->lefiLayer::numSpacing(); i++) { for (int i = 0; i < leflayer->lefiLayer::numSpacing(); i++) {
// spaceType: 0 -> minSpacing, 1 -> maxEOLSpace, 2 -> maxEOLSpaceParallelEdge // spaceType: 0 -> minSpacing, 1 -> maxEOLSpace, 2 ->
// maxEOLSpaceParallelEdge
int spaceType = 0; int spaceType = 0;
int spacing, width, within, parSpace, parWithin; int spacing, width, within, parSpace, parWithin;
spacing = lround(leflayer->lefiLayer::spacing(i) * convertFactor); spacing = lround(leflayer->lefiLayer::spacing(i) * convertFactor);
@ -1233,9 +1260,9 @@ int readLefMacro(lefrCallbackType_e c, lefiMacro* macro, lefiUserData ud) {
string edgetype; string edgetype;
ssedgetype >> edgeside >> edgetype; ssedgetype >> edgeside >> edgetype;
if (edgeside == "LEFT") { if (edgeside == "LEFT") {
celltype->edgetypeL = db->edgetypes.getEdgeType(edgetype); celltype->edgetypeL = db->edgetypes->getEdgeType(edgetype);
} else if (edgeside == "RIGHT") { } else if (edgeside == "RIGHT") {
celltype->edgetypeR = db->edgetypes.getEdgeType(edgetype); celltype->edgetypeR = db->edgetypes->getEdgeType(edgetype);
} else if (edgeside == "BOTTOM") { } else if (edgeside == "BOTTOM") {
static bool missBot = true; static bool missBot = true;
if (missBot) { if (missBot) {
@ -1350,13 +1377,13 @@ int readDefGcellGrid(defrCallbackType_e c, defiGcellGrid* dgrid, defiUserData ud
Database* db = (Database*)ud; Database* db = (Database*)ud;
const string macro(dgrid->macro()); const string macro(dgrid->macro());
if (macro == "X") { if (macro == "X") {
db->gcellgrid.numX.emplace_back(dgrid->xNum()); db->gcellgrid->numX.emplace_back(dgrid->xNum());
db->gcellgrid.stepX.emplace_back(dgrid->xStep()); db->gcellgrid->stepX.emplace_back(dgrid->xStep());
db->gcellgrid.startX.emplace_back(dgrid->x()); db->gcellgrid->startX.emplace_back(dgrid->x());
} else if (macro == "Y") { } else if (macro == "Y") {
db->gcellgrid.numY.emplace_back(dgrid->xNum()); db->gcellgrid->numY.emplace_back(dgrid->xNum());
db->gcellgrid.stepY.emplace_back(dgrid->xStep()); db->gcellgrid->stepY.emplace_back(dgrid->xStep());
db->gcellgrid.startY.emplace_back(dgrid->x()); db->gcellgrid->startY.emplace_back(dgrid->x());
} }
return 0; return 0;
} }
@ -1500,7 +1527,9 @@ int readDefComponent(defrCallbackType_e c, defiComponent* co, defiUserData ud) {
cell->fixed(true); cell->fixed(true);
if (co->placementOrient() % 2 == 1) { if (co->placementOrient() % 2 == 1) {
// 0:N, 1:W, 2:S, 3:E, 4:FN, 5:FW, 6:FS, 7:FE, -1:NONE // 0:N, 1:W, 2:S, 3:E, 4:FN, 5:FW, 6:FS, 7:FE, -1:NONE
logger.warning("Fixed Cell [%s]'s placementOrient [%s] is not supported, CLASS: %s.", logger.warning(
"Fixed Cell [%s]'s placementOrient [%s] is not supported, "
"CLASS: %s.",
cell->name().c_str(), cell->name().c_str(),
getOrient(co->placementOrient()).c_str(), getOrient(co->placementOrient()).c_str(),
celltype->cls.c_str()); celltype->cls.c_str());
@ -1550,7 +1579,9 @@ int readDefPin(defrCallbackType_e c, defiPin* dpin, defiUserData ud) {
for (int j = 0; j < dpin->numPorts(); j++) { for (int j = 0; j < dpin->numPorts(); j++) {
if (j > 1) { if (j > 1) {
string pinName(dpin->pinName()); string pinName(dpin->pinName());
logger.warning("DefPin %s has multiple ports. We currently only support single port definition", logger.warning(
"DefPin %s has multiple ports. We currently only support "
"single port definition",
pinName.c_str()); pinName.c_str());
break; break;
} }
@ -1686,7 +1717,7 @@ int readDefSNet(defrCallbackType_e c, defiNet* dnet, defiUserData ud) {
} }
snet->addShape(*layer, lx, ly, hx, hy); snet->addShape(*layer, lx, ly, hx, hy);
if ((layer->rIndex == 0 || layer->rIndex == 1) && fy == ty) { if ((layer->rIndex == 0 || layer->rIndex == 1) && fy == ty) {
db->powerNet.addRail(snet, lx, hx, fy); db->powerNet->addRail(snet, lx, hx, fy);
} }
fx = tx; fx = tx;
fy = ty; fy = ty;
@ -1717,7 +1748,7 @@ int readDefSNet(defrCallbackType_e c, defiNet* dnet, defiUserData ud) {
} }
snet->addShape(*layer, lx, ly, hx, hy); snet->addShape(*layer, lx, ly, hx, hy);
if ((layer->rIndex == 0 || layer->rIndex == 1) && fy == ty) { if ((layer->rIndex == 0 || layer->rIndex == 1) && fy == ty) {
db->powerNet.addRail(snet, lx, hx, fy); db->powerNet->addRail(snet, lx, hx, fy);
} }
fx = tx; fx = tx;
fy = ty; fy = ty;
@ -1891,7 +1922,8 @@ int readDefRegion(defrCallbackType_e c, defiRegion* dreg, defiUserData ud) {
} }
//-----Group----- //-----Group-----
// #define GROUP_MARKER 9999999 //first mark all group member cell with this marker, then replace the value in one scan // #define GROUP_MARKER 9999999 //first mark all group member cell with this
// marker, then replace the value in one scan
int readDefGroupName(defrCallbackType_e c, const char* cl, defiUserData ud) { return 0; } int readDefGroupName(defrCallbackType_e c, const char* cl, defiUserData ud) { return 0; }
int readDefGroupMember(defrCallbackType_e c, const char* cl, defiUserData ud) { int readDefGroupMember(defrCallbackType_e c, const char* cl, defiUserData ud) {

View File

@ -1,4 +1,8 @@
#include "common/db/Cell.h"
#include "common/db/Database.h" #include "common/db/Database.h"
#include "common/db/Layer.h"
#include "common/db/Net.h"
#include "common/db/Pin.h"
using namespace db; using namespace db;
@ -135,7 +139,7 @@ bool Database::readVerilog(const std::string &file) {
if (!iopin) { if (!iopin) {
logger.error("io pin not found: %s", pinName.c_str()); logger.error("io pin not found: %s", pinName.c_str());
} }
Pin* pin = iopin->pin; Pin *pin = iopin->pin;
iopin->is_connected = true; iopin->is_connected = true;
Net *net = addNet(pinName); Net *net = addNet(pinName);

View File

@ -10,6 +10,4 @@ target_compile_definitions(${TARGET_NAME} PRIVATE
TORCH_MINOR_VERSION=${TORCH_MINOR_VERSION} TORCH_MINOR_VERSION=${TORCH_MINOR_VERSION}
ENABLE_CUDA=0) ENABLE_CUDA=0)
install(TARGETS install(TARGETS ${TARGET_NAME} DESTINATION ${XPLACE_LIB_DIR})
${TARGET_NAME}
DESTINATION ${XPLACE_LIB_DIR})

View File

@ -8,30 +8,27 @@ file(GLOB_RECURSE SRC_FILES_DP_CUDA ${CMAKE_CURRENT_SOURCE_DIR}/*.cu)
# OpenMP # OpenMP
find_package(OpenMP REQUIRED) find_package(OpenMP REQUIRED)
# CUDA DP Kernel # CUDA/CPP DP Kernel
cuda_add_library(dp_cuda_tmp STATIC ${SRC_FILES_DP_CUDA}) add_library(dp STATIC ${CMAKE_CURRENT_SOURCE_DIR}/../io_parser/gp/GPDatabase.cpp
set_target_properties(dp_cuda_tmp PROPERTIES CUDA_RESOLVE_DEVICE_SYMBOLS ON)
set_target_properties(dp_cuda_tmp PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
set_target_properties(dp_cuda_tmp PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_include_directories(dp_cuda_tmp PRIVATE ${PROJECT_SOURCE_DIR}/cpp_to_py ${TORCH_INCLUDE_DIRS} ${FLUTE_INCLUDE_DIR})
target_link_libraries(dp_cuda_tmp torch ${TORCH_PYTHON_LIBRARY} xplace_common flute OpenMP::OpenMP_CXX)
# CPU DP object
add_library(dp SHARED ${CMAKE_CURRENT_SOURCE_DIR}/../io_parser/gp/GPDatabase.cpp
${SRC_FILES_DP} ${SRC_FILES_DP}
${SRC_FILES_DP_CUDA}) ${SRC_FILES_DP_CUDA})
target_include_directories(dp PRIVATE ${PROJECT_SOURCE_DIR}/cpp_to_py ${TORCH_INCLUDE_DIRS} ${FLUTE_INCLUDE_DIR}) set_target_properties(dp PROPERTIES
target_link_libraries(dp PRIVATE torch ${TORCH_PYTHON_LIBRARY} xplace_common flute dp_cuda_tmp pthread CUDA::curand) CUDA_RESOLVE_DEVICE_SYMBOLS ON
POSITION_INDEPENDENT_CODE ON)
target_include_directories(dp PRIVATE ${TORCH_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/cpp_to_py)
target_link_libraries(dp PRIVATE torch ${TORCH_PYTHON_LIBRARY} xplace_common OpenMP::OpenMP_CXX pthread CUDA::curand)
target_compile_options(dp PRIVATE -fPIC) target_compile_options(dp PRIVATE -fPIC)
install(TARGETS dp DESTINATION ${XPLACE_LIB_DIR}) pybind11_add_module(gpudp MODULE PyBindCppMain.cpp)
# For Pybind target_include_directories(gpudp PRIVATE ${TORCH_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/cpp_to_py)
add_pytorch_extension(gpudp PyBindCppMain.cpp target_link_libraries(gpudp PRIVATE torch ${TORCH_PYTHON_LIBRARY} xplace_common io_parser dp)
EXTRA_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/cpp_to_py ${FLUTE_INCLUDE_DIR} target_compile_definitions(gpudp PRIVATE
EXTRA_LINK_LIBRARIES xplace_common flute io_parser dp) TORCH_EXTENSION_NAME=gpudp
TORCH_VERSION_MAJOR=${TORCH_VERSION_MAJOR}
TORCH_VERSION_MINOR=${TORCH_VERSION_MINOR}
ENABLE_CUDA=${TORCH_ENABLE_CUDA})
install(TARGETS gpudp DESTINATION ${XPLACE_LIB_DIR}) install(TARGETS gpudp DESTINATION ${XPLACE_LIB_DIR})

View File

@ -2,7 +2,10 @@
#include <torch/extension.h> #include <torch/extension.h>
#include "common/common.h" #include "common/common.h"
#include "common/db/Database.h"
namespace db {
class Database;
}
namespace dp { namespace dp {

View File

@ -4,7 +4,6 @@
#include <cuda_runtime.h> #include <cuda_runtime.h>
#include "common/common.h" #include "common/common.h"
#include "common/db/Database.h"
#include "gpudp/db/dp_torch.h" #include "gpudp/db/dp_torch.h"
#include "pitch_nested_vector.cuh" #include "pitch_nested_vector.cuh"
#include "utils.cuh" #include "utils.cuh"

View File

@ -1,7 +1,6 @@
#pragma once #pragma once
#include "common/common.h" #include "common/common.h"
#include "common/db/Database.h"
#include "gpudp/db/dp_torch.h" #include "gpudp/db/dp_torch.h"
namespace dp { namespace dp {

View File

@ -3,67 +3,29 @@ file(GLOB_RECURSE SRC_FILES_GGR ${CMAKE_CURRENT_SOURCE_DIR}/db/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gr/*.cpp) ${CMAKE_CURRENT_SOURCE_DIR}/gr/*.cpp)
file(GLOB_RECURSE SRC_FILES_GGR_CUDA ${CMAKE_CURRENT_SOURCE_DIR}/*.cu) file(GLOB_RECURSE SRC_FILES_GGR_CUDA ${CMAKE_CURRENT_SOURCE_DIR}/*.cu)
# CUDA GGR Kernel # CUDA/CPP GGR Kernel
cuda_add_library(ggr_cuda_tmp STATIC ${SRC_FILES_GGR_CUDA}) add_library(ggr STATIC ${CMAKE_CURRENT_SOURCE_DIR}/../io_parser/gp/GPDatabase.cpp
set_target_properties(ggr_cuda_tmp PROPERTIES CUDA_RESOLVE_DEVICE_SYMBOLS ON)
set_target_properties(ggr_cuda_tmp PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
set_target_properties(ggr_cuda_tmp PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_include_directories(ggr_cuda_tmp PRIVATE ${PROJECT_SOURCE_DIR}/cpp_to_py ${TORCH_INCLUDE_DIRS} ${FLUTE_INCLUDE_DIR})
target_link_libraries(ggr_cuda_tmp torch ${TORCH_PYTHON_LIBRARY} xplace_common flute)
# target_compile_options(ggr_cuda_tmp PRIVATE "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:-use_fast_math>") # not work...
# CPU GGR object
add_library(ggr SHARED ${CMAKE_CURRENT_SOURCE_DIR}/../io_parser/gp/GPDatabase.cpp
${SRC_FILES_GGR} ${SRC_FILES_GGR}
${SRC_FILES_GGR_CUDA}) ${SRC_FILES_GGR_CUDA})
target_include_directories(ggr PRIVATE ${PROJECT_SOURCE_DIR}/cpp_to_py ${TORCH_INCLUDE_DIRS} ${FLUTE_INCLUDE_DIR}) set_target_properties(ggr PROPERTIES
target_link_libraries(ggr PRIVATE torch ${TORCH_PYTHON_LIBRARY} xplace_common flute ggr_cuda_tmp pthread) CUDA_RESOLVE_DEVICE_SYMBOLS ON
POSITION_INDEPENDENT_CODE ON)
target_include_directories(ggr PRIVATE ${TORCH_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/cpp_to_py ${FLUTE_INCLUDE_DIR})
target_link_libraries(ggr PRIVATE torch ${TORCH_PYTHON_LIBRARY} xplace_common flute pthread)
target_compile_options(ggr PRIVATE -fPIC) target_compile_options(ggr PRIVATE -fPIC)
target_compile_options(ggr PRIVATE "$<$<COMPILE_LANGUAGE:CUDA>:--extended-lambda>")
install(TARGETS ggr DESTINATION ${XPLACE_LIB_DIR}) pybind11_add_module(gpugr MODULE PyBindCppMain.cpp)
target_include_directories(gpugr PRIVATE ${TORCH_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/cpp_to_py ${FLUTE_INCLUDE_DIR})
target_link_libraries(gpugr PRIVATE torch ${TORCH_PYTHON_LIBRARY} xplace_common flute io_parser ggr)
target_compile_definitions(gpugr PRIVATE
TORCH_EXTENSION_NAME=gpugr
TORCH_VERSION_MAJOR=${TORCH_VERSION_MAJOR}
TORCH_VERSION_MINOR=${TORCH_VERSION_MINOR}
ENABLE_CUDA=${TORCH_ENABLE_CUDA})
# For Pybind
add_pytorch_extension(gpugr PyBindCppMain.cpp
EXTRA_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/cpp_to_py ${FLUTE_INCLUDE_DIR}
EXTRA_LINK_LIBRARIES xplace_common flute io_parser ggr)
install(TARGETS gpugr DESTINATION ${XPLACE_LIB_DIR}) install(TARGETS gpugr DESTINATION ${XPLACE_LIB_DIR})
################ For debug only ##################
# set(CMAKE_BUILD_TYPE Release)
# set(CMAKE_CXX_STANDARD 17)
# set(CMAKE_CUDA17_EXTENSION_COMPILE_OPTION "-std=c++17")
# set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -arch sm_86 --extended-lambda --use_fast_math ")
# project(ggr LANGUAGES C CXX CUDA)
# file(GLOB_RECURSE SRC_FILES_GR2 ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
# file(GLOB_RECURSE SRC_FILES_GR2_CUDA ${CMAKE_CURRENT_SOURCE_DIR}/*.cu)
# add_executable(gpugr_cpp PyBindCppMain.cpp
# ${CMAKE_CURRENT_SOURCE_DIR}/../io_parser/gp/GPDatabase.cpp
# ${SRC_FILES_GR2}
# ${SRC_FILES_GR2_CUDA})
# set_target_properties(gpugr_cpp PROPERTIES CUDA_RESOLVE_DEVICE_SYMBOLS ON)
# set_target_properties(gpugr_cpp PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
# set_target_properties(gpugr_cpp PROPERTIES LINK_FLAGS "-Wl,--whole-archive -rdynamic -lpthread -Wl,--no-whole-archive")
# target_include_directories(
# gpugr_cpp PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/.. ${PROJECT_SOURCE_DIR}/cpp_to_py ${FLUTE_INCLUDE_DIR} ${TORCH_INCLUDE_DIRS})
# target_link_libraries(
# gpugr_cpp PRIVATE torch ${TORCH_PYTHON_LIBRARY} flute xplace_common)
# target_compile_options(gpugr_cpp PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:
# -arch=sm_86
# --use_fast_math
# -std=c++17
# >)
# install(TARGETS
# gpugr_cpp
# DESTINATION ${XPLACE_LIB_DIR})

View File

@ -1,5 +1,6 @@
#include "common/common.h" #include "common/common.h"
#include "common/db/Database.h" #include "common/db/Database.h"
#include "io_parser/gp/GPDatabase.h"
#include "gpugr/db/GRDatabase.h" #include "gpugr/db/GRDatabase.h"
#include "gpugr/gr/RouteForce.h" #include "gpugr/gr/RouteForce.h"
#include "flute.h" #include "flute.h"

View File

@ -1,5 +1,16 @@
#include "GRDatabase.h" #include "GRDatabase.h"
#include "common/db/BsRouteInfo.h"
#include "common/db/Cell.h"
#include "common/db/Database.h"
#include "common/db/Layer.h"
#include "common/db/GCellGrid.h"
#include "common/db/Net.h"
#include "common/db/Pin.h"
#include "common/db/SNet.h"
#include "common/db/Via.h"
#include "io_parser/gp/GPDatabase.h"
namespace gr { namespace gr {
GRDatabase::~GRDatabase() { logger.info("destruct grdb"); } GRDatabase::~GRDatabase() { logger.info("destruct grdb"); }
@ -67,9 +78,9 @@ GRDatabase::GRDatabase(std::shared_ptr<db::Database> rawdb_, std::shared_ptr<gp:
// 2) init gcellgrid // 2) init gcellgrid
// 2.1) grid lines // 2.1) grid lines
db::GCellGrid& gcellgrid = rawdb.gcellgrid; db::GCellGrid* gcellgrid = rawdb.gcellgrid;
gridlines.resize(2); gridlines.resize(2);
if (!gcellgrid.numX.size() || !gcellgrid.numY.size()) { if (!gcellgrid->numX.size() || !gcellgrid->numY.size()) {
if (grSetting.routeXSize <= 0 || grSetting.routeYSize <= 0) { if (grSetting.routeXSize <= 0 || grSetting.routeYSize <= 0) {
grSetting.routeXSize = 512; grSetting.routeXSize = 512;
grSetting.routeYSize = 512; grSetting.routeYSize = 512;
@ -77,16 +88,16 @@ GRDatabase::GRDatabase(std::shared_ptr<db::Database> rawdb_, std::shared_ptr<gp:
} }
if (grSetting.routeXSize <= 0 || grSetting.routeYSize <= 0) { if (grSetting.routeXSize <= 0 || grSetting.routeYSize <= 0) {
gridlines[0].emplace_back(0); gridlines[0].emplace_back(0);
for (int idx = 0; idx < gcellgrid.numX.size(); idx++) { for (int idx = 0; idx < gcellgrid->numX.size(); idx++) {
for (int i = 1; i < gcellgrid.numX[idx]; i++) { for (int i = 1; i < gcellgrid->numX[idx]; i++) {
gridlines[0].emplace_back(gcellgrid.startX[idx] + i * gcellgrid.stepX[idx]); gridlines[0].emplace_back(gcellgrid->startX[idx] + i * gcellgrid->stepX[idx]);
} }
} }
gridlines[1].emplace_back(0); gridlines[1].emplace_back(0);
for (int idx = 0; idx < gcellgrid.numY.size(); idx++) { for (int idx = 0; idx < gcellgrid->numY.size(); idx++) {
for (int i = 1; i < gcellgrid.numY[idx]; i++) { for (int i = 1; i < gcellgrid->numY[idx]; i++) {
gridlines[1].emplace_back(gcellgrid.startY[idx] + i * gcellgrid.stepY[idx]); gridlines[1].emplace_back(gcellgrid->startY[idx] + i * gcellgrid->stepY[idx]);
} }
} }
} else { } else {
@ -109,16 +120,16 @@ GRDatabase::GRDatabase(std::shared_ptr<db::Database> rawdb_, std::shared_ptr<gp:
if (grSetting.routeXSize <= 0 || grSetting.routeYSize <= 0) { if (grSetting.routeXSize <= 0 || grSetting.routeYSize <= 0) {
int largeNumX = -1, largeNumY = -1; int largeNumX = -1, largeNumY = -1;
for (int idx = 0; idx < gcellgrid.numX.size(); idx++) { for (int idx = 0; idx < gcellgrid->numX.size(); idx++) {
if (largeNumX < gcellgrid.numX[idx]) { if (largeNumX < gcellgrid->numX[idx]) {
largeNumX = gcellgrid.numX[idx]; largeNumX = gcellgrid->numX[idx];
mainGcellStepX = gcellgrid.stepX[idx]; mainGcellStepX = gcellgrid->stepX[idx];
} }
} }
for (int idx = 0; idx < gcellgrid.numY.size(); idx++) { for (int idx = 0; idx < gcellgrid->numY.size(); idx++) {
if (largeNumY < gcellgrid.numY[idx]) { if (largeNumY < gcellgrid->numY[idx]) {
largeNumY = gcellgrid.numY[idx]; largeNumY = gcellgrid->numY[idx];
mainGcellStepY = gcellgrid.stepY[idx]; mainGcellStepY = gcellgrid->stepY[idx];
} }
} }
} else { } else {
@ -191,7 +202,7 @@ void GRDatabase::setupCapacity() {
void GRDatabase::setupCapacityBookshelf() { void GRDatabase::setupCapacityBookshelf() {
capacity.resize(gridGraphSize, 0); capacity.resize(gridGraphSize, 0);
for (int i = 0; i < nLayers; i++) { for (int i = 0; i < nLayers; i++) {
int oricap = std::max(rawdb.bsRouteInfo.capH[i], rawdb.bsRouteInfo.capV[i]); int oricap = std::max(rawdb.bsRouteInfo->capH[i], rawdb.bsRouteInfo->capV[i]);
float cap = oricap / (layerPitch[i]); float cap = oricap / (layerPitch[i]);
if ((i & 1) ^ m1direction) { if ((i & 1) ^ m1direction) {
for (int j = 0; j < xSize; j++) { for (int j = 0; j < xSize; j++) {
@ -608,7 +619,7 @@ void GRDatabase::markObsBookShelf(std::vector<RectOnLayer>& allObs,
std::vector<float> layer2oricap(nLayers, 0.0); std::vector<float> layer2oricap(nLayers, 0.0);
for (int i = 0; i < nLayers; i++) { for (int i = 0; i < nLayers; i++) {
int oricap = std::max(rawdb.bsRouteInfo.capH[i], rawdb.bsRouteInfo.capV[i]); int oricap = std::max(rawdb.bsRouteInfo->capH[i], rawdb.bsRouteInfo->capV[i]);
float cap = oricap / (layerPitch[i]); float cap = oricap / (layerPitch[i]);
layer2oricap[i] = oricap; layer2oricap[i] = oricap;
} }
@ -695,7 +706,7 @@ void GRDatabase::markObsBookShelf(std::vector<RectOnLayer>& allObs,
ovlpLen = buf[0].range(); ovlpLen = buf[0].range();
} }
// Follow perl script dac2012_evaluate_solution.pl // Follow perl script dac2012_evaluate_solution.pl
float blocked = floor((float)ovlpLen * (1.0 - rawdb.bsRouteInfo.blockagePorosity)); float blocked = floor((float)ovlpLen * (1.0 - rawdb.bsRouteInfo->blockagePorosity));
float availableSpace = ((float)gridIntvl.range() - blocked) / (float)gridIntvl.range(); float availableSpace = ((float)gridIntvl.range() - blocked) / (float)gridIntvl.range();
int adjustedCap = layer2oricap[l] * availableSpace; int adjustedCap = layer2oricap[l] * availableSpace;
adjustedCap = std::max(0, adjustedCap); adjustedCap = std::max(0, adjustedCap);

View File

@ -1,9 +1,15 @@
#pragma once #pragma once
#include "GRSetting.h"
#include "GrNet.h" #include "GrNet.h"
#include "common/common.h" #include "common/common.h"
#include "common/db/Database.h" #include "GRSetting.h"
#include "io_parser/gp/GPDatabase.h"
namespace db {
class Database;
class Cell;
}
namespace gp {
class GPDatabase;
}
namespace gr { namespace gr {

View File

@ -1,4 +1,7 @@
#include "RouteForce.h" #include "RouteForce.h"
#include "common/db/Database.h"
#include "io_parser/gp/GPDatabase.h"
#include "gpugr/db/GRDatabase.h"
namespace gr { namespace gr {

View File

@ -1,9 +1,11 @@
#pragma once #pragma once
#include "common/common.h" #include "common/common.h"
#include "common/db/Database.h"
#include "gpugr/db/GRDatabase.h"
#include "gpugr/gr/GPURouter.h" #include "gpugr/gr/GPURouter.h"
namespace gr {
class GRDatabase;
}
namespace gr { namespace gr {
class RouteForce { class RouteForce {

View File

@ -1,4 +1,6 @@
#include "BindHelper.h" #include "BindHelper.h"
#include "common/db/Database.h"
#include "io_parser/gp/GPDatabase.h"
namespace Xplace { namespace Xplace {

View File

@ -1,8 +1,5 @@
#pragma once #pragma once
#include "common/common.h" #include "common/common.h"
#include "common/db/Database.h"
#include "io_parser/gp/GPDatabase.h"
#include <pybind11/pybind11.h> #include <pybind11/pybind11.h>
#include <pybind11/stl.h> #include <pybind11/stl.h>
#include <pybind11/stl_bind.h> #include <pybind11/stl_bind.h>

View File

@ -1,4 +1,6 @@
#include "BindHelper.h" #include "BindHelper.h"
#include "common/db/Database.h"
#include "io_parser/gp/GPDatabase.h"
namespace Xplace { namespace Xplace {

View File

@ -1,5 +1,15 @@
#include "GPDatabase.h" #include "GPDatabase.h"
#include "common/db/Cell.h"
#include "common/db/Database.h"
#include "common/db/Layer.h"
#include "common/db/Net.h"
#include "common/db/Pin.h"
#include "common/db/Region.h"
#include "common/db/Row.h"
#include "common/db/SNet.h"
#include "common/db/Via.h"
namespace gp { namespace gp {
GPDatabase::~GPDatabase() { logger.info("destruct gpdb"); } GPDatabase::~GPDatabase() { logger.info("destruct gpdb"); }
@ -364,7 +374,6 @@ orient_type rotate_180_orient(orient_type orient) {
orient_type vflip_orient(orient_type orient) { return hflip_orient(rotate_180_orient(orient)); } orient_type vflip_orient(orient_type orient) { return hflip_orient(rotate_180_orient(orient)); }
void GPDatabase::transferOrient() { void GPDatabase::transferOrient() {
// Transfer all gpdb nodes to "N" direction for global placement // Transfer all gpdb nodes to "N" direction for global placement
// NOTE: we don't change rawdb // NOTE: we don't change rawdb
@ -592,6 +601,8 @@ void GPDatabase::setup_random_place() {
} }
} }
const int GPDatabase::getM1Direction() const { return database.getRLayer(0)->direction == 'v' ? 1 : 0; }
// Torch Related // Torch Related
torch::Tensor GPDatabase::getNodeLPosTensor() { torch::Tensor GPDatabase::getNodeLPosTensor() {
torch::Tensor node_lpos = torch::zeros({num_nodes, 2}); torch::Tensor node_lpos = torch::zeros({num_nodes, 2});

View File

@ -1,7 +1,12 @@
#pragma once #pragma once
#include <torch/extension.h> #include <torch/extension.h>
#include "common/common.h" #include "common/common.h"
#include "common/db/Database.h"
namespace db {
class Database;
class Pin;
class PinType;
}
namespace gp { namespace gp {
@ -210,7 +215,7 @@ public:
const std::tuple<int, int, int, int>& getCoreInfo() const { return coreInfo; } const std::tuple<int, int, int, int>& getCoreInfo() const { return coreInfo; }
const int getSiteWidth() const { return siteW; } const int getSiteWidth() const { return siteW; }
const int getSiteHeight() const { return siteH; } const int getSiteHeight() const { return siteH; }
const int getM1Direction() const { return database.getRLayer(0)->direction == 'v' ? 1 : 0; } const int getM1Direction() const;
// Torch related // Torch related
torch::Tensor getNodeLPosTensor(); torch::Tensor getNodeLPosTensor();

View File

@ -1,7 +1,10 @@
#include <torch/extension.h> #include <torch/extension.h>
#include "common/common.h" #include "common/common.h"
#include "common/db/Database.h" #include "common/db/Database.h"
#include "flute.h" #include "common/db/Geometry.h"
#include "common/db/Layer.h"
#include "common/db/SNet.h"
#include "common/db/Via.h"
#include "io_parser/gp/GPDatabase.h" #include "io_parser/gp/GPDatabase.h"
namespace routedp { namespace routedp {

View File

@ -29,7 +29,7 @@
## USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ## USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
################################################################################ ################################################################################
CMAKE_MINIMUM_REQUIRED (VERSION 3.1) CMAKE_MINIMUM_REQUIRED (VERSION 3.18)
PROJECT(flute) PROJECT(flute)
SET(CMAKE_CXX_STANDARD 11) SET(CMAKE_CXX_STANDARD 11)

2
thirdparty/pybind11 vendored

@ -1 +1 @@
Subproject commit 128d988ef183cfb6334714f0bcf8b8e7b7e2e95b Subproject commit 83b92ceb3537666fb0188f564e1d53bf8c80b0ba