-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Hi, I would like to know how the pin coordinates are extracted using dreamplace?
Thanks.
Hi, you can read the DEF into DREAMPlace, and call the pinpos operator to get a tensor of pin positions. You can read DREAMPlace's HPWL operator to see how its inputs are constructed (their input contains the pin coordinate tensor).
Originally posted by @gzz2000 in #8 (comment)
Hi,
I previously posted a related inquiry in another thread, but since that thread has been marked as completed, I believe it would be better to post this as a new issue.
As stated in the title, I’m seeing discrepancies in pin locations when using the pin_pos operation mentioned in that issue. I retrieved the pin locations for comparison, but they don’t exactly match the locations given by the nf[2:5] dump. (For reference, I used the “spm” design for testing.)
Additionally, I reviewed the description of nf[2:5] in the repository. The pin order doesn’t appear to follow the expected top/left/right/bottom layout of the die area. It seems that nf[2] + nf[5] and nf[3] + nf[4] do not match the die area height and width, respectively.
Could you please clarify this discrepancy?
The following is the minimum code to reproduce.
import sys
import os
import logging
# for consistency between python2 and python3
root_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
if root_dir not in sys.path:
sys.path.append(root_dir)
import numpy as np
import torch
import PlaceDB
import Params
from dreamplace.ops.pin_pos.pin_pos import PinPosFunction, PinPosSegmentFunction
from dreamplace.ops.hpwl.hpwl import HPWLFunction, HPWLAtomicFunction
from dreamplace.ops.pin_pos.pin_pos import PinPos
from dreamplace.ops.hpwl.hpwl import HPWL
if __name__ == '__main__':
np.set_printoptions(threshold=np.inf, suppress=True)
params = Params.Params()
params.load(sys.argv[1]) # only read the DEF/LEF file in this json file
logging.info("parameters = %s" % (params))
placedb = PlaceDB.PlaceDB()
placedb(params)
pin_offset_x = torch.from_numpy(placedb.pin_offset_x).to(torch.float).cuda()
pin_offset_y = torch.from_numpy(placedb.pin_offset_y).to(torch.float).cuda()
pin2node_map = torch.from_numpy(placedb.pin2node_map).to(torch.long).cuda()
flat_node2pin_map = torch.from_numpy(placedb.flat_node2pin_map).to(torch.int).cuda()
flat_node2pin_start_map = torch.from_numpy(placedb.flat_node2pin_start_map).to(torch.int).cuda()
pin_pos_instance = PinPos(
pin_offset_x=pin_offset_x,
pin_offset_y=pin_offset_y,
pin2node_map=pin2node_map,
flat_node2pin_map=flat_node2pin_map,
flat_node2pin_start_map=flat_node2pin_start_map,
num_physical_nodes=placedb.num_physical_nodes,
)
pin_pos_instance = pin_pos_instance.cuda()
pos = torch.cat([torch.from_numpy(placedb.node_x).to(torch.float),
torch.from_numpy(placedb.node_y).to(torch.float)]).cuda()
pin_pos = pin_pos_instance(pos)
# only use for checking the pin locations
pin_pos = np.array(pin_pos.cpu())
pin_x = pin_pos[:placedb.num_pins]
pin_y = pin_pos[placedb.num_pins:]
pin_pos = np.stack((pin_x, pin_y), axis=1)
left = placedb.xl
right = placedb.xh
bottom = placedb.yl
top = placedb.yh
relative_distances = np.array([
pin_pos[:, 0] - left, # distance_to_left
right - pin_pos[:, 0], # distance_to_right
pin_pos[:, 1] - bottom, # distance_to_bottom
top - pin_pos[:, 1], # distance_to_top
]).T
relative_distances = np.array(relative_distances)
with open('pins', mode='w+', encoding='UTF-8') as file:
file.write(str(relative_distances))
logging.info('write successfully')Thanks in advance for your help.