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 ...@@ -47,6 +47,8 @@ RUN rm xrtdeps.sh
# cloning dependency repos # cloning dependency repos
# finn-base # finn-base
RUN git clone https://github.com/Xilinx/finn-base.git /workspace/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 # Brevitas
RUN git clone https://github.com/Xilinx/brevitas.git /workspace/brevitas RUN git clone https://github.com/Xilinx/brevitas.git /workspace/brevitas
# CNPY # CNPY
......
...@@ -73,6 +73,8 @@ USER $UNAME ...@@ -73,6 +73,8 @@ USER $UNAME
# cloning dependency repos (as user) # cloning dependency repos (as user)
# finn-base # finn-base
RUN git clone https://github.com/Xilinx/finn-base.git /workspace/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 # Brevitas
RUN git clone https://github.com/Xilinx/brevitas.git /workspace/brevitas RUN git clone https://github.com/Xilinx/brevitas.git /workspace/brevitas
# CNPY # CNPY
......
...@@ -13,6 +13,7 @@ gecho () { ...@@ -13,6 +13,7 @@ gecho () {
# checkout the correct dependency repo commits # checkout the correct dependency repo commits
# the repos themselves are cloned in the Dockerfile # the repos themselves are cloned in the Dockerfile
FINN_BASE_COMMIT=8908c6a3f6674c4fa790954bd41c23ee5bf053df FINN_BASE_COMMIT=8908c6a3f6674c4fa790954bd41c23ee5bf053df
FINN_EXP_COMMIT=e9f97dcdb4db2f889b0f36af079a6a1792b7d4de
BREVITAS_COMMIT=aff49758ec445d77c75721c7de3091a2a1797ca8 BREVITAS_COMMIT=aff49758ec445d77c75721c7de3091a2a1797ca8
CNPY_COMMIT=4e8810b1a8637695171ed346ce68f6984e585ef4 CNPY_COMMIT=4e8810b1a8637695171ed346ce68f6984e585ef4
HLSLIB_COMMIT=2e49322d1bbc4969ca293843bda1f3f9c05456fc HLSLIB_COMMIT=2e49322d1bbc4969ca293843bda1f3f9c05456fc
...@@ -25,6 +26,11 @@ gecho "finn-base @ $FINN_BASE_COMMIT" ...@@ -25,6 +26,11 @@ gecho "finn-base @ $FINN_BASE_COMMIT"
git -C /workspace/finn-base pull --quiet git -C /workspace/finn-base pull --quiet
git -C /workspace/finn-base checkout $FINN_BASE_COMMIT --quiet git -C /workspace/finn-base checkout $FINN_BASE_COMMIT --quiet
pip install --user -e /workspace/finn-base 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 # Brevitas
gecho "brevitas @ $BREVITAS_COMMIT" gecho "brevitas @ $BREVITAS_COMMIT"
git -C /workspace/brevitas pull --quiet git -C /workspace/brevitas pull --quiet
......
...@@ -58,16 +58,21 @@ class Floorplan(Transformation): ...@@ -58,16 +58,21 @@ class Floorplan(Transformation):
# read in a user-specified floorplan or generate a default one # read in a user-specified floorplan or generate a default one
if self.user_floorplan is None: 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_dir = make_build_dir(prefix="vitis_floorplan_")
json_file = json_dir + "/floorplan.json" json_file = json_dir + "/floorplan.json"
model.set_metadata_prop("floorplan_json", json_file) model.set_metadata_prop("floorplan_json", json_file)
with open(json_file, "w") as f: with open(json_file, "w") as f:
json.dump(floorplan, f, indent=4) json.dump(self.user_floorplan, f, indent=4)
else: else:
model.set_metadata_prop("floorplan_json", self.user_floorplan) model.set_metadata_prop("floorplan_json", self.user_floorplan)
model = model.transform(ApplyConfig(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 # perform DWC and FIFO specific adjustments
unassigned_nodes = 0 unassigned_nodes = 0
for node in model.graph.node: for node in model.graph.node:
...@@ -75,6 +80,7 @@ class Floorplan(Transformation): ...@@ -75,6 +80,7 @@ class Floorplan(Transformation):
node_slr = node_inst.get_nodeattr("slr") node_slr = node_inst.get_nodeattr("slr")
if node_slr == -1: if node_slr == -1:
unassigned_nodes += 1 unassigned_nodes += 1
node_inst.set_nodeattr("slr", default_slr)
if node.op_type == "StreamingDataWidthConverter_Batch": if node.op_type == "StreamingDataWidthConverter_Batch":
# if we have SLR assignment already. use that # if we have SLR assignment already. use that
if node_slr != -1: if node_slr != -1:
...@@ -100,8 +106,8 @@ class Floorplan(Transformation): ...@@ -100,8 +106,8 @@ class Floorplan(Transformation):
if unassigned_nodes > 0: if unassigned_nodes > 0:
warnings.warn( warnings.warn(
str(unassigned_nodes) str(unassigned_nodes)
+ " nodes have no entry in the provided floorplan " + " nodes have no entry in the provided floorplan,"
+ "and no default value was set" + " SLR was set to " + str(default_slr)
) )
# partition id generation # partition id generation
......
...@@ -207,8 +207,6 @@ class VitisLink(Transformation): ...@@ -207,8 +207,6 @@ class VitisLink(Transformation):
# has axis, aximm and axilite # has axis, aximm and axilite
# everything else is axis-only # everything else is axis-only
# assume only one connection from each ip to the next # 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]) producer = model.find_producer(node.input[0])
consumer = model.find_consumers(node.output[0]) consumer = model.find_consumers(node.output[0])
# define kernel instances # define kernel instances
...@@ -225,13 +223,35 @@ class VitisLink(Transformation): ...@@ -225,13 +223,35 @@ class VitisLink(Transformation):
else: else:
instance_names[node.name] = node.name instance_names[node.name] = node.name
config.append("nk=%s:1:%s" % (node.name, instance_names[node.name])) config.append("nk=%s:1:%s" % (node.name, instance_names[node.name]))
# assign SLRs # explicitly assign SLRs if the slr attribute is not -1
config.append("slr=%s:SLR0" % instance_names[node.name]) 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 # assign memory banks
if producer is None or consumer is None: if producer is None or consumer is None:
config.append( node_mem_port = sdp_node.get_nodeattr("mem_port")
"sp=%s.m_axi_gmem0:DDR[%d]" % (instance_names[node.name], 0) 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 # connect streams
if producer is not None: if producer is not None:
for i in range(len(node.input)): 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