Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Interchange] Refactor & speedup reader/writers #677

Merged
merged 27 commits into from
Jun 13, 2023
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
1d765db
Refactor Interchange Log/Phys Reader/Writer
eddieh-xlnx May 8, 2023
a8a53ec
More tidying up
eddieh-xlnx May 9, 2023
bfa17d3
Fix broken test
eddieh-xlnx May 9, 2023
091e3dc
Merge remote-tracking branch 'upstream/master' into interchange_refac
eddieh-xlnx May 19, 2023
413c08c
More refactoring/improvements
eddieh-xlnx May 19, 2023
63736d2
Fix collapse macro collision, plus optimize
eddieh-xlnx May 19, 2023
f52a813
Test for collapseMacroUnisims() does not collide
eddieh-xlnx May 19, 2023
9f580ec
EDIFNetlist.getHDIPrimitive() to deep copy too
eddieh-xlnx May 19, 2023
787a2a8
Split Enumerator into {Identity,String}Enumerator
eddieh-xlnx May 19, 2023
9cef6ae
Get rid of EDIFEnumerable
eddieh-xlnx May 19, 2023
2f9f448
Interchange.benchmark() to return Path
eddieh-xlnx May 19, 2023
24563e9
Bump copyright year
eddieh-xlnx May 19, 2023
d4a0689
Merge branch 'interchange_enum' into interchange_refac
eddieh-xlnx May 20, 2023
78a28b2
Fix EDIFNetlist.getHDIPrimitive()
eddieh-xlnx May 20, 2023
6df225c
Fix EDIFNetlist.getHDIPrimitive()
eddieh-xlnx May 20, 2023
69ebd16
Merge branch 'edif_collapse_macro' into interchange_enum
eddieh-xlnx May 20, 2023
2f3cfe3
Merge branch 'interchange_enum' into interchange_refac
eddieh-xlnx May 20, 2023
106a8bc
Merge remote-tracking branch 'upstream/master' into interchange_enum
eddieh-xlnx May 20, 2023
1564255
Merge branch 'interchange_enum' into interchange_refac
eddieh-xlnx May 20, 2023
e4ee420
Another EDIFNetlist.getHDIPrimitive() fix
eddieh-xlnx May 20, 2023
6508e0b
Merge branch 'edif_collapse_macro' into interchange_enum
eddieh-xlnx May 20, 2023
f89b65a
Merge branch 'interchange_enum' into interchange_refac
eddieh-xlnx May 20, 2023
863ff01
Merge remote-tracking branch 'upstream/master' into interchange_refac
eddieh-xlnx May 23, 2023
2014dc2
Update src/com/xilinx/rapidwright/interchange/IdentityEnumerator.java
eddieh-xlnx May 23, 2023
146d9e1
Merge remote-tracking branch 'upstream/master' into interchange_refac
eddieh-xlnx Jun 13, 2023
75be208
Address some review comments
eddieh-xlnx Jun 13, 2023
c276a92
Address some more review
eddieh-xlnx Jun 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/com/xilinx/rapidwright/edif/EDIFNet.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
*
* Copyright (c) 2017-2022, Xilinx, Inc.
* Copyright (c) 2022, Advanced Micro Devices, Inc.
* Copyright (c) 2022-2023, Advanced Micro Devices, Inc.
* All rights reserved.
*
* Author: Chris Lavin, Xilinx Research Labs.
Expand Down Expand Up @@ -224,6 +224,10 @@ public EDIFPortInst createPortInst(EDIFPort port, EDIFCellInst cellInst) {
return new EDIFPortInst(port, this, cellInst);
}

public EDIFPortInst createPortInst(EDIFPort port, EDIFCellInst cellInst, boolean deferSort) {
return new EDIFPortInst(port, this, cellInst, deferSort);
}

public EDIFPortInst createPortInst(EDIFPort port, int index, EDIFCellInst cellInst) {
return new EDIFPortInst(port, this, index, cellInst);
}
Expand Down
19 changes: 18 additions & 1 deletion src/com/xilinx/rapidwright/edif/EDIFPortInst.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public EDIFPortInst(EDIFPortInst portInst) {
public EDIFPortInst(EDIFPort port, EDIFNet parentNet, int index) {
this(port,parentNet,index,null);
}

/**
* Constructor to create a single bit port ref and associate it with its
* net and instance.
Expand All @@ -73,7 +74,23 @@ public EDIFPortInst(EDIFPort port, EDIFNet parentNet, int index) {
* @param cellInst The instance this port ref belongs to
*/
public EDIFPortInst(EDIFPort port, EDIFNet parentNet, EDIFCellInst cellInst) {
this(port, parentNet, -1, cellInst);
this(port, parentNet, -1, cellInst, false);
}

/**
* Constructor to create a single bit port ref and associate it with its
* net and instance.
* @param port The port on the cell this port ref uses
* @param parentNet The net this port ref should belong to
* @param cellInst The instance this port ref belongs to
* @param deferSort The EDIFPortInstList maintains a sorted list of EDIFPortInst
* objects and sorts them upon insertion. Setting this flag to true will skip a sort addition
* but the caller is responsible to conclude a batch of additions with a call to
* {@link EDIFPortInstList#reSortList()}. This is useful when a large number of EDIFPortInsts
* will be added consecutively (such as parsing a netlist).
*/
public EDIFPortInst(EDIFPort port, EDIFNet parentNet, EDIFCellInst cellInst, boolean deferSort) {
this(port, parentNet, -1, cellInst, deferSort);
}

/**
Expand Down
101 changes: 101 additions & 0 deletions src/com/xilinx/rapidwright/interchange/BELPinCache.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/*
* Copyright (c) 2023, Advanced Micro Devices, Inc.
* All rights reserved.
*
* Author: Eddie Hung, Advanced Micro Devices, Inc.
*
* This file is part of RapidWright.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package com.xilinx.rapidwright.interchange;

import com.xilinx.rapidwright.design.SiteInst;
import com.xilinx.rapidwright.device.BEL;
import com.xilinx.rapidwright.device.BELPin;
import com.xilinx.rapidwright.device.SiteTypeEnum;

import java.util.List;
import java.util.Map;

/**
* Class for caching BELPin lookups, given a SiteInst object, and string
* indices for the BEL and BELPin names.
*/
public class BELPinCache {
private static class Key {
public final SiteTypeEnum siteTypeEnum;
public int belStringIdx;
public int pinStringIdx;

public Key(SiteInst siteInst, int belStringIdx, int pinStringIdx) {
siteTypeEnum = siteInst.getSiteTypeEnum();
this.belStringIdx = belStringIdx;
this.pinStringIdx = pinStringIdx;
}

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + siteTypeEnum.ordinal();
result = prime * result + belStringIdx;
result = prime * result + pinStringIdx;
return result;
}

@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Key other = (Key) obj;
return belStringIdx == other.belStringIdx &&
pinStringIdx == other.pinStringIdx &&
siteTypeEnum == other.siteTypeEnum;
}
}

private final Map<Key, BELPin> map;

private final List<String> strings;

public BELPinCache(Map<Key, BELPin> map, List<String> strings) {
this.map = map;
this.strings = strings;
}

public BELPin getBELPin(SiteInst siteInst, int belStringIdx, int pinStringIdx) {
Key key = new Key(siteInst, belStringIdx, pinStringIdx);
return map.computeIfAbsent(key, (k) -> {
String belName = strings.get(k.belStringIdx);
BEL bel = siteInst.getBEL(belName);
if (bel == null) {
throw new RuntimeException(String.format("ERROR: Failed to get BEL %s", belName));
}

String belPinName = strings.get(k.pinStringIdx);
BELPin belPin = bel.getPin(belPinName);
if (belPin == null) {
throw new RuntimeException(String.format("ERROR: Failed to get BEL pin %s/%s", belName, belPinName));
}

return belPin;
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ public static void writeDeviceResourcesFile(String part, Device device, CodePerf
put(series+"_"+EDIFTools.MACRO_PRIMITIVES_LIB, LogNetlistWriter.DEVICE_MACROS_LIB);
}}
);
writer.populateNetlistBuilder(netlist, netlistBuilder);
writer.populateNetlistBuilder(netlist, netlistBuilder, CodePerfTracker.SILENT);

writeCellParameterDefinitions(series, netlist, devBuilder.getParameterDefs());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public void ensureSize(int size) {

@Override
public T get(int index) {
// if (size() -1 < index) return null;
return super.get(index);
}

Expand Down
Loading