Skip to content

Commit

Permalink
Squashed 'security/' changes from 3039eed..6b60f47
Browse files Browse the repository at this point in the history
6b60f47 update utils.mk (#68)
ee61e2e remove modular test which are not for customer (#67)
8cb2e7a Fix next cr 0511 (#66)
31e490b Fix next cr-1086848 (#65)
7571eba Fix cr 1098358 (#64)
5f013b6 Fix ripmd golden (#63)
3bf0e84 fix dsp chain issue (#62)
33ad0aa opt ecdsa secp256k1 (#61)
dc3cc06 fix typo in pragma
3e65107 Minor Changes (#50)
a0954a3 minor change (#59)
ec1de22 Next bring back api (#58)
b3fbbe3 Update Jenkinsfile
a9599aa change all the makefiles in L1 to fix aws support (#57)
1fdae3a Next benchmark (#55)
dbdc5fa Next benchmark (#53)
d5f7f30 Next benchmark (#52)
3f53c9f add aws/versal support for L1 (#51)
f93c89d update tool version for vck_190 (#49)
1845b19 support vcd_190 (#48)
47a57b4 AES refactor (#46)
0114cb6 Add Sizeless version CRC32 and Adler32 (#44)
2ed8174 2021.1 ripemd160 (#43)
a0562f2 change 2020.2_stable_latest to 2021.1_stable_latest

git-subtree-dir: security
git-subtree-split: 6b60f47b03ade447f1dea46b47d8abebe0fbe553
  • Loading branch information
sdausr committed May 26, 2021
1 parent ebf9e92 commit 9ceed7b
Show file tree
Hide file tree
Showing 378 changed files with 7,044 additions and 3,826 deletions.
3 changes: 2 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@Library('pipeline-library')_
VitisLibPipeline (branch: 'next', libname: 'xf_security', TARGETS: 'hls_csim:hls_csynth:hls_cosim:vitis_sw_emu:vitis_hw_emu:vitis_hw_build',
email: 'tuol@xilinx.com', devtest: 'RunDeploy.sh', TOOLVERSION: '2020.2_stable_latest')
upstream_dependencies: 'xf_utils_hw,next,../utils',
email: 'tuol@xilinx.com', devtest: 'RunDeploy.sh', TOOLVERSION: '2021.1_stable_latest')
113 changes: 96 additions & 17 deletions L1/benchmarks/adler32/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright 2019-2020 Xilinx, Inc.
# 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.
Expand All @@ -12,7 +12,7 @@
# 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.2
# makefile-generator v1.0.3
#

# ####################################### Help Section #####################################
Expand All @@ -22,30 +22,31 @@ help::
$(ECHO) "Makefile Usage:"
$(ECHO) " make all TARGET=<sw_emu/hw_emu/hw> DEVICE=<FPGA platform> HOST_ARCH=<aarch32/aarch64/x86>"
$(ECHO) " Command to generate the design for specified Target and Shell."
$(ECHO) " By default, HOST_ARCH=x86. HOST_ARCH is required for SoC shells"
$(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 TARGET=<sw_emu/hw_emu/hw> DEVICE=<FPGA platform> HOST_ARCH=<aarch32/aarch64/x86>"
$(ECHO) " By default, HOST_ARCH=x86. HOST_ARCH is required for SoC shells"
$(ECHO) " make sd_card TARGET=<sw_emu/hw_emu/hw> DEVICE=<FPGA platform> HOST_ARCH=<aarch32/aarch64>"
$(ECHO) " Command to prepare sd_card files."
$(ECHO) " This target is only used in embedded device."
$(ECHO) ""
$(ECHO) " make run TARGET=<sw_emu/hw_emu/hw> DEVICE=<FPGA platform> HOST_ARCH=<aarch32/aarch64/x86>"
$(ECHO) " Command to run application in emulation."
$(ECHO) " By default, HOST_ARCH=x86. HOST_ARCH required for SoC shells"
$(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=<aarch32/aarch64/x86>"
$(ECHO) " Command to build xclbin application."
$(ECHO) " By default, HOST_ARCH=x86. HOST_ARCH is required for SoC shells"
$(ECHO) ""
$(ECHO) " make host HOST_ARCH=<aarch32/aarch64/x86>"
$(ECHO) " Command to build host application."
$(ECHO) " By default, HOST_ARCH=x86. HOST_ARCH is required for SoC shells"
$(ECHO) " By default, HOST_ARCH=x86. HOST_ARCH is required for embedded devices"
$(ECHO) ""
$(ECHO) " NOTE: For SoC shells, ENV variable SYSROOT needs to be set."
$(ECHO) " NOTE: For embedded devices, e.g. zcu102/zcu104/vck190, env variable SYSROOT, EDGE_COMMON_SW and PERL need to be set first, and HOST_ARCH is either aarch32 or aarch64. For example,"
$(ECHO) " export SYSROOT=< path-to-platform-sysroot >"
$(ECHO) " export EDGE_COMMON_SW=< path-to-rootfs-and-Image-files >"
$(ECHO) " export PERL=<path-to-perl-installation-location >"
$(ECHO) ""

# ##################### Setting up default value of TARGET ##########################
Expand All @@ -64,8 +65,12 @@ endif

# #################### Checking if DEVICE in whitelist ############################
ifneq ($(findstring u50, $(DEVICE)), u50)
ifneq ($(findstring aws-vu9p-f1, $(DEVICE)), aws-vu9p-f1)
ifneq ($(findstring vck190, $(DEVICE)), vck190)
$(warning [WARNING]: This project has not been tested for $(DEVICE). It may or may not work.)
endif
endif
endif

# ######################## Setting up Project Variables #################################
MK_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
Expand All @@ -84,6 +89,14 @@ EMCONFIG_DIR := $(BUILD_DIR)
XCLBIN_DIR := $(CUR_DIR)/$(BUILD_DIR)
export XCL_BINDIR = $(XCLBIN_DIR)

# ####################### Setting environment variables for embedded #####################
ifneq ($(HOST_ARCH), x86)
SYSROOT := $(SYSROOT)
PERL ?= perl
SDCARD := sd_card
EMU_DIR := $(SDCARD)/data/emulation
endif

# ######################### Setting up Host Variables #########################
#Include Required Host Source Files
HOST_SRCS += $(XFLIB_DIR)/L1/benchmarks/adler32/host/main.cpp
Expand All @@ -92,6 +105,7 @@ CXXFLAGS += -I$(XFLIB_DIR)/L1/include
CXXFLAGS += -I$(XFLIB_DIR)/L1/benchmarks/adler32/host
CXXFLAGS += -I$(XFLIB_DIR)/L1/benchmarks/adler32/kernel
CXXFLAGS += -I$(XFLIB_DIR)/ext/xcl2
CXXFLAGS += -I$(XFLIB_DIR)/../utils/L1/include
CXXFLAGS += -I$(XFLIB_DIR)/ext/xcl2

LDFLAGS += -lssl -lcrypto
Expand All @@ -106,31 +120,44 @@ CXXFLAGS += -D HW_EMU_TEST
endif

# ######################### Host compiler global settings ############################
ifneq ($(HOST_ARCH), x86)
CXXFLAGS += --sysroot=$(SYSROOT)
CXXFLAGS += -I$(SYSROOT)/usr/include/xrt -I$(XILINX_VIVADO)/include -std=c++14 -O3 -Wall -Wno-unknown-pragmas -Wno-unused-label
else
CXXFLAGS += -I$(XILINX_XRT)/include -I$(XILINX_VIVADO)/include -std=c++11 -O3 -Wall -Wno-unknown-pragmas -Wno-unused-label
endif
LDFLAGS += -L$(XILINX_XRT)/lib -lOpenCL -lpthread -lrt -Wno-unused-label -Wno-narrowing -DVERBOSE
CXXFLAGS += -fmessage-length=0 -O3
CXXFLAGS += -I$(CUR_DIR)/src/

ifeq ($(HOST_ARCH), x86)
LDFLAGS += -L$(XILINX_VIVADO)/lnx64/tools/fpo_v7_0 -Wl,--as-needed -lgmp -lmpfr -lIp_floating_point_v7_0_bitacc_cmodel
endif
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 #######################
PKG_OUT_DIR := package_$(TARGET)
EMBEDDED_PACKAGE_OUT = package_$(TARGET)
ifneq (,$(findstring zc706, $(XDEVICE)))
K_IMAGE := $(SYSROOT)/../../uImage
K_IMAGE := $(EDGE_COMMON_SW)/uImage
else
K_IMAGE := $(SYSROOT)/../../Image
K_IMAGE := $(EDGE_COMMON_SW)/Image
endif

EXE_NAME := host.exe
EXE_FILE := $(BUILD_DIR)/$(EXE_NAME)
HOST_ARGS := -xclbin $(BUILD_DIR)/Adler32Kernel.xclbin -data $(CUR_DIR)/data/test.dat -num 16

PKG_HOST_ARGS = $(foreach args,$(HOST_ARGS),$(subst $(dir $(patsubst %/,%,$(args))),,$(args)))

# ##################### Kernel compiler global settings ##########################
VPP_FLAGS += -t $(TARGET) --platform $(XPLATFORM) --save-temps --optimize 2
VPP_FLAGS += --jobs 8
VPP_FLAGS += --hls.jobs 8
VPP_LDFLAGS += --vivado.synth.jobs 8 --vivado.impl.jobs 8
ifneq (,$(shell echo $(XPLATFORM) | awk '/u50/'))
VPP_FLAGS += --config $(CUR_DIR)/conn_u50.cfg
endif
Expand All @@ -141,7 +168,11 @@ VPP_FLAGS += -I$(XFLIB_DIR)/L1/include
VPP_FLAGS += -I$(XFLIB_DIR)/L1/benchmarks/adler32/kernel

Adler32Kernel_VPP_FLAGS += --hls.clock 300000000:Adler32Kernel
ifneq ($(HOST_ARCH), x86)
VPP_LDFLAGS_Adler32Kernel += --clock.defaultFreqHz 300000000
else
VPP_LDFLAGS_Adler32Kernel += --kernel_frequency 300
endif


# ############################ Declaring Binary Containers ##########################
Expand All @@ -158,7 +189,8 @@ BINARY_CONTAINER_Adler32Kernel_OBJS += $(TEMP_DIR)/Adler32Kernel.xo
# ######################### Setting Targets of Makefile ################################

.PHONY: all clean cleanall docs emconfig
all: check_vpp check_platform $(EXE_FILE) $(BINARY_CONTAINERS) emconfig
all: check_vpp check_platform $(EXE_FILE) $(BINARY_CONTAINERS) emconfig sd_card


.PHONY: host
host: check_xrt check_sysroot $(EXE_FILE)
Expand All @@ -178,7 +210,7 @@ $(TEMP_DIR)/Adler32Kernel.xo: $(XFLIB_DIR)/L1/benchmarks/adler32/kernel/adler32_

$(BINARY_CONTAINERS): $(BINARY_CONTAINER_Adler32Kernel_OBJS)
mkdir -p $(BUILD_DIR)
$(VPP) -l $(VPP_FLAGS) --temp_dir $(BUILD_DIR) --report_dir $(BUILD_REPORT_DIR)/Adler32Kernel $(VPP_LDFLAGS) $(VPP_LDFLAGS_Adler32Kernel) -o '$@' $(+)
$(VPP) -l $(VPP_FLAGS) --temp_dir $(TEMP_DIR) --report_dir $(BUILD_REPORT_DIR)/Adler32Kernel $(VPP_LDFLAGS) $(VPP_LDFLAGS_Adler32Kernel) -o '$@' $(+)


# ################# Setting Rules for Host (Building Host Executable) ################
Expand All @@ -192,12 +224,59 @@ $(EMCONFIG_DIR)/emconfig.json:


# ###############Setting Essential Checks And Running Rules For Vitis Flow #############
# Setting default value for vitis flow
RESULT_VAL ?=
RUN_LEVEL ?= 7
run: all
ifeq ($(TARGET),$(filter $(TARGET),sw_emu hw_emu))
ifeq ($(HOST_ARCH), x86)
$(CP) $(EMCONFIG_DIR)/emconfig.json .
XCL_EMULATION_MODE=$(TARGET) $(EXE_FILE) $(HOST_ARGS)
else
ifeq ($(findstring vck190, $(DEVICE)), vck190)
export XCL_EMULATION_MODE=$(TARGET)
$(PERL) $(XF_PROJ_ROOT)/ext/make_utility/embedded_run_emulation.pl "./$(EMBEDDED_PACKAGE_OUT)/launch_$(TARGET).sh -noc-memory-config qemu-memory-_ddr@0x00000000 -no-reboot" "./run_script.sh" "$(RESULT_STRING)" "$(RUN_LEVEL)" | tee embedded_run.log
endif
endif
else
ifeq ($(HOST_ARCH), x86)
$(EXE_FILE) $(HOST_ARGS)
else
$(ECHO) "Please copy the content of sd_card folder and data to an SD Card and run on the board"
endif
endif

# ######################### Preparing sdcard folder ##############################
EMBEDDED_EXEC_SCRIPT = run_script.sh
PACKAGE_FILES += $(EMBEDDED_EXEC_SCRIPT)
PACKAGE_FILES += $(EXE_FILE)
PACKAGE_FILES += emconfig.json
PACKAGE_FILES += $(DATA_FILE)
SD_FILES_WITH_PREFIX = $(foreach sd_file,$(PACKAGE_FILES),--package.sd_file $(sd_file))
SD_DIRS_WITH_PREFIX = $(foreach sd_dir,$(DATA_DIR),--package.sd_dir $(sd_dir))
sd_card: $(EXE_FILE) $(BINARY_CONTAINERS) emconfig
ifneq ($(HOST_ARCH), x86)
@echo "Generating sd_card folder...."
mkdir -p $(EMBEDDED_PACKAGE_OUT)
rm -rf run_script.sh
@echo 'export LD_LIBRARY_PATH=/mnt:/tmp:$$LD_LIBRARY_PATH' >> run_script.sh
ifeq ($(TARGET), $(filter $(TARGET),sw_emu hw_emu))
@echo 'export XCL_EMULATION_MODE=$(TARGET)' >> run_script.sh
endif
@echo 'export XILINX_VITIS=/mnt' >> run_script.sh
@echo 'export XILINX_XRT=/usr' >> run_script.sh
@echo 'cp platform_desc.txt /etc/xocl.txt' >> run_script.sh
emconfigutil --platform $(DEVICE) --nd 1;
@echo './$(EXE_NAME) $(PKG_HOST_ARGS)' >> run_script.sh
@echo 'return_code=$$?' >> run_script.sh
@echo 'if [ $$return_code -ne 0 ]; then' >> run_script.sh
@echo ' echo "ERROR: Embedded host run failed, RC=$$return_code"' >> run_script.sh
@echo 'fi' >> run_script.sh
@echo 'echo "INFO: Embedded host run completed."' >> run_script.sh
@echo 'exit $$return_code' >> run_script.sh
chmod a+rx run_script.sh
v++ -t $(TARGET) --platform $(DEVICE) -o $(BINARY_CONTAINERS_PKG) -p $(BINARY_CONTAINERS) --package.out_dir $(EMBEDDED_PACKAGE_OUT) --package.rootfs $(EDGE_COMMON_SW)/rootfs.ext4 --package.sd_file $(K_IMAGE) $(SD_FILES_WITH_PREFIX) $(SD_DIRS_WITH_PREFIX)
@echo "### ***** sd_card generation done! ***** ###"
endif

# ################################# Cleaning Rules ##################################
Expand All @@ -212,7 +291,7 @@ cleank:
-$(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) $(BUILD_DIR) sd_card* 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
Expand Down
71 changes: 71 additions & 0 deletions L1/benchmarks/adler32/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
Adler32
========

To profile performance of adler32, we prepare a datapack of 268,435,456 byte messages as kernel input.
Base on U50, We have 1 kernel, each kernel has 1 PU.
Kernel utilization and throughput is shown in table below.

Executable Usage
================

* **Work Directory(Step 1)**

The steps for library download and environment setup can be found in :ref:`l1_vitis_security`. For getting the design,

```
cd L1/benchmarks/adler32
```

* **Build kernel(Step 2)**

Run the following make command to build your XCLBIN and host binary targeting a specific device. Please be noticed that this process will take a long time, maybe couple of hours.

```
source /opt/xilinx/Vitis/2021.1/settings64.sh
source /opt/xilinx/xrt/setenv.sh
export DEVICE=u50_gen3x16
export TARGET=hw
make run
```

* **Run kernel(Step 3)**

To get the benchmark results, please run the following command.

```
./BUILD_DIR/host.exe -xclbin ./BUILD_DIR/Adler32Kernel.xclbin -data PROJECT/data/test.dat -num 16
```

Input Arguments:

```
Usage: host.exe -[-xclbin]
-xclbin binary;
```

* **Example output(Step 4)**

```
kernel has been created
kernel start------
kernel end------
Execution time 724.018ms
Write DDR Execution time 1.19501 ms
Kernel Execution time 721.203 ms
Read DDR Execution time 0.07055 ms
Total Execution time 723.504 ms
```

Profiling
=========

The Adler32 is validated on Xilinx Alveo U50 board.
Its resource, frequency and throughput is shown as below.

+-----------+------------+------------+----------+--------+--------+-------------+
| Frequency | LUT | REG | BRAM | URAM | DSP | Throughput |
+-----------+------------+------------+----------+--------+--------+-------------+
| 262 MHz | 6,348 | 12,232 | 16 | 0 | 0 | 4.1 GB/s |
+-----------+------------+------------+----------+--------+--------+-------------+


23 changes: 21 additions & 2 deletions L1/benchmarks/adler32/description.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"description": "",
"flow": "vitis",
"platform_whitelist": [
"u50"
"u50",
"aws-vu9p-f1",
"vck190"
],
"platform_blacklist": [
"zc"
Expand All @@ -18,6 +20,22 @@
]
}
}
},
"vck190": {
"host": {
"linker": {
"librarypaths": [
"$(SYSROOT)/usr/lib",
"${SYSROOT}/opt/xilinx/xrt/lib"
]
},
"compiler": {
"includepaths": [
"$(SYSROOT)/usr/include"
],
"options": "--sysroot=$(SYSROOT)"
}
}
}
},
"launch": [
Expand All @@ -37,7 +55,8 @@
"LIB_DIR/L1/include",
"LIB_DIR/L1/benchmarks/adler32/host",
"LIB_DIR/L1/benchmarks/adler32/kernel",
"LIB_DIR/ext/xcl2"
"LIB_DIR/ext/xcl2",
"LIB_DIR/../utils/L1/include"
],
"options": "-O3 "
}
Expand Down
Loading

0 comments on commit 9ceed7b

Please sign in to comment.