Skip to content

Commit

Permalink
fixed conv's unittest (wrong shape for bias), added bank opt python s…
Browse files Browse the repository at this point in the history
…cripts from DP-FGPA-V1
  • Loading branch information
salehjg committed Sep 12, 2021
1 parent a565eaa commit e733e7b
Show file tree
Hide file tree
Showing 7 changed files with 286 additions and 6 deletions.
10 changes: 10 additions & 0 deletions docs/banks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Memory Bank Optimizer
`scripts/bank_optimizer_v2.py` is created to find optimized memory banks for the kernels with the objective of minimizing the number of `DataMover` kernel launches needed to execute the computation graph of the selected `TopModelArch`.

# Instructions
1. Run the selected `CModel` on FPGA for `hostlog_0trace.log` to be created.
2. Open `hostlog_0trace.log` and find the lines that after `Dumping bank-crossing logs for` and append them.
3. Copy the these lines into `bank_optimizer_v2.py`, method `get_objective` and line `objective =`
4. Assign the allowed banks per kernel like `banks_transpose=[1,2]` to allow banks one and two to be selected for kernel `Transpose`, or `banks_transpose=[1]` to force the kernel to use only the bank one.
5. Run the script.
6. Use the output to configure `config` submodule of the main `DeepPoint-V2-FPGA` repository and then rebuild the FPGA image.
6 changes: 6 additions & 0 deletions docs/results.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Results
Here the results of the various FPGA runs on AWS F1 could be found.
To avoid including the related files in the git repository, they are lined below as github release archives.

## Archive Links
///TODO
3 changes: 2 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ This repository contains the second version of the code base for Xilinx SDAccel
- [Debugging The Project](docs/debug.md)
- [Deploying on AWS-F1](docs/aws.md)
- [Tips & Tricks!](docs/tips.md)
- [Results](docs/results.md)

# Build System
As easy as it is to use SDx GUI, it is recommended to use provided cmake scripts to run synthesis and build the binaries for both the selected FPGA platform and the host.
Expand All @@ -18,7 +19,7 @@ This project relies on these software/libraries(These should be installed on the
Xilinx SDAccel 2019.1(Tested), 2018.3 2018.2 2017.4(Not Tested)
Xilinx XRT
python3(Symlinked as `python3`)
CMake3 (>3.10, Do **not** use default CMake package available on AWS-F1)
CMake3 (>3.10, Do **not** use the default CMake package available on AWS-F1)
Bash (>4.0, Dash and others are not tested)
devtoolset-7 (>7.0, For C++14 support)
```
Expand Down
197 changes: 197 additions & 0 deletions scripts/bank_optimizer_v2.py

Large diffs are not rendered by default.

66 changes: 66 additions & 0 deletions scripts/kernel_obj.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import numpy as np


class SlrStats:
def __init__(self, slr_index, util_bram, util_dsp, util_ff, util_lut, util_uram):
self.slr_index = slr_index
self.util_bram = util_bram
self.util_dsp = util_dsp
self.util_ff = util_ff
self.util_lut = util_lut
self.util_uram = util_uram

def __add__(self, other):
if not(self.slr_index == -1 and other.slr_index == -1):
assert self.slr_index == other.slr_index
return SlrStats(
self.slr_index,
self.util_bram + other.util_bram,
self.util_dsp + other.util_dsp ,
self.util_ff + other.util_ff ,
self.util_lut + other.util_lut ,
self.util_uram + other.util_uram
)

def __str__(self):
return ''.join([
"BRAM=",str(self.util_bram),'%, ',
"DSP=",str(self.util_dsp),'%, ',
"FF=",str(self.util_ff),'%, ',
"LUT=",str(self.util_lut),'%, ',
"URAM=",str(self.util_uram),'%, ',
])

def __lt__(self, other):
return self.util_bram < other.util_bram and \
self.util_dsp < other.util_dsp and \
self.util_ff < other.util_ff and \
self.util_lut < other.util_lut and \
self.util_uram < other.util_uram


class KernelObj:
def __init__(self, kernel_name, possible_banks, util_bram, util_dsp, util_ff, util_lut, util_uram, assigned_bank=-1):
self.kernel_name = kernel_name
self.possible_banks = possible_banks
self.assigned_bank = assigned_bank
self.util_stats = SlrStats(-1, util_bram, util_dsp, util_ff, util_lut, util_uram)

def get_slr(self):
if self.assigned_bank == 1:
return 2
if self.assigned_bank == 2:
return 1
assert False

def clone(self, assigned_bank=-1):
return KernelObj(
self.kernel_name,
self.possible_banks,
self.util_stats.util_bram,
self.util_stats.util_dsp,
self.util_stats.util_ff,
self.util_stats.util_lut,
self.util_stats.util_uram,
assigned_bank)

8 changes: 4 additions & 4 deletions test/ocltests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ set(TEST_SOURCES
#${CMAKE_SOURCE_DIR}/test/ocltests/unittests/test_ckwtile/test_ckwtile.cpp
#${CMAKE_SOURCE_DIR}/test/ocltests/unittests/test_ckwtranspose/test_ckwtranspose.cpp
#${CMAKE_SOURCE_DIR}/test/ocltests/unittests/test_ckwgather/test_ckwgather.cpp
${CMAKE_SOURCE_DIR}/test/ocltests/unittests/test_ckwreduce/test_ckwreduce.cpp
${CMAKE_SOURCE_DIR}/test/ocltests/unittests/test_layermean/test_layermean.cpp
${CMAKE_SOURCE_DIR}/test/ocltests/unittests/test_layervariance/test_layervariance.cpp
#${CMAKE_SOURCE_DIR}/test/ocltests/unittests/test_ckwreduce/test_ckwreduce.cpp
#${CMAKE_SOURCE_DIR}/test/ocltests/unittests/test_layermean/test_layermean.cpp
#${CMAKE_SOURCE_DIR}/test/ocltests/unittests/test_layervariance/test_layervariance.cpp
#${CMAKE_SOURCE_DIR}/test/ocltests/unittests/test_ckwpadunpad/test_ckwpadunpad.cpp
#${CMAKE_SOURCE_DIR}/test/ocltests/unittests/test_ckwtopk/test_ckwtopk.cpp
#${CMAKE_SOURCE_DIR}/test/ocltests/unittests/test_ckwconv/test_ckwconv.cpp
${CMAKE_SOURCE_DIR}/test/ocltests/unittests/test_ckwconv/test_ckwconv.cpp
)


Expand Down
2 changes: 1 addition & 1 deletion test/ocltests/unittests/test_ckwconv/test_ckwconv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ bool ConvTest1(

TEST(test_ckwconv, mixed1) {
std::vector<bool> results = {
ConvTest1<float>({1,256,1,6},{1,1,6,16},{128}),
ConvTest1<float>({1,256,1,6},{1,1,6,16},{16}),
};

for(auto r:results){
Expand Down

0 comments on commit e733e7b

Please sign in to comment.