Skip to content

Commit

Permalink
adding combine bandwith and rx exerciser tx passthrough (#1446)
Browse files Browse the repository at this point in the history
  • Loading branch information
hagrawal-xilinx authored and GitHub Enterprise committed Oct 26, 2022
1 parent 56832a4 commit 7c313f1
Show file tree
Hide file tree
Showing 42 changed files with 3,567 additions and 0 deletions.
4 changes: 4 additions & 0 deletions x3h/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ This section contains X3 Hybrid Platform Examples.
- **Key Concepts/Keywords**
* - `ip_tables_rx <ip_tables_rx>`_
- Xilinx IPTables RX Filter offload engine.
- `combine_bw_hm_passthrough <combine_bw_hm_passthrough>`_
- Xilinx Combine Bandwidth Hostmemory and Kernel.
- `rx_exerciser_tx_passthrough <rx_exerciser_tx_passthrough>`_
- Xilinx Tx Passthrough and Rx Exerciser.
-


239 changes: 239 additions & 0 deletions x3h/combine_bw_hm_passthrough/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,239 @@
#
# Copyright 2019-2021 Xilinx, Inc.
#
# 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.
# makefile-generator v1.0.4
#

# ####################################### Help Section #####################################
.PHONY: help

help::
$(ECHO) "Makefile Usage:"
$(ECHO) " make all TARGET=<sw_emu/hw_emu/hw> DEVICE=<FPGA platform> HOST_ARCH=<x86>"
$(ECHO) " Command to generate the design for specified Target and Shell."
$(ECHO) ""
$(ECHO) " make clean "
$(ECHO) " Command to remove the generated non-hardware files."
$(ECHO) ""
$(ECHO) " make cleanall"
$(ECHO) " Command to remove all the generated files."
$(ECHO) ""
$(ECHO) " make run TARGET=<sw_emu/hw_emu/hw> DEVICE=<FPGA platform> HOST_ARCH=<x86>"
$(ECHO) " Command to run application in emulation or on board."
$(ECHO) ""
$(ECHO) " make build TARGET=<sw_emu/hw_emu/hw> DEVICE=<FPGA platform> HOST_ARCH=<x86>"
$(ECHO) " Command to build xclbin application."
$(ECHO) ""
$(ECHO) " make host HOST_ARCH=<x86>"
$(ECHO) " Command to build host application."
$(ECHO) ""

# ##################### Setting up default value of TARGET ##########################
TARGET ?= sw_emu

# ################### Setting up default value of DEVICE ##############################
DEVICE ?= xilinx_u200_gen3x16_xdma_1_202020_1

# ###################### Setting up default value of HOST_ARCH #######################
HOST_ARCH ?= x86

# #################### Checking if DEVICE in blocklist #############################
ifeq ($(findstring zc, $(DEVICE)), zc)
$(error [ERROR]: This project is not supported for $(DEVICE).)
endif
ifeq ($(findstring samsung, $(DEVICE)), samsung)
$(error [ERROR]: This project is not supported for $(DEVICE).)
endif
ifeq ($(findstring nodma, $(DEVICE)), nodma)
$(error [ERROR]: This project is not supported for $(DEVICE).)
endif
ifeq ($(findstring qep, $(DEVICE)), qep)
$(error [ERROR]: This project is not supported for $(DEVICE).)
endif

# ######################## Setting up Project Variables #################################
MK_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
XF_PROJ_ROOT ?= $(shell bash -c 'export MK_PATH=$(MK_PATH); echo $${MK_PATH%x3h/combine_bw_hm_passthrough/*}')
CUR_DIR := $(patsubst %/,%,$(dir $(MK_PATH)))
XFLIB_DIR = $(XF_PROJ_ROOT)
PWD = $(shell readlink -f .)
# ######################### Include environment variables in utils.mk ####################
include ./utils.mk
XDEVICE := $(call device2xsa, $(DEVICE))
TEMP_DIR := _x_temp.$(TARGET).$(XDEVICE)
TEMP_REPORT_DIR := $(CUR_DIR)/reports/_x.$(TARGET).$(XDEVICE)
BUILD_DIR := build_dir.$(TARGET).$(XDEVICE)
BUILD_REPORT_DIR := $(CUR_DIR)/reports/_build.$(TARGET).$(XDEVICE)
EMCONFIG_DIR := $(BUILD_DIR)
XCLBIN_DIR := $(CUR_DIR)/$(BUILD_DIR)
export XCL_BINDIR = $(XCLBIN_DIR)
include ./config.mk

# ######################### Setting up Host Variables #########################
#Include Required Host Source Files
HOST_SRCS += $(CUR_DIR)/src/host.cpp
HOST_SRCS += $(XFLIB_DIR)/common/includes/xcl2/xcl2.cpp
CXXFLAGS += -I$(CUR_DIR)/src
CXXFLAGS += -I$(XFLIB_DIR)/common/includes/xcl2

ifeq ($(TARGET),sw_emu)
CXXFLAGS += -D SW_EMU_TEST
endif

ifeq ($(TARGET),hw_emu)
CXXFLAGS += -D HW_EMU_TEST
endif

# ######################### Host compiler global settings ############################
CXXFLAGS += -I$(XILINX_XRT)/include -I$(XILINX_HLS)/include -std=c++11 -O3 -Wall -Wno-unknown-pragmas -Wno-unused-label
LDFLAGS += -L$(XILINX_XRT)/lib -lOpenCL -lpthread -lrt -Wno-unused-label -Wno-narrowing -DVERBOSE
CXXFLAGS += -fmessage-length=0
CXXFLAGS += -I$(CUR_DIR)/src/
ifneq (,$(shell echo $(XPLATFORM) | awk '/vck190/'))
CXXFLAGS += -I$(SYSROOT)/usr/include
CXXFLAGS += --sysroot=$(SYSROOT)
LDFLAGS += -L$(SYSROOT)/usr/lib
LDFLAGS += -L${SYSROOT}/opt/xilinx/xrt/lib
endif

# ################### Setting package and image directory #######################

EXE_NAME := combine_bw_hm_passthrough
EXE_FILE := $(BUILD_DIR)/$(EXE_NAME)
HOST_ARGS := $(BUILD_DIR) ./packet_gen_python/packetGen.py

# ##################### Kernel compiler global settings ##########################
VPP_FLAGS += -t $(TARGET) --platform $(XPLATFORM) --save-temps --optimize 2
VPP_FLAGS += --hls.jobs 8
VPP_LDFLAGS += --vivado.synth.jobs 8 --vivado.impl.jobs 8
VPP_FLAGS += -I$(CUR_DIR)/src/

VPP_FLAGS += -DNO_SYNTH

passthrough_VPP_FLAGS += --hls.clock 500000000:packet_passthrough_rx_v1,packet_passthrough_tx_v1

# Kernel linker flags
VPP_LDFLAGS_combine_bw_hm_passthrough_temp := --config $(CUR_DIR)/combine_bw_hm_passthrough.cfg
VPP_LDFLAGS_combine_bw_hm_passthrough += $(VPP_LDFLAGS_combine_bw_hm_passthrough_temp)
VPP_LDFLAGS_combine_bw_hm_passthrough += --clock.id=3:packet_passthrough_rx_v1_1,packet_passthrough_rx_v1_2,packet_passthrough_rx_v1_3,packet_passthrough_rx_v1_4,packet_passthrough_tx_v1_1,packet_passthrough_tx_v1_2,packet_passthrough_tx_v1_3,packet_passthrough_tx_v1_4
VPP_LDFLAGS += --advanced.param=compiler.worstNegativeSlack=-0.054
# Kernel args

# ############################ Declaring Binary Containers ##########################

BINARY_CONTAINERS += $(BUILD_DIR)/combine_bw_hm_passthrough.xclbin
BINARY_CONTAINER_combine_bw_hm_passthrough_OBJS += $(TEMP_DIR)/passthrough_rx.xo
BINARY_CONTAINER_combine_bw_hm_passthrough_OBJS += $(TEMP_DIR)/passthrough_tx.xo
BINARY_CONTAINER_combine_bw_hm_passthrough_OBJS += $(TEMP_DIR)/verify.xo
BINARY_CONTAINER_combine_bw_hm_passthrough_OBJS += $(TEMP_DIR)/bandwidth.xo
BINARY_CONTAINER_combine_bw_hm_passthrough_OBJS += $(TEMP_DIR)/hostmemory.xo

# ######################### Setting Targets of Makefile ################################

.PHONY: all clean cleanall docs emconfig
ifeq ($(HOST_ARCH), x86)
all: check_version check_vpp check_platform check_xrt $(EXE_FILE) $(BINARY_CONTAINERS) emconfig
else
all: check_version check_vpp check_platform check_sysroot $(EXE_FILE) $(BINARY_CONTAINERS) emconfig sd_card
endif

.PHONY: host
ifeq ($(HOST_ARCH), x86)
host: check_xrt $(EXE_FILE)
else
host: check_sysroot $(EXE_FILE)
endif

.PHONY: xclbin
ifeq ($(HOST_ARCH), x86)
xclbin: check_vpp check_xrt $(BINARY_CONTAINERS)
else
xclbin: check_vpp check_sysroot $(BINARY_CONTAINERS)
endif

.PHONY: build
build: xclbin

# ################ Setting Rules for Binary Containers (Building Kernels) ################
$(TEMP_DIR)/verify.xo: $(CUR_DIR)/src/verify.cpp
$(ECHO) "Compiling Kernel: verify"
mkdir -p $(TEMP_DIR)
$(VPP) -c $(verify_VPP_FLAGS) $(VPP_FLAGS) -k verify -I'$(<D)' --temp_dir $(TEMP_DIR) --report_dir $(TEMP_REPORT_DIR) -o'$@' $^
$(TEMP_DIR)/bandwidth.xo: $(CUR_DIR)/src/bandwidth.cpp
$(ECHO) "Compiling Kernel: bandwidth"
mkdir -p $(TEMP_DIR)
$(VPP) -c $(bandwidth_VPP_FLAGS) $(VPP_FLAGS) -k bandwidth -I'$(<D)' --temp_dir $(TEMP_DIR) --report_dir $(TEMP_REPORT_DIR) -o'$@' $^
$(TEMP_DIR)/hostmemory.xo: $(CUR_DIR)/src/hostmemory.cpp
$(ECHO) "Compiling Kernel: hostmemory"
mkdir -p $(TEMP_DIR)
$(VPP) -c $(hostmemory_VPP_FLAGS) $(VPP_FLAGS) -k hostmemory -I'$(<D)' --temp_dir $(TEMP_DIR) --report_dir $(TEMP_REPORT_DIR) -o'$@' $^
$(TEMP_DIR)/passthrough_rx.xo: $(CUR_DIR)/src/packet_passthrough_rx_v1.cpp
$(ECHO) "Compiling Kernel: passthrough_rx"
mkdir -p $(TEMP_DIR)
$(VPP) -c $(passthrough_VPP_FLAGS) $(VPP_FLAGS) -k packet_passthrough_rx_v1 -I'$(<D)' --temp_dir $(TEMP_DIR) --report_dir $(TEMP_REPORT_DIR) -o'$@' $^
$(TEMP_DIR)/passthrough_tx.xo: $(CUR_DIR)/src/packet_passthrough_tx_v1.cpp
$(ECHO) "Compiling Kernel: passthrough_tx"
mkdir -p $(TEMP_DIR)
$(VPP) -c $(passthrough_VPP_FLAGS) $(VPP_FLAGS) -k packet_passthrough_tx_v1 -I'$(<D)' --temp_dir $(TEMP_DIR) --report_dir $(TEMP_REPORT_DIR) -o'$@' $^


$(BUILD_DIR)/combine_bw_hm_passthrough.xclbin: $(BINARY_CONTAINER_combine_bw_hm_passthrough_OBJS)
mkdir -p $(BUILD_DIR)
$(VPP) -l $(VPP_FLAGS) --temp_dir $(TEMP_DIR) --report_dir $(BUILD_REPORT_DIR)/combine_bw_hm_passthrough $(VPP_LDFLAGS) $(VPP_LDFLAGS_combine_bw_hm_passthrough) -o '$@' $(+)
cp -rf $(BUILD_DIR)/combine_bw_hm_passthrough.xclbin ./test/verify.xclbin
cp -rf $(BUILD_DIR)/combine_bw_hm_passthrough.xclbin ./test/bandwidth.xclbin
cp -rf $(BUILD_DIR)/combine_bw_hm_passthrough.xclbin ./test/hostmemory.xclbin

# ################# Setting Rules for Host (Building Host Executable) ################
ifeq ($(HOST_ARCH), x86)
$(EXE_FILE): $(HOST_SRCS) | check_xrt
else
$(EXE_FILE): $(HOST_SRCS) | check_sysroot
endif

mkdir -p $(BUILD_DIR)
$(CXX) -o $@ $^ $(CXXFLAGS) $(LDFLAGS)

emconfig:$(EMCONFIG_DIR)/emconfig.json
$(EMCONFIG_DIR)/emconfig.json:
emconfigutil --platform $(XPLATFORM) --od $(EMCONFIG_DIR)


# ###############Setting Essential Checks And Running Rules For Vitis Flow #############
run: all
ifeq ($(TARGET),$(filter $(TARGET),sw_emu hw_emu))
$(CP) $(EMCONFIG_DIR)/emconfig.json .
XCL_EMULATION_MODE=$(TARGET) $(EXE_FILE) $(HOST_ARGS)
else
$(EXE_FILE) $(HOST_ARGS)
endif

# ################################# Cleaning Rules ##################################
cleanh:
-$(RMDIR) $(EXE_FILE) vitis_* TempConfig system_estimate.xtxt *.rpt .run/
-$(RMDIR) src/*.ll _xocc_* .Xil dltmp* xmltmp* *.log *.jou *.wcfg *.wdb sample_link.ini sample_compile.ini obj* bin* *.csv *.jpg *.jpeg *.png

cleank:
-$(RMDIR) $(BUILD_DIR)/*.xclbin _vimage *xclbin.run_summary qemu-memory-_* emulation/ _vimage/ start_simulation.sh *.xclbin
-$(RMDIR) _x_temp.*/_x.* _x_temp.*/.Xil _x_temp.*/profile_summary.* xo_* _x*
-$(RMDIR) _x_temp.*/dltmp* _x_temp.*/kernel_info.dat _x_temp.*/*.log
-$(RMDIR) _x_temp.*

cleanall: cleanh cleank
-$(RMDIR) $(BUILD_DIR) build_dir.* emconfig.json *.html $(TEMP_DIR) $(CUR_DIR)/reports *.csv *.run_summary $(CUR_DIR)/*.raw package_* run_script.sh .ipcache *.str
-$(RMDIR) $(XFLIB_DIR)/common/data/*.xe2xd* $(XFLIB_DIR)/common/data/*.orig*

-$(RMDIR) $(AIE_CONTAINERS) $(CUR_DIR)/Work $(CUR_DIR)/*.xpe $(CUR_DIR)/hw.o $(CUR_DIR)/*.xsa $(CUR_DIR)/xnwOut aiesimulator_output .AIE_SIM_CMD_LINE_OPTIONS

clean: cleanh
87 changes: 87 additions & 0 deletions x3h/combine_bw_hm_passthrough/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
Combine_Bandwidth_Hostmemory(C)
===============================

This is a simple design that verifies if the platform has basic functionalities It also tests the possible bandwidth between Kernel and Global Memory and validates direct host memory access from kernel.

DESIGN FILES
------------

Application code is located in the src directory. Accelerator binary files will be compiled to the xclbin directory. The xclbin directory is required by the Makefile and its contents will be filled during compilation. A listing of all the files in this example is shown below

::

src/bandwidth.cpp
src/host.cpp
src/hostmemory.cpp
src/verify.cpp

BUILD INSTRUCTIONS
------------------

Instruction below can be used to generate XCLBIN for Hardware (Board) flow.

::

make all TARGET=hw DEVICE=<path to xilinx_x3522p_gen4x8_hn10g_M7_1_202110_1.xpfm file>

Instruction below can be used to generate XCLBIN for Hardware Emulation Flow.

::

make run TARGET=hw_emu DEVICE=<path to xilinx_x3522p_gen4x8_hn10g_1_202220_1.xpfm emulation platform>

Note: In case of emulation flow platform file is present under /proj/xbuilds/Vitis_HW_EMU/2022.2/xilinx_x3522p_gen4x8_hn10g_1_202220_1/2022.2_component_verified

COMMAND LINE ARGUMENTS
----------------------

Once the environment has been configured, the application can be executed by

::

./combine_bw_hm.exe platform_test_path

DETAILS
-------

This example contains verify test, bandwidth test and host memory test kernels to validate FPGA.

In the verify test we have extremely simple HLS C Kernel to verify that the platform has basic functionality. It will make a call to the kernel with an empty global buffer. The kernel will then write the string of characters "Hello World" into the buffer and return. The host will copy this buffer locally and then print out the resulting buffer contents.

In the bandwidth test we try to get the maximum possible bandwidth between Kernel and Global Memory.
Extracting Memory Information and generate cfg file:

- Platforminfo -j (path to xpfm) > platform_info.json
- From the platform_info.json file we pick the memory info
- Generate the meta data related to Memory Banks(DDR/HBM/HOST) to platform_bandwidth.cfg file


Using the ``sp`` option in the platform_bandwidth.cfg file AXI-Master Port is connected to the IP.

::

sp=bandwidth_1.input:DDR[0]
sp=bandwidth_1.output:DDR[0]

hostmemory test is to validate direct host memory access from kernel using slave bridge.

The host allocates a buffer into specific host-only buffer using ``XCL_MEM_EXT_HOST_ONLY``. The ``cl_mem_ext_ptr`` object needs to be used in cases where memory assignment is done by user explicitly:

.. code:: cpp
cl_mem_ext_ptr_t input_buffer_ext;
input_buffer_ext.flags = XCL_MEM_EXT_HOST_ONLY;
input_buffer_ext.obj = nullptr;
input_buffer_ext.param = 0;
OCL_CHECK(err, input_buffer[i] = new cl::Buffer(context, CL_MEM_READ_WRITE | CL_MEM_EXT_PTR_XILINX, vector_size_bytes,
&input_buffer_ext, &err));
Using the ``sp`` option in the platform_hostmemory.cfg file, AXI-Master Port is connected to the Slave-Bridge IP:

::

sp=hostmemory.input:HOST[0]
sp=hostmemory.output:HOST[0]

For more comprehensive documentation, `click here <http://xilinx.github.io/Vitis_Accel_Examples>`__.
45 changes: 45 additions & 0 deletions x3h/combine_bw_hm_passthrough/combine_bw_hm_passthrough.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
[connectivity]
stream_connect=MMacRx0:packet_passthrough_rx_v1_1.rx_in
stream_connect=MMacRxPause0:packet_passthrough_rx_v1_1.rx_pause_in
stream_connect=packet_passthrough_rx_v1_1.rx_out:SNicRx0
stream_connect=packet_passthrough_rx_v1_1.rx_pause_out:SNicRxPause0
stream_connect=MNicTx0:packet_passthrough_tx_v1_1.tx_in
stream_connect=MNicTxPause0:packet_passthrough_tx_v1_1.tx_pause_in
stream_connect=packet_passthrough_tx_v1_1.tx_meta_res_out:SNicTxMetaRsp0
stream_connect=packet_passthrough_tx_v1_1.tx_out:SMacTx0
stream_connect=MMacTxMetaRsp0:packet_passthrough_tx_v1_1.tx_meta_res_in
stream_connect=packet_passthrough_tx_v1_1.tx_pause_out:SMacTxPause0
stream_connect=MMacRx1:packet_passthrough_rx_v1_2.rx_in
stream_connect=MMacRxPause1:packet_passthrough_rx_v1_2.rx_pause_in
stream_connect=packet_passthrough_rx_v1_2.rx_out:SNicRx1
stream_connect=packet_passthrough_rx_v1_2.rx_pause_out:SNicRxPause1
stream_connect=MNicTx1:packet_passthrough_tx_v1_2.tx_in
stream_connect=MNicTxPause1:packet_passthrough_tx_v1_2.tx_pause_in
stream_connect=packet_passthrough_tx_v1_2.tx_meta_res_out:SNicTxMetaRsp1
stream_connect=packet_passthrough_tx_v1_2.tx_out:SMacTx1
stream_connect=MMacTxMetaRsp1:packet_passthrough_tx_v1_2.tx_meta_res_in
stream_connect=packet_passthrough_tx_v1_2.tx_pause_out:SMacTxPause1
stream_connect=MMacRx2:packet_passthrough_rx_v1_3.rx_in
stream_connect=MMacRxPause2:packet_passthrough_rx_v1_3.rx_pause_in
stream_connect=packet_passthrough_rx_v1_3.rx_out:SNicRx2
stream_connect=packet_passthrough_rx_v1_3.rx_pause_out:SNicRxPause2
stream_connect=MNicTx2:packet_passthrough_tx_v1_3.tx_in
stream_connect=MNicTxPause2:packet_passthrough_tx_v1_3.tx_pause_in
stream_connect=packet_passthrough_tx_v1_3.tx_meta_res_out:SNicTxMetaRsp2
stream_connect=packet_passthrough_tx_v1_3.tx_out:SMacTx2
stream_connect=MMacTxMetaRsp2:packet_passthrough_tx_v1_3.tx_meta_res_in
stream_connect=packet_passthrough_tx_v1_3.tx_pause_out:SMacTxPause2
stream_connect=MMacRx3:packet_passthrough_rx_v1_4.rx_in
stream_connect=MMacRxPause3:packet_passthrough_rx_v1_4.rx_pause_in
stream_connect=packet_passthrough_rx_v1_4.rx_out:SNicRx3
stream_connect=packet_passthrough_rx_v1_4.rx_pause_out:SNicRxPause3
stream_connect=MNicTx3:packet_passthrough_tx_v1_4.tx_in
stream_connect=MNicTxPause3:packet_passthrough_tx_v1_4.tx_pause_in
stream_connect=packet_passthrough_tx_v1_4.tx_meta_res_out:SNicTxMetaRsp3
stream_connect=packet_passthrough_tx_v1_4.tx_out:SMacTx3
stream_connect=MMacTxMetaRsp3:packet_passthrough_tx_v1_4.tx_meta_res_in
stream_connect=packet_passthrough_tx_v1_4.tx_pause_out:SMacTxPause3
nk=packet_passthrough_rx_v1:4
nk=packet_passthrough_tx_v1:4
sp=hostmemory_1.input:HOST[0]
sp=hostmemory_1.output:HOST[0]
6 changes: 6 additions & 0 deletions x3h/combine_bw_hm_passthrough/config.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ifneq ($(USR_VPP_FLAGS), )
VPP_FLAGS += $(USR_VPP_FLAGS)
endif
ifneq ($(USR_VPP_LDFLAGS), )
VPP_LDFLAGS += $(USR_VPP_LDFLAGS)
endif
Loading

0 comments on commit 7c313f1

Please sign in to comment.