Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
2b4210b
Optimized version or URAM usage, still in development.
Mar 30, 2018
53d81f4
Create README.md
kostarnov Apr 2, 2018
a05f34f
No mismatches in URAM version vs BRAM version using fractional remap …
Apr 11, 2018
aba057b
Merge pull request #1 from Xilinx/master
alekrop Apr 11, 2018
ab89eb3
Merge branch 'master' into remap-dev
Apr 11, 2018
9832de3
Merge from Xilinx upstream.
Apr 11, 2018
3692da3
default URAM usage parameter is set to false.
Apr 11, 2018
2ada030
Fix: extra definition is removed.
Apr 11, 2018
afbab81
xf_remap opimization: workaround added to overcome mismatch of NN fil…
Apr 13, 2018
39dfc15
xf_remap opimizaion :simpler workaround to overcome incorrect RTL syn…
Apr 16, 2018
d1a04fd
.
sergensv Apr 16, 2018
0047e7e
Add Gaussian filter example
sergensv Apr 16, 2018
2805ed6
xf_warp URAM optimization: Initial commit.
Apr 17, 2018
05516d0
xf_warp URAM optimization: NN interpolation is done, Bilinear is star…
Apr 18, 2018
102ce40
Add resizing of filtered image (host sources interface didn't change…
Apr 19, 2018
666bb9e
Add Visual Studio project and .gitignore
Apr 19, 2018
30df81b
xf_warp URAM optimization: Bilinear filer is done.
Apr 19, 2018
dc458a2
Add resizing image after GaussianBlur filter and synchronize host app…
Apr 20, 2018
63e8ab1
Add script examples to generate AFI and launch test
Apr 20, 2018
825babc
Correct misprint
Apr 20, 2018
f3621a0
Updated stereoBM testbench file
bgouthamb Apr 23, 2018
d7a1d88
Merge remote-tracking branch 'upstream/master'
Apr 25, 2018
92651c5
Merge branch 'master' into xf_warpTransform-dev
Apr 25, 2018
800c682
xf_npyr_opt_flow URAM opimization: initial commit, computeSum() for b…
Apr 27, 2018
8cf8408
xf_npyr_opt_flow URAM optimization: lbWrapper() for both rates is done.
May 1, 2018
9d096b8
xf_npyr_opt_flow URAM optimization: pipeline pragma is changed to UNR…
May 3, 2018
0c30f43
Apply found work around to xf_gaussian_filter.hpp and rework AWS exam…
May 3, 2018
65d9c40
Stereopipeline initial version
May 3, 2018
092ddf1
Update Gaussian Filter VS project
May 3, 2018
563e66d
Update auxiliary scripts
May 3, 2018
52a2c35
Fix error in Gaussian filter test bench: scan differences between Ope…
May 3, 2018
95774e2
xf_pyr_dense_optical_flow URAM optimization: USE_URAM define added to…
May 4, 2018
a409423
xf_pyr_dense_optical_flow() URAM optimization: pyrDown() part of desi…
May 4, 2018
0d80ec0
Add stereo pipeline project
May 6, 2018
eaec922
Comment out problem definition (duplicate define from other header an…
May 6, 2018
0e417fb
Format code of xfopencv library for convenience
May 6, 2018
0052c37
Exclude memcpy() calls from xFInitUndistortRectifyMapInverseKernel() …
May 6, 2018
3285596
Format xf_stereo_pipeline_config.h and comment out function declaration
May 6, 2018
c2c5083
Success compilation of xf::InitUndistortRectifyMapInverse() calling
May 6, 2018
66eeb6c
Success compilation of xf::InitUndistortRectifyMapInverse() + remap()…
May 6, 2018
f6a1be8
Fix error: static modifier removed because it prevent using few insta…
May 6, 2018
b6ce8a6
Successful compilation of preliminary processing of both images.
May 6, 2018
0def3f1
xf_pyr_dense_optical_flow() URAM optimization:scale_up() function is …
May 9, 2018
676c92f
xf_remap() fix: added just for intiialization "staic" is removed acco…
May 6, 2018
5f6c080
Merge branch 'master' into xf_pyr_optical_flow-dev
May 9, 2018
c42e888
Rearrange kernel parameters - first all input buffers, next output. S…
May 10, 2018
c1bb34e
Change defines to match test images size
May 11, 2018
bf5e97f
Add emulation flow, extract common part of examples makefiles into si…
May 14, 2018
c019ab8
Update stereopipeline, remode default values from template due to com…
May 14, 2018
668b7f0
Move "include" of common_makefile to right place
May 14, 2018
00ef52d
Merge remote-tracking branch 'origin/xf_pyr_optical_flow-dev'
May 14, 2018
fca91ef
update gitignore
May 14, 2018
c480c07
Merge branch 'AWS_demo-dev'
May 14, 2018
4075d6f
Move run scripts to appropriate folder
May 15, 2018
bae522f
Minor improvements
May 15, 2018
5b02b98
Seems found "solution" how to pass bm_state as kernel parameter - pas…
May 16, 2018
8dfb813
Exclude using non default constructor due to issues exist in HW emula…
May 16, 2018
43493a6
Restore original xf_params.h
May 16, 2018
f3f9672
Fix minor issues
May 16, 2018
3b58c22
Create README.md
May 18, 2018
96ae1fe
Update format
May 18, 2018
7025ff9
Update README.md
May 18, 2018
6a16007
Update format
May 18, 2018
fc15fce
Update format
May 18, 2018
22c9f76
Add description + cosmetic changes in source code and makefiles
May 23, 2018
5a0e445
Fix tables layout issues on GitHub
May 23, 2018
53342eb
Fix layout issues on GitHub
May 23, 2018
d919571
Add description for stereo pipeline, remove redundant code
May 26, 2018
e9c1d23
xf_pyr_dense_optical_flow URAM optimization: findGradients() is rough…
May 29, 2018
254a58e
xf_pyr_dense_optical_flow URAM optimization: comment added with sugge…
May 30, 2018
183689a
xf_remap() function: non-functional extra changes (spaces, tabs, cosm…
May 30, 2018
5057dd4
xf_pyr_dense_optical_flow URAM optimization: extra default values for…
May 30, 2018
00c5a53
xf_pyr_dense_optical_flow URAM optimization: find_G_and_b_matrix() fu…
May 30, 2018
d32f276
xf_pyr_dense_optical_flow URAM optimization: auMedianBlur() function …
May 30, 2018
3f38733
xf_pyr_dense_optical_flow URAM optimization: reduction of URAMs used …
May 30, 2018
64b62aa
xf_pyr_dense_optical_flow URAM optimization: more loops restructuring…
Jun 4, 2018
a21fced
xf_pyr_dense_optical_flow URAM optimization: adding comment about wor…
Jun 4, 2018
d06a5e8
xf_pyr_dense_optical_flow URAM optimization: restructuring loop insid…
Jun 4, 2018
99badde
xf_pyr_dense_optical_flow URAM optimization: improving latency for xF…
Jun 5, 2018
f970f96
Merge branch 'master' into xf_pyr_optical_flow-dev
Jun 5, 2018
78e871e
xf_remap update: adding flexible partitioning for URAM buffer to have…
Jun 25, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/**/ide/**/*.*sdf
/**/ide/**/*.tss
/**/ide/**/*.suo
/**/ide/**/Debug
/**/ide/**/Release
Binary file added aws_demo/Code_Structure.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
130 changes: 130 additions & 0 deletions aws_demo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
AWS Demo
======================
The AWS Demo is set of examples demonstrate how use xfOpenCV library in kernels build for Amazone F1 instance. Each example could be build to run on FPGA (only F1 instance with "*FPGA Developer AMI*" could be used) or emulated for debug purpose in HW or SW emulation mode (any instance with "*FPGA Developer AMI*"could be used).

## EXAMPLES FILE HIERARCHY
Each example is organized into the following folders


| Folder Name | Contents |
| :----- | :------
| <example name> | **Root folder of example.** Folder contains input image(s), headers with kernel configuration and declaration, makefile, source code of host application, kernel wrapper and kernel.|
|      hw |**Folder for FPGA flow.** |
| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;afi |**Folder for AWS FPGA binary file generation.** After successful build folder will contain the kernel container binary (`<kernel name>.xclbin`) to generate AWS FPGA binary file for Amazon F1 instance and register AFI. During generation all intermediate files will be stored there. |
| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;run |**Run folder of the example.** After successful build folder will contain host application executable. All result, intermediate and reference images generated by kernel and application will be stored there. Kernel container |
| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hw_emu |**Folder for HW emulation flow.** |
| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;run |**Emulation folder of the example.** After successful build folder will contain host application executable and kernel container (`<kernel name>.xclbin`) for HW emulation. Emulation logs and data, result, intermediate and reference images generated by kernel emulation and application will be stored there. |
| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sw_emu |**Folder for HW emulation flow.** |
| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;run |**Emulation folder of the example.** After successful build folder will contain host application executable and kernel container (`<kernel name>.xclbin`) for HW emulation. Emulation logs and data, result, intermediate and reference images generated by kernel emulation and application will be stored there. |


## HOW TO BUILD EXAMPLE
Place xfOpenCV library (`xfopencv` folder) together with Amazon's FPGA framework
```
project_data
├─ aws-fpga
└─ xfopencv
```

If you would like to have other folder structure you need tune [`aws_demo/common_makefile`](common_makefile). For more information please see [make_description.md](make_description.md)

### Prepare environment
Run following code to prepare environment for build.
```
cd $AWS_FPGA_REPO_DIR
source sdaccel_setup.sh
source $XILINX_SDX/settings64.sh
```

### Build example for SW/HW emulation

1. Go to root folder of example.
2. Build whole example (`all`), kernel part only (`krnl`) or host application only (`host`) for HW (`hw_emu`) or SW (`sw_emu`) emulation with the following command:
```
make TARGET=hw_emu|sw_emu all|host|krnl
```

To erase all build data including host application executable and kernel binary files use following command:
```
make TARGET=hw_emu|sw_emu clean
```

### Build example for FPGA

To build examples for FPGA F1 instance you will need access to [**AWS CLI**](https://aws.amazon.com/cli/) and [**S3**](https://aws.amazon.com/s3/). Please refer to **_[What Is the AWS Command Line Interface?](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-welcome.html)_** and **_[Getting Started with Amazon S3](https://aws.amazon.com/s3/getting-started/)_**.
1. Go to root folder of example.
2. Build whole example (`all`), kernel part only (`krnl`) or host application only (`host`) for HW (`hw_emu`) or SW (`sw_emu`) emulation with the following command:
```
make TARGET=hw all|host|krnl
```
3. After kernel build complete go to ***afi*** folder to generate AWS FPGA binary file for Amazon F1 instance and register AFI
4. Setup **[AWS CLI](https://aws.amazon.com/cli/)** (see **_[What Is the AWS Command Line Interface?](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-welcome.html)_**)
5. Run script placed in ***afi*** folder to generate AWS FPGA binary file for Amazon F1 instance and register AFI
```
source ./gen_afi.sh
```
Script will create S3 bucket for FPGA image and launch image generation in background process. When script finish the FPGA image will not be ready.
6. Wait until FPGA image will be generated. To check generation completion periodically run following command:
```
aws ec2 describe-fpga-images --fpga-image-id <afi id>
```
You can get `<afi id>` from script message or from file **`*_afi_id.txt`**. During generation you will see following message:
```
...
"State": {
"Code": "pending"
},
...
```
The FPGA image is ready if command print `available`:
```
...
"State": {
"Code": "available"
},
...
```

7. Copy `<kernel name>.awsxclbin` into ***hw/run*** folder

To erase all build data including host application executable but except content of ***afi*** folder use following command:
```
make TARGET=hw clean
```

## HOW TO RUN EXAMPLE

### Prepare environment
If you relaunch Amazon instance after build you need to repeat environment preparation step:
```
cd $AWS_FPGA_REPO_DIR
source sdaccel_setup.sh
source $XILINX_SDX/settings64.sh
```
### Run SW/HW emulation of example

1. Go to emulation folder of example (**`hw_emu/run`** or **`sw_emu/run`**).
2. Set desired emulation option in `sdaccel.ini` file
3. Launch emulation with the following command:
```
source run.sh
```

### Run example on FPGA

1. Go to run folder of example (**`hw/run`**).
2. Launch shell
```
sudo sh
```
3. Launch application with the following command:
```
source run.sh
```

## REVISION HISTORY

Date | Readme Version | Release Notes
-------- |----------------|-------------------------
May 2018 | 1.0 | Initial version.

196 changes: 196 additions & 0 deletions aws_demo/common_makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
########################################
# #
# Tools section #
# #
########################################

XILINX_SDX ?= /opt/Xilinx/SDx/2017.1.op
XILINX_HLS ?= $(XILINX_SDX)/Vivado_HLS


SDX_CXX ?= $(XILINX_SDX)/bin/xcpp
XOCC ?= $(XILINX_SDX)/bin/xocc

RM = rm -f
RMDIR = rm -rf

ifeq "$(AWS_PLATFORM)" "$(AWS_PLATFORM_1DDR)"
XILINX_SDX_RUNTIME=/opt/Xilinx/2017.1.rte.1ddr/runtime/lib/x86_64
else ifeq "$(AWS_PLATFORM)" "$(AWS_PLATFORM_4DDR)"
XILINX_SDX_RUNTIME=/opt/Xilinx/2017.1.rte.4ddr/runtime/lib/x86_64
else ifeq "$(AWS_PLATFORM)" "$(AWS_PLATFORM_4DDR_DEBUG)"
XILINX_SDX_RUNTIME=/opt/Xilinx/2017.1.rte.4ddr_debug/runtime/lib/x86_64
endif

XFOPENCV ?= /home/centos/src/project_data/xfopencv

TARGET ?= hw_emu

########################################
# #
# Host section #
# #
########################################

HOST_SDx_SRC ?= xcl2

SDx_LIB_DIR ?= $(SDACCEL_DIR)/examples/xilinx/libs/xcl2

CXXFLAGS += -DSDX_PLATFORM=$(AWS_PLATFORM) -D__USE_XOPEN2K8
CXXFLAGS += -I$(XILINX_SDX)/runtime/include/1_2/
CXXFLAGS += -I$(XILINX_SDX)/include/
CXXFLAGS += -I$(XFOPENCV)/include/
CXXFLAGS += -I$(SDx_LIB_DIR)/
CXXFLAGS += -I$(XILINX_HLS)/include
CXXFLAGS += -O2 -Wall -c -fmessage-length=0 -std=c++14

#--- Specify OpenCV libraries ---#

LDFLAGS += -L$(XILINX_SDX)/lnx64/tools/opencv
LDFLAGS += -lopencv_core
LDFLAGS += -lopencv_imgproc
LDFLAGS += -lopencv_highgui

#--- Specify common libraries ---#

LDFLAGS += -L$(XILINX_SDX)/lib/lnx64.o
LDFLAGS += -lstdc++
LDFLAGS += -lpthread
LDFLAGS += -lrt

#--- Specify AWS libraries ---#

LDFLAGS += -L$(XILINX_SDX_RUNTIME)
LDFLAGS += -lxilinxopencl

#--- Specify runtime libraries ---#

LDFLAGS += -Wl,-rpath,$(XILINX_SDX)/lnx64/tools/opencv
LDFLAGS += -Wl,-rpath,$(XILINX_SDX)/lib/lnx64.o
LDFLAGS += -Wl,-rpath,$(XILINX_SDX_RUNTIME)

#--- Specify objects ---#

HOST_AWS_DIR = ./
HOST_BLD_DIR = $(TARGET)/build/host
HOST_RUN_DIR = $(TARGET)/run

HOST_AWS_OBJ += $(addsuffix .o, $(addprefix $(HOST_BLD_DIR)/, $(HOST_AWS_SRC)) )
HOST_SDx_OBJ += $(addsuffix .o, $(addprefix $(HOST_BLD_DIR)/, $(HOST_SDx_SRC)) )

HOST_OBJ = $(HOST_AWS_OBJ) $(HOST_SDx_OBJ)

HOST_EXE ?= $(HOST_RUN_DIR)/$(TEST_NAME)

BUILD_SUBDIRS += $(HOST_BLD_DIR)


########################################
# #
# Kernel section #
# #
########################################

XOCC_OPTS += --platform $(AWS_PLATFORM)
XOCC_OPTS += --save-temps
XOCC_OPTS += --report system

XOCC_INCL += -I$(XFOPENCV)/include
XOCC_INCL += -I/opt/Xilinx/SDx/2017.4/include/ocv

KERNEL_BLD_DIR = $(TARGET)/build/kernel

ifeq "$(TARGET)" "hw"
KERNEL_RUN_DIR = $(TARGET)/afi
else
KERNEL_RUN_DIR = $(TARGET)/run
XOCC_OPTS += -g
endif

BUILD_SUBDIRS += $(KERNEL_BLD_DIR)

KERNEL_OBJ += $(addsuffix .xo , $(addprefix $(KERNEL_BLD_DIR)/, $(KERNEL)) )
KERNEL_BIN += $(addsuffix .xclbin, $(addprefix $(KERNEL_RUN_DIR)/, $(KERNEL)) )


########################################
# #
# Build section #
# #
########################################

.PHONY: all

all: host krnl

host: $(HOST_EXE)

krnl: $(KERNEL_BIN)

clean:
$(RMDIR) $(BUILD_SUBDIRS)
$(RMDIR) .Xil
$(RMDIR) $(HOST_RUN_DIR)/TempConfig
$(RM) $(HOST_RUN_DIR)/*.jpg $(HOST_RUN_DIR)/*.png $(HOST_RUN_DIR)/*.log $(HOST_RUN_DIR)/*.csv $(HOST_RUN_DIR)/*.html
$(RM) $(KERNEL_BIN)
$(RM) $(HOST_EXE)
$(RM) $(HOST_EXE)/*.*xclbin

.PHONY: all

#--- Kernel rules ---#

$(KERNEL_OBJ): $(KERNEL_BLD_DIR)/%.xo : %_kernel_aws.cpp
@echo " "
@echo "================================================================"
@echo "Compilation of $< to $@"
@echo "================================================================"
@echo " "
@mkdir -p $(@D)
$(XOCC) -c -t $(TARGET) $(XOCC_OPTS) $(XOCC_INCL) -k $(*F) --max_memory_ports $(*F) -I$(<D) --xp misc:solution_name=$(KERNEL_BLD_DIR)/$(*F)_compile -o$(@) $(<)



$(KERNEL_BIN): $(KERNEL_RUN_DIR)/%.xclbin : $(KERNEL_BLD_DIR)/%.xo
@echo " "
@echo "================================================================"
@echo "Linking of $@ ($(@D))"
@echo "================================================================"
@echo " "
mkdir -p $(KERNEL_RUN_DIR)
$(XOCC) -l -t $(TARGET) $(XOCC_OPTS) --jobs 8 --nk $(*F):1 --xp misc:solution_name=$(KERNEL_BLD_DIR)/$(*F)_link -o$(@) $(+)


#--- Host rules ---#

$(HOST_AWS_OBJ): $(HOST_BLD_DIR)/%.o : $(HOST_AWS_DIR)/%.cpp
@echo " "
@echo "================================================================"
@echo "Compilation of $< to $@"
@echo "================================================================"
@echo " "
@mkdir -p $(HOST_BLD_DIR)
$(SDX_CXX) $(CXXFLAGS) -o $(@) $(<)


$(HOST_SDx_OBJ): $(HOST_BLD_DIR)/%.o : $(SDx_LIB_DIR)/%.cpp
@echo " "
@echo "================================================================"
@echo "Compilation of $< to $@"
@echo "================================================================"
@echo " "
@mkdir -p $(HOST_BLD_DIR)
$(SDX_CXX) $(CXXFLAGS) -o $(@) $(<)


$(HOST_EXE): $(HOST_OBJ)
@echo " "
@echo "================================================================"
@echo "Linking of $@ ($(@D))"
@echo "================================================================"
@echo " "
mkdir -p $(HOST_RUN_DIR)
$(SDX_CXX) -o "$@" $(+) $(LDFLAGS)



Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions aws_demo/gaussianfilter/hw/afi/gen_afi.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash
echo aws s3 rm --recursive s3://xfg
aws s3 rm --recursive s3://xfg

echo aws s3 rb s3://xfg
aws s3 rb s3://xfg


echo aws s3 mb s3://xfg
aws s3 mb s3://xfg

aws s3 mb s3://xfg/dcp
touch FILES_GO_HERE.txt
aws s3 cp FILES_GO_HERE.txt s3://xfg/dcp/


aws s3 mb s3://xfg/log
touch LOGS_FILES_GO_HERE.txt
aws s3 cp LOGS_FILES_GO_HERE.txt s3://xfg/log/

aws s3 ls --recursive s3://xfg

rm -f FILES_GO_HERE.txt
rm -f LOGS_FILES_GO_HERE.txt

$SDACCEL_DIR/tools/create_sdaccel_afi.sh -xclbin=xf_gaussian_filter.xclbin -s3_bucket=xfg -s3_dcp_key=dcp -s3_logs_key=log

cat *afi_id*

echo "use following command to check afi ready"
echo "aws ec2 describe-fpga-images --fpga-image-id <afi id>"
5 changes: 5 additions & 0 deletions aws_demo/gaussianfilter/hw/run/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

source /opt/Xilinx/SDx/2017.1.rte.4ddr/setup.sh

./gaussian_filter_test ../../im0.jpg
5 changes: 5 additions & 0 deletions aws_demo/gaussianfilter/hw_emu/run/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
emconfigutil -f $AWS_PLATFORM

export XCL_EMULATION_MODE=hw_emu

./gaussian_filter_test ../../im0.jpg
5 changes: 5 additions & 0 deletions aws_demo/gaussianfilter/hw_emu/run/sdaccel.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[Debug]
timeline_trace=true
device_profile=true
app_debug=true
profile=true
Binary file added aws_demo/gaussianfilter/im0.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading