Skip to content

Commit

Permalink
Mon Sep 9 04:10:52 PM PDT 2024
Browse files Browse the repository at this point in the history
  • Loading branch information
vagrantxiao24 committed Sep 9, 2024
1 parent 473d8a2 commit ff27e5b
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 89 deletions.
34 changes: 27 additions & 7 deletions benchmarks/tapa_flow/knn_chipknn/k2D_float_15PEs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,44 @@

ROOT_DIR := $(shell git rev-parse --show-toplevel)
KERNEL_NAME := Knn
PLATFORM := xilinx_u280_gen3x16_xdma_1_202211_1
RS_SCRIPT := $(CURDIR)/run.py
AB_CONFIG := $(CURDIR)/design/config/$(notdir $(RS_SCRIPT))/ab_config.json
IMPL_CONFIG := $(CURDIR)/design/config/$(notdir $(RS_SCRIPT))/impl_config.json
LINK_CONFIG := $(CURDIR)/design/config/$(notdir $(RS_SCRIPT))/link_config.ini
PLATFORM := xilinx_u55c_gen3x16_xdma_3_202210_1
GRP_UTIL := $(ROOT_DIR)/common/util/get_group.py
RS_SCRIPT := run.py
TEMP_DIR := $(CURDIR)/build/$(notdir $(RS_SCRIPT))
RS_TARGET := $(TEMP_DIR)/dse/candidate_0/vitis_run_hw/$(KERNEL_NAME)_$(PLATFORM).xclbin
RS_TARGET := $(TEMP_DIR)/dse/solution_0/vitis_run_hw/$(KERNEL_NAME)_$(PLATFORM).xclbin
TAPA_XO := $(CURDIR)/design/generated/knn.xo
PART := xcu280-fsvh2892-2L-e
BUILD_LOG := $(TEMP_DIR)/build.json
SUCCESS := "Build Successful"
TIMING_RPT := impl_1_hw_bb_locked_timing_summary_routed.rpt
SLACK_GETTER := $(ROOT_DIR)/common/util/get_slack.py
RSPATH := $(CURDIR)
RSXX := rapidstream
RSPYTHON := rapidstream
DEVICE_CONFIG := $(TEMP_DIR)/device.json
DEVICE_GEN := $(CURDIR)/gen_device.py

all: $(RS_TARGET)
$(RSXX) $(SLACK_GETTER) -d $(TEMP_DIR) -i $(TIMING_RPT) -o $(BUILD_LOG) -c clk_kernel_00_unbuffered_net -p 3.333
cd $(RSPATH) && $(RSPYTHON) $(SLACK_GETTER) -d $(TEMP_DIR) -i $(TIMING_RPT) -o $(BUILD_LOG) -c clk_kernel_00_unbuffered_net -p 3.333
@echo $(SUCCESS)

$(RS_TARGET):$(TAPA_XO)
$(RSXX) $(RS_SCRIPT)
$(RS_TARGET):$(TAPA_XO) $(DEVICE_CONFIG)
mkdir -p $(TEMP_DIR)
cd $(RSPATH) && $(RSXX)-tapaopt \
--work-dir $(TEMP_DIR) \
--tapa-xo-path $< \
--device-config $(DEVICE_CONFIG) \
--floorplan-config $(AB_CONFIG) \
--single-reg \
--run-impl \
--implementation-config $(IMPL_CONFIG) \
--connectivity-ini $(LINK_CONFIG)

$(DEVICE_CONFIG):$(AB_CONFIG)
mkdir -p $(TEMP_DIR)
cd $(RSPATH) && $(RSPYTHON) $(RS_SCRIPT)

show_groups:
rapidstream $(GRP_UTIL) -i $(TEMP_DIR)/passes/0-imported.json \
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"dse_range_max": 0.8,
"dse_range_min": 0.7,
"partition_strategy": "flat",
"port_pre_assignments": {
".*final_out.*": "HBM[0]",
".*in_.*": "HBM[0]",
"ap_clk": "CLK_RST",
"ap_rst_n": "CLK_RST",
"interrupt": "CLK_RST",
"s_axi_control_.*": "S_AXI_CONTROL"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"max_workers": 2,
"port_to_clock_period": {
"ap_clk": 3.33
},
"vitis_platform": "xilinx_u55c_gen3x16_xdma_3_202210_1"
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
WORK_DIR=generated
WORK_DIR=work.out

tapac \
--work-dir ${WORK_DIR} \
tapa compile \
--top Knn \
--part-num xcu280-fsvh2892-2L-e \
--part-num xcu55c-fsvh2892-2L-e \
--clock-period 3.33 \
-o ${WORK_DIR}/knn.xo \
--connectivity config/link_config.ini \
src/knn.cpp \
-f src/knn.cpp \
2>&1 | tee tapa.log
90 changes: 14 additions & 76 deletions benchmarks/tapa_flow/knn_chipknn/k2D_float_15PEs/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,88 +3,26 @@
The contributor(s) of this file has/have agreed to the RapidStream Contributor License Agreement.
"""

from rapidstream import get_u280_vitis_device_factory, RapidStreamTAPA
from pathlib import Path
from rapidstream import get_u55c_vitis_device_factory
import os

CURR_DIR = os.path.dirname(os.path.abspath(__file__))
INI_PATH = f"{CURR_DIR}/design/config/link_config.ini"
VITIS_PLATFORM = "xilinx_u280_gen3x16_xdma_1_202211_1"
XO_PATH = f"{CURR_DIR}/design/generated/knn.xo"
kernel_name = "Knn"

factory = get_u280_vitis_device_factory(VITIS_PLATFORM)
CURR_FILE = os.path.basename(__file__)
VITIS_PLATFORM = (
"xilinx_u55c_gen3x16_xdma_3_202210_1" # "xilinx_u280_gen3x16_xdma_1_202211_1"
)

# Reserve resource for the HBM Memory Sub-System.
# The HMSS is not part of the user kernel so the partition optimization process
# is unaware of its existence. We need to manually reserve resources for it.
# For 512-bit HBM channels, each HBM channel uses approximately the following resources:
# AREA_PER_HBM_CHANNEL = {
# "LUT": 5000,
# "FF": 6500,
# "BRAM": 0,
# "URAM": 0,
# "DSP": 0,
# }
factory.reduce_slot_area(1, 0, lut=5000 * 16, ff=6500 * 16)
factory.reduce_slot_area(0, 0, lut=5000 * 13, ff=6500 * 13)
factory = get_u55c_vitis_device_factory(VITIS_PLATFORM)

# For this U280 platform, the right most DSP column on the boundary between
# dynamic/static region is not usable. So we need to adjust the DSP count
# to reflect the actual available DSPs.
print("Reducing DSP of (1, 1) to make it less congested")
factory.reduce_slot_area(1, 0, lut=50000, ff=60000)
factory.reduce_slot_area(0, 0, lut=50000, ff=60000)
factory.reduce_slot_area(1, 1, dsp=100)

rs = RapidStreamTAPA(f"{CURR_DIR}/build/{os.path.basename(__file__)}")

rs.set_virtual_device(factory.generate_virtual_device())
rs.add_xo_file(XO_PATH)
rs.set_vitis_platform(VITIS_PLATFORM)
rs.set_vitis_connectivity_config(INI_PATH)

rs.set_top_module_name(kernel_name)
rs.add_clock("ap_clk", 3.33)

rs.add_flatten_targets([kernel_name])
factory.generate_virtual_device(Path(f"{CURR_DIR}/build/{CURR_FILE}/device.json"))

# Bind ports to HBM 16-31
right_slot = "SLOT_X1Y0:SLOT_X1Y0"
left_slot = "SLOT_X0Y0:SLOT_X0Y0"
# The config file binds the following argument to HBM 0 - 15
# sp=Knn_1.in_0:HBM[0]
# sp=Knn_1.in_1:HBM[1]
# sp=Knn_1.in_2:HBM[2]
# sp=Knn_1.in_3:HBM[3]
# sp=Knn_1.in_4:HBM[4]
# sp=Knn_1.in_5:HBM[5]
# sp=Knn_1.in_6:HBM[6]
# sp=Knn_1.in_7:HBM[7]
# sp=Knn_1.in_8:HBM[8]
# sp=Knn_1.in_9:HBM[9]
# sp=Knn_1.in_10:HBM[10]
# sp=Knn_1.in_11:HBM[11]
# sp=Knn_1.in_12:HBM[12]
# sp=Knn_1.in_13:HBM[13]
# sp=Knn_1.in_14:HBM[14]
# sp=Knn_1.final_out_dist:HBM[14]
# sp=Knn_1.final_out_id:HBM[14]

rs.assign_port_to_region(".*in_.*", left_slot)
rs.assign_port_to_region(".*final_out.*", left_slot)

# Constrain the remaining control ports.
# All ports must be constrained to a specific slot:
rs.assign_port_to_region("s_axi_control_.*", left_slot)
rs.assign_port_to_region("ap_clk", left_slot)
rs.assign_port_to_region("ap_rst_n", left_slot)
rs.assign_port_to_region("interrupt", left_slot)

# Xustomize the placement strategy:
rs.set_placement_strategy("EarlyBlockPlacement")

# Allow two parallel Vitis implementation
rs.run_dse(
max_workers=2,
max_dse_limit=0.85,
min_dse_limit=0.75,
partition_strategy="flat",
)
# ab_config = FloorplanConfig(
# port_pre_assignments={".*": "SLOT_X0Y0:SLOT_X0Y0"},
# )
# ab_config.save_to_file("test.json")

0 comments on commit ff27e5b

Please sign in to comment.