Skip to content
Snippets Groups Projects
Unverified Commit e5da788b authored by Yaman Umuroglu's avatar Yaman Umuroglu Committed by GitHub
Browse files

Merge pull request #314 from quetric/feature/apply_slr_mem_constraints

[VitisBuild] Apply SLR and memory bank constraints during Vitis Linking
parents 2d2d03cb b666fd41
No related branches found
No related tags found
No related merge requests found
......@@ -47,6 +47,8 @@ RUN rm xrtdeps.sh
# cloning dependency repos
# finn-base
RUN git clone https://github.com/Xilinx/finn-base.git /workspace/finn-base
# finn-experimental
RUN git clone https://github.com/Xilinx/finn-experimental.git /workspace/finn-experimental
# Brevitas
RUN git clone https://github.com/Xilinx/brevitas.git /workspace/brevitas
# CNPY
......
......@@ -73,6 +73,8 @@ USER $UNAME
# cloning dependency repos (as user)
# finn-base
RUN git clone https://github.com/Xilinx/finn-base.git /workspace/finn-base
# finn-experimental
RUN git clone https://github.com/Xilinx/finn-experimental.git /workspace/finn-experimental
# Brevitas
RUN git clone https://github.com/Xilinx/brevitas.git /workspace/brevitas
# CNPY
......
......@@ -13,6 +13,7 @@ gecho () {
# checkout the correct dependency repo commits
# the repos themselves are cloned in the Dockerfile
FINN_BASE_COMMIT=8908c6a3f6674c4fa790954bd41c23ee5bf053df
FINN_EXP_COMMIT=e9f97dcdb4db2f889b0f36af079a6a1792b7d4de
BREVITAS_COMMIT=aff49758ec445d77c75721c7de3091a2a1797ca8
CNPY_COMMIT=4e8810b1a8637695171ed346ce68f6984e585ef4
HLSLIB_COMMIT=2e49322d1bbc4969ca293843bda1f3f9c05456fc
......@@ -25,6 +26,11 @@ gecho "finn-base @ $FINN_BASE_COMMIT"
git -C /workspace/finn-base pull --quiet
git -C /workspace/finn-base checkout $FINN_BASE_COMMIT --quiet
pip install --user -e /workspace/finn-base
# finn-experimental
gecho "finn-experimental @ $FINN_EXP_COMMIT"
git -C /workspace/finn-experimental pull --quiet
git -C /workspace/finn-experimental checkout $FINN_EXP_COMMIT --quiet
pip install --user -e /workspace/finn-experimental
# Brevitas
gecho "brevitas @ $BREVITAS_COMMIT"
git -C /workspace/brevitas pull --quiet
......
......@@ -58,16 +58,21 @@ class Floorplan(Transformation):
# read in a user-specified floorplan or generate a default one
if self.user_floorplan is None:
floorplan = model.analysis(floorplan_params)
self.user_floorplan = model.analysis(floorplan_params)
json_dir = make_build_dir(prefix="vitis_floorplan_")
json_file = json_dir + "/floorplan.json"
model.set_metadata_prop("floorplan_json", json_file)
with open(json_file, "w") as f:
json.dump(floorplan, f, indent=4)
json.dump(self.user_floorplan, f, indent=4)
else:
model.set_metadata_prop("floorplan_json", self.user_floorplan)
model = model.transform(ApplyConfig(self.user_floorplan))
try:
default_slr = self.user_floorplan["Defaults"]["slr"][0]
except:
default_slr = -1
# perform DWC and FIFO specific adjustments
unassigned_nodes = 0
for node in model.graph.node:
......@@ -75,6 +80,7 @@ class Floorplan(Transformation):
node_slr = node_inst.get_nodeattr("slr")
if node_slr == -1:
unassigned_nodes += 1
node_inst.set_nodeattr("slr", default_slr)
if node.op_type == "StreamingDataWidthConverter_Batch":
# if we have SLR assignment already. use that
if node_slr != -1:
......@@ -100,8 +106,8 @@ class Floorplan(Transformation):
if unassigned_nodes > 0:
warnings.warn(
str(unassigned_nodes)
+ " nodes have no entry in the provided floorplan "
+ "and no default value was set"
+ " nodes have no entry in the provided floorplan,"
+ " SLR was set to " + str(default_slr)
)
# partition id generation
......
......@@ -207,8 +207,6 @@ class VitisLink(Transformation):
# has axis, aximm and axilite
# everything else is axis-only
# assume only one connection from each ip to the next
# all aximm allocated to DDR[0]
# all kernels allocated to SLR0
producer = model.find_producer(node.input[0])
consumer = model.find_consumers(node.output[0])
# define kernel instances
......@@ -225,13 +223,35 @@ class VitisLink(Transformation):
else:
instance_names[node.name] = node.name
config.append("nk=%s:1:%s" % (node.name, instance_names[node.name]))
# assign SLRs
config.append("slr=%s:SLR0" % instance_names[node.name])
# explicitly assign SLRs if the slr attribute is not -1
node_slr = sdp_node.get_nodeattr("slr")
if node_slr != -1:
config.append("slr=%s:SLR%d" % (instance_names[node.name], node_slr))
# assign memory banks
if producer is None or consumer is None:
config.append(
"sp=%s.m_axi_gmem0:DDR[%d]" % (instance_names[node.name], 0)
)
node_mem_port = sdp_node.get_nodeattr("mem_port")
if node_mem_port == "":
#configure good defaults based on board
if "u50" in self.platform or "u280" in self.platform:
# Use HBM where available (also U50 does not have DDR)
mem_type = "HBM"
mem_idx = 0
elif "u200" in self.platform:
# Use DDR controller in static region of U200
mem_type = "DDR"
mem_idx = 1
elif "u250" in self.platform:
# Use DDR controller on the node's SLR if set, otherwise 0
mem_type = "DDR"
if node_slr == -1:
mem_idx = 0
else:
mem_idx = node_slr
else:
mem_type = "DDR"
mem_idx = 1
node_mem_port = "%s[%d]" % (mem_type, mem_idx)
config.append("sp=%s.m_axi_gmem0:%s" % (instance_names[node.name], node_mem_port))
# connect streams
if producer is not None:
for i in range(len(node.input)):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment