Skip to content

Initial changes for F4PGA #82

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 209 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
209 commits
Select commit Hold shift + click to select a range
0f6e7cc
add dram
Jan 6, 2022
f0eb23f
integrating
AzinT Mar 11, 2022
0774248
int
AzinT Mar 11, 2022
d318ab5
add xcl2
AzinT Mar 11, 2022
6a72a45
add xcl2
AzinT Mar 11, 2022
668e3ac
add xcl2
AzinT Mar 11, 2022
f871951
int
AzinT Mar 12, 2022
fc208be
int
AzinT Mar 12, 2022
6ea950c
int
AzinT Mar 12, 2022
1bb0fa7
int
AzinT Mar 12, 2022
5c83a31
int
AzinT Mar 12, 2022
8be154b
int
AzinT Mar 12, 2022
e54b121
int
AzinT Mar 12, 2022
3d5ff87
int
AzinT Mar 12, 2022
5c05255
int
AzinT Mar 12, 2022
dec3d35
int
AzinT Mar 12, 2022
d02bab7
int
AzinT Mar 12, 2022
ac457a9
int
AzinT Mar 12, 2022
0847130
int
AzinT Mar 12, 2022
3b89512
int
AzinT Mar 12, 2022
6ce503f
int
AzinT Mar 12, 2022
9aadd72
int
AzinT Mar 12, 2022
8edc523
innt
AzinT Mar 12, 2022
6a34013
innt
AzinT Mar 12, 2022
52bfc1b
innt
AzinT Mar 12, 2022
0c8118a
innt
AzinT Mar 12, 2022
9937281
innt
AzinT Mar 12, 2022
5367e9c
innt
AzinT Mar 12, 2022
927cda6
innt
AzinT Mar 12, 2022
b735e10
innt
AzinT Mar 12, 2022
da5fbd5
innt
AzinT Mar 12, 2022
2d755bd
innt
AzinT Mar 12, 2022
cf0cc64
innt
AzinT Mar 12, 2022
6ece7cb
innt
AzinT Mar 12, 2022
c857505
init
AzinT Mar 12, 2022
dbc59fa
init
AzinT Mar 12, 2022
5c39303
init
AzinT Mar 12, 2022
256ccdf
init
AzinT Mar 12, 2022
69f665a
init
AzinT Mar 12, 2022
070f938
init
AzinT Mar 12, 2022
23683ae
init
AzinT Mar 12, 2022
1552a26
init
AzinT Mar 12, 2022
2c904ec
init
AzinT Mar 12, 2022
078facf
init
AzinT Mar 12, 2022
f3af5ef
init
AzinT Mar 12, 2022
69f7854
init
AzinT Mar 12, 2022
8bf4e2d
init
AzinT Mar 12, 2022
5a8823e
init
AzinT Mar 12, 2022
4711bd7
init
AzinT Mar 12, 2022
df2f576
init
AzinT Mar 12, 2022
a227560
init
AzinT Mar 12, 2022
562bfbc
init
AzinT Mar 12, 2022
b8bf38e
init
AzinT Mar 12, 2022
2f942b7
init
AzinT Mar 12, 2022
707ac63
init
AzinT Mar 12, 2022
fb549e5
init
AzinT Mar 12, 2022
f82f7fd
init
AzinT Mar 12, 2022
31f38a3
init
AzinT Mar 12, 2022
a0f3ed5
init
AzinT Mar 12, 2022
b5cfbb6
init
AzinT Mar 12, 2022
378d5f8
init
AzinT Mar 12, 2022
ae8497d
init
AzinT Mar 12, 2022
8e37ef3
init
AzinT Mar 12, 2022
434e807
init
AzinT Mar 12, 2022
af12996
init
AzinT Mar 12, 2022
ee36168
init
AzinT Mar 12, 2022
0161dbe
init
AzinT Mar 12, 2022
5c2c738
init
AzinT Mar 12, 2022
db81976
init
AzinT Mar 12, 2022
a41007d
init
AzinT Mar 12, 2022
128789b
init
AzinT Mar 12, 2022
83ac693
init
AzinT Mar 12, 2022
0fad4ec
init
AzinT Mar 12, 2022
cca1506
init
AzinT Mar 12, 2022
715c276
init
AzinT Mar 12, 2022
e1f7ebd
init
AzinT Mar 12, 2022
0708a30
init
AzinT Mar 12, 2022
d19e5af
done
Mar 12, 2022
acae68c
init
AzinT Mar 12, 2022
8fbc83f
init
AzinT Mar 12, 2022
7a2344f
init
AzinT Mar 12, 2022
98ae122
init
AzinT Mar 12, 2022
d9c853f
init
AzinT Mar 12, 2022
2add695
init
AzinT Mar 12, 2022
eb3188a
init
AzinT Mar 12, 2022
b83716b
init
AzinT Mar 12, 2022
dad5f81
init
AzinT Mar 12, 2022
12b6c39
init
AzinT Mar 12, 2022
2abe44c
init
AzinT Mar 12, 2022
7556e59
init
AzinT Mar 12, 2022
47ffa5a
init
AzinT Mar 12, 2022
627f250
init
AzinT Mar 12, 2022
5f65765
init
AzinT Mar 12, 2022
a5caf67
init
AzinT Mar 12, 2022
5bac8d3
init
AzinT Mar 12, 2022
8351bb6
Revert commit of Smith-Waterman.
stevehoover Oct 27, 2022
805b013
Revert "init"
stevehoover Oct 27, 2022
9f1cc10
Revert "init"
stevehoover Oct 27, 2022
13a7beb
Revert "init"
stevehoover Oct 27, 2022
7bd710f
Revert "init"
stevehoover Oct 27, 2022
0af6aa1
Revert "init"
stevehoover Oct 27, 2022
49cc28f
Revert "init"
stevehoover Oct 27, 2022
c6237df
Revert "init"
stevehoover Oct 27, 2022
3307701
Revert "init"
stevehoover Oct 27, 2022
1161bde
Revert "init"
stevehoover Oct 27, 2022
8a5c974
Revert "init"
stevehoover Oct 27, 2022
efb0194
Revert "init"
stevehoover Oct 27, 2022
c8bfbec
Revert "init"
stevehoover Oct 27, 2022
784ac92
Revert "init"
stevehoover Oct 27, 2022
bbd2460
Revert "init"
stevehoover Oct 27, 2022
9e9e852
Revert "init"
stevehoover Oct 27, 2022
ac80fe6
Revert "init"
stevehoover Oct 27, 2022
3ceead9
Revert "done"
stevehoover Oct 27, 2022
3f9b79a
Revert "init"
stevehoover Oct 27, 2022
b9e1b55
Revert "init"
stevehoover Oct 27, 2022
994b1c7
Revert "init"
stevehoover Oct 27, 2022
4bf53ee
Revert "init"
stevehoover Oct 27, 2022
b3cda5d
Revert "init"
stevehoover Oct 27, 2022
55f3bd9
Revert "init"
stevehoover Oct 27, 2022
63a09f7
Revert "init"
stevehoover Oct 27, 2022
e831076
Revert "init"
stevehoover Oct 27, 2022
32dc806
Revert "init"
stevehoover Oct 27, 2022
a6442b5
Revert "init"
stevehoover Oct 27, 2022
5b7a975
Revert "init"
stevehoover Oct 27, 2022
3774a7c
Revert "init"
stevehoover Oct 27, 2022
e39d5c9
Revert "init"
stevehoover Oct 27, 2022
f49532e
Revert "init"
stevehoover Oct 27, 2022
0e88ccb
Revert "init"
stevehoover Oct 27, 2022
5672c49
Revert "init"
stevehoover Oct 27, 2022
0a06984
Revert "init"
stevehoover Oct 27, 2022
01e53b6
Revert "init"
stevehoover Oct 27, 2022
877965b
Revert "init"
stevehoover Oct 27, 2022
9f8a227
Revert "init"
stevehoover Oct 27, 2022
d6cb2e9
Revert "init"
stevehoover Oct 27, 2022
c035774
Revert "init"
stevehoover Oct 27, 2022
57933d8
Revert "init"
stevehoover Oct 27, 2022
358fbd6
Revert "init"
stevehoover Oct 27, 2022
a3917e4
Revert "init"
stevehoover Oct 27, 2022
6a5c3bf
Revert "init"
stevehoover Oct 27, 2022
21e4cce
Revert "init"
stevehoover Oct 27, 2022
fbdc2ff
Revert "init"
stevehoover Oct 27, 2022
4cd440f
Revert "init"
stevehoover Oct 27, 2022
ed80720
Revert "init"
stevehoover Oct 27, 2022
36c1496
Revert "init"
stevehoover Oct 27, 2022
e58ed13
Revert "init"
stevehoover Oct 27, 2022
0e274fc
Revert "init"
stevehoover Oct 27, 2022
61a91fd
Revert "init"
stevehoover Oct 27, 2022
727955f
Revert "init"
stevehoover Oct 27, 2022
c9c41cb
Revert "init"
stevehoover Oct 27, 2022
6f1af52
Revert "init"
stevehoover Oct 27, 2022
ddad5bc
Revert "init"
stevehoover Oct 27, 2022
ff1b7a8
Revert "init"
stevehoover Oct 27, 2022
2d4d92a
Revert "init"
stevehoover Oct 27, 2022
aa04622
Revert "init"
stevehoover Oct 27, 2022
a0e8bdb
Revert "init"
stevehoover Oct 27, 2022
8345b90
Revert "init"
stevehoover Oct 27, 2022
9b5c77a
Revert "innt"
stevehoover Oct 27, 2022
3e0f093
Revert "innt"
stevehoover Oct 27, 2022
56cc838
Revert "innt"
stevehoover Oct 27, 2022
81653ec
Revert "innt"
stevehoover Oct 27, 2022
6e2788f
Revert "innt"
stevehoover Oct 27, 2022
9c3ecf6
Revert "innt"
stevehoover Oct 27, 2022
449d10e
Revert "innt"
stevehoover Oct 27, 2022
7ff696f
Revert "innt"
stevehoover Oct 27, 2022
d5126f3
Revert "innt"
stevehoover Oct 27, 2022
b504361
Revert "innt"
stevehoover Oct 27, 2022
3b969ad
Revert "innt"
stevehoover Oct 27, 2022
67a1800
Revert "innt"
stevehoover Oct 27, 2022
de8e6ea
Revert "int"
stevehoover Oct 27, 2022
e617717
Revert "int"
stevehoover Oct 27, 2022
c76e272
Revert "int"
stevehoover Oct 27, 2022
afcbad9
Revert "int"
stevehoover Oct 27, 2022
4737b58
Revert "int"
stevehoover Oct 27, 2022
fd8567f
Revert "int"
stevehoover Oct 27, 2022
37af793
Revert "int"
stevehoover Oct 27, 2022
7021452
Revert "int"
stevehoover Oct 27, 2022
022fa7e
Revert "int"
stevehoover Oct 27, 2022
7e94af1
Revert "int"
stevehoover Oct 27, 2022
0516f91
Revert "int"
stevehoover Oct 27, 2022
3c433ec
Revert "int"
stevehoover Oct 27, 2022
3e0db68
Revert "int"
stevehoover Oct 27, 2022
1bf341e
Revert "int"
stevehoover Oct 27, 2022
4417895
Revert "int"
stevehoover Oct 27, 2022
b0ceeaa
Revert "int"
stevehoover Oct 27, 2022
450141a
Revert "add xcl2"
stevehoover Oct 27, 2022
785d91d
Revert "add xcl2"
stevehoover Oct 27, 2022
4fdd040
Revert "add xcl2"
stevehoover Oct 27, 2022
207341e
Revert "int"
stevehoover Oct 27, 2022
83efb2e
Revert "integrating"
stevehoover Oct 27, 2022
bed82ce
Revert "add dram"
stevehoover Oct 27, 2022
d7c21f2
Merge /home/steve/repos/1st-CLaaS
stevehoover Oct 27, 2022
b02b056
Updated Terraform version to 1.5.2
Shelby-dotcom Jul 22, 2023
34f3bab
Config instance updated for RDP
Shelby-dotcom Sep 10, 2023
c23a809
Temporary Makefile comments for Local Deployment
Shelby-dotcom Sep 10, 2023
ae6873a
Stabalized hw_emu: Added vitis etup and removed sdaccel setup
Shelby-dotcom Sep 10, 2023
63aa3b4
Makefile and launc scrhipt changes
Shelby-dotcom Sep 10, 2023
ca06f0f
Host kernel updated OpenCL calls
Shelby-dotcom Sep 10, 2023
aed616b
Updated rtl kernel tcl script
Shelby-dotcom Sep 10, 2023
bc627b6
Updated Makefile for f1 instance
Shelby-dotcom Sep 23, 2023
64cc541
Updated prebuilt files
Shelby-dotcom Sep 23, 2023
379aae4
Hw flow stablized
Sep 30, 2023
6dd3b37
prebuilt updated
Shelby-dotcom Sep 30, 2023
0b42fa7
Minor readme changes
Shelby-dotcom Oct 2, 2023
029aa8c
Merge branch 'master' into ali/GSOC
Shelby-dotcom Oct 2, 2023
6834dca
Corrected a bug in launch script causing sim to fail
Shelby-dotcom Oct 9, 2023
cf3bbf7
Updated verilator to v5.016
Shelby-dotcom Oct 9, 2023
c6ddc9f
cleanup makefile
Shelby-dotcom Oct 9, 2023
d10f93a
cleanup hw_kernel
Shelby-dotcom Oct 9, 2023
bd0b66d
Initial changes for f4pga
Shelby-dotcom Oct 23, 2023
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
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "framework/host/json"]
path = framework/host/json
url = https://github.com/nlohmann/json.git
[submodule "framework/fpga/f4pga-examples"]
path = framework/fpga/f4pga-examples
url = https://github.com/chipsalliance/f4pga-examples
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ Looking specifically at the Amazon F1 platform, F1 provides powerful Xilinx FPGA

- Documentation is often misleading as APIs and infrastructure are evolving.
- External dependencies are poorly managed, so tutorials break at random.
- Xilinx tools, Vivado and SDAccel, while powerful, are difficult to learn and use, slow, and arcane.
- Xilinx tools, Vivado and Vitis, while powerful, are difficult to learn and use, slow, and arcane.
- OpenCL is a whole other beast, built for folks who want to design hardware like it's software... which it obviously isn't.
- Developers must understand AXI protocols and manage AXI controllers.
- The AWS platform can be intimidating to a newcomer.
Expand Down
Binary file not shown.
Binary file not shown.
3 changes: 2 additions & 1 deletion bin/install_verilator
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ then
echo "$(pwd)/verilator exists."
echo "To reinstall, first 'rm -rf $(pwd)/verilator'."
else
curl https://www.veripool.org/ftp/verilator-4.018.tgz | tar -zx
wget -qO- https://github.com/verilator/verilator/archive/refs/tags/v5.016.tar.gz | tar xvz
mv verilator* verilator # So path is not version-dependent.
cd verilator
autoconf
./configure
make -j$(nproc)
fi
Expand Down
4 changes: 2 additions & 2 deletions doc/DevelopersGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ The top-level file structure is:
- `regress`: a regression script that launches framework and app regression scripts
- `doc`: documentation (including this document)
- `init`: a script to set up the repository for development
- `sdaccel_setup`: a script to set up for development using Xilinx tools on AWS
- `vitis_setup`: a script to set up for development using Xilinx tools on AWS

An application _`foo`_ is constructed from code in `framework` and `apps/foo`. `framework` and `apps/foo` contain files/directories using nearly identical structure:

Expand Down Expand Up @@ -90,7 +90,7 @@ An actual F1, and even AWS as a whole, are needed very little during development

- Software (`sw`): An optional mode where the RTL kernel is not utilized. Custom C++ code is required to provide emulated kernel behavior.
- Simulation (`sim`): Verilator is used for 2-state simulation of the custom RTL kernel. Verilator creates a C++ model of the kernel which is directly compiled in with the host executable. The Host Application C++ code controls the kernel clock and decides when to send/receive data to/from the kernel.
- Hardware Emulation (`hw_emu`): This mode is supported by Xilinx SDAccel on AWS. All FPGA logic is simulated, including the custom kernel and surrounding shell logic. This runs much slower than Simulation.
- Hardware Emulation (`hw_emu`): This mode is supported by Xilinx Vitis on AWS. All FPGA logic is simulated, including the custom kernel and surrounding shell logic. This runs much slower than Simulation.
- Hardware (`hw`): Uses a real F1 FPGA.

Generally, most kernel development is done in Simulation. Hardware Emulation is used to refine the implementation of the design and may catch a few new bugs because of 4-state modeling and test bench differences. Hardware compilation is primarily for testing the application at speed and for deployment.
Expand Down
15 changes: 11 additions & 4 deletions doc/GettingStartedF1.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ The command below uses <a href="https://www.terraform.io/" target="_blank" atom_

> **IMPORTANT:** Be sure not to accidentally leave instances running!!! You should configure monitoring of your resources, but the options, though plentiful, seem very limited for catching instances you fail to stop. Also be warned that stopping an instance can fail. We have found it important to always refresh the page before changing machine state. And, be sure your instance transitions to "stopped" state (or, according to AWS support, charging stops at "stopping" state).

You must choose a Linux password for your new instance (which must not contain single/double quotes nor backslash). Obviously, since you are typing it here in plain text, be sure it is not visible to wandering eyes, and perhaps run `clear` after command completion.
You must choose a Linux password for your new instance (which must not contain single/double quotes nor backslash). **Make Sure to use a strong password probably with more than 8 characters and having alphabets + numbers + special characters** .Obviously, since you are typing it here in plain text, be sure it is not visible to wandering eyes, and perhaps run `clear` after command completion.

```sh
make development_instance LINUX_PASSWORD=<password-for-your-instance>
Expand Down Expand Up @@ -145,6 +145,13 @@ make desktop

Enter your Linux password. (We do not register your password with Remmina because Remmina must be carefully configure to keep your password secure.)

If you have Windows installed, you can use RDC (Remote Desktop Connection). If you want to access the remote server manually, type the Public IP Address in the field.

![RDC sample](/doc/img/RDC.png "RDC Window")

If you face any color depth issue when using Remote Desktop especially with Xilinx Tools (they get blurry and test is none to visible), you can set High Colour to **16 bit**

![RDC color](/doc/img/RDC_color.png "RDC Colour")

### SSH Access

Expand Down Expand Up @@ -183,7 +190,7 @@ Open a new terminal in your remote desktop. Each time you do so, you must:

```sh
cd ~/1st-CLaaS # (~/1st-CLaaS is a symbolic link.)
source sdaccel_setup
source vitis_setup
```


Expand Down Expand Up @@ -225,7 +232,7 @@ git commit ...
git push # If not to master, you would pull from corresponding branch on F1 instance.
```

> Note: Sourcing `sdaccel_setup` currently breaks `git gui` and `gitk`, so use these in a separate shell without `sdaccel_setup`.
> Note: Sourcing `vitis_setup` currently breaks `git gui` and `gitk`, so use these in a separate shell without `vitis_setup`.



Expand All @@ -239,7 +246,7 @@ make f1_instance
```

```sh
make ssh SSH_CMD='source 1st-CLaaS/sdaccel_setup && cd 1st-CLaaS/app/mandelbrot/build && make launch PREBUILT=true' # TARGET=hw is the default on F1.
make ssh SSH_CMD='source 1st-CLaaS/vitis_setup && cd 1st-CLaaS/app/mandelbrot/build && make launch PREBUILT=true' # TARGET=hw is the default on F1.
```

As before, open `http://<IP>:8888` in your browser (using the new IP). Now you can select renderer "FPGA", and navigate at FPGA speed. (Try "velocity" nagivation mode.)
Expand Down
Binary file added doc/img/RDC.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/img/RDC_color.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 12 additions & 11 deletions framework/build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ SUPPORTED_TARGETS :=$(SUPPORTED_TARGETS)sw |$(SPACE)
endif



#
# Determine BUILD_TARGET. [hw (default) | hw_emu | sim | sw]
#
Expand Down Expand Up @@ -364,7 +365,7 @@ S3_LOGS_KEY=$(KERNEL_NAME)_log
S3_DCP_KEY=$(KERNEL_NAME)_dcp
S3_TRANSFER_KEY=$(KERNEL_NAME)_xfer

XOCC=xocc
VPP=v++
CC=g++


Expand Down Expand Up @@ -395,7 +396,7 @@ HOST_HDRS=$(SW_HDRS) $(FRAMEWORK_HOST_DIR)/kernel.h
HOST_HDRS=$(SW_HDRS) $(FRAMEWORK_HOST_DIR)/hw_kernel.h
# TODO: It seems SDX_PLATFORM should be set to a value. For hw_emu, I see one device: "xilinx:pcie-hw-em:7v3:1.0"
# What's the emconfigutil command (for configuring the platform for hw_emu?)
HOST_CFLAGS=$(SW_CFLAGS) -D KERNEL_AVAIL -D FPGA_DEVICE -D OPENCL -I$(XILINX_XRT)/runtime/include/1_2 -D C_KERNEL -D SDX_PLATFORM=$(AWS_PLATFORM) -D KERNEL=$(KERNEL_NAME)
HOST_CFLAGS=$(SW_CFLAGS) -D KERNEL_AVAIL -D FPGA_DEVICE -D OPENCL -I$(XILINX_XRT)/runtime/include/1_2 -D C_KERNEL -D VITIS_PLATFORM=xilinx_aws-vu9p-f1_shell-v04261818_201920_3 -D KERNEL=$(KERNEL_NAME)
HOST_LFLAGS=$(SW_LFLAGS) -lxilinxopencl

#Simulation flags
Expand All @@ -410,15 +411,15 @@ HOST_EXE=host

#Kernel
KERNEL_SRC=
# Flags for xocc (include -I <file> args).
# Flags for v++ (include -I <file> args).
KERNEL_FLAGS=
KERNEL_EXE=$(KERNEL_NAME)

#Custom flag to give to xocc
KERNEL_LDCLFLAGS=--nk $(KERNEL_NAME):1 \
--xp param:compiler.preserveHlsOutput=1 \
--max_memory_ports $(KERNEL_NAME) \
--memory_port_data_width $(KERNEL_NAME):512 \
#Custom flag to give to v++
KERNEL_LDCLFLAGS= --connectivity.nk $(KERNEL_NAME):1 \
--xp param:compiler.preserveHlsOutput=1 \
--hls.max_memory_ports $(KERNEL_NAME) \
--hls.memory_port_data_width $(KERNEL_NAME):512 \

KERNEL_ADDITIONAL_FLAGS=

Expand Down Expand Up @@ -549,7 +550,7 @@ HOST_CMD=$(VALGRIND_PREFIX) $(HOST_EXE_PATH) $(HOST_ARGS)
endif
ifeq ($(BUILD_TARGET),hw_emu)
BUILD_TARGETS=$(BUILD_DIR)/$(HOST_EXE) $(HOST_XCLBIN)
HOST_CMD=export XCL_EMULATION_MODE=$(BUILD_TARGET) && $(XILINX_SDX)/bin/emconfigutil --od $(DEST_DIR) --nd 1 --platform $(AWS_PLATFORM) && $(VALGRIND_PREFIX) $(HOST_EXE_PATH) $(HOST_ARGS) $(HOST_XCLBIN)
HOST_CMD=export XCL_EMULATION_MODE=$(BUILD_TARGET) && $(XILINX_VITIS)/bin/emconfigutil --od $(DEST_DIR) --nd 1 --platform $(AWS_PLATFORM) && $(VALGRIND_PREFIX) $(HOST_EXE_PATH) $(HOST_ARGS) $(HOST_XCLBIN)
endif
ifeq ($(BUILD_TARGET),hw)
BUILD_TARGETS=$(BUILD_DIR)/$(HOST_EXE) $(HOST_XCLBIN)
Expand Down Expand Up @@ -794,7 +795,7 @@ project: $(USER_KERNEL_ADDED_FILE)


$(DEST_DIR)/$(KERNEL_EXE).xclbin: $(XO_FILE)
cd $(DEST_DIR); $(XOCC) -g --platform $(AWS_PLATFORM) --target $(BUILD_TARGET) --link -O quick --save-temps $(REPORT) --kernel $(KERNEL_NAME) ../../$(XO_FILE) $(KERNEL_LDCLFLAGS) $(KERNEL_FLAGS) $(KERNEL_ADDITIONAL_FLAGS) --output $(KERNEL_EXE).xclbin
cd $(DEST_DIR); $(VPP) -g --platform $(AWS_PLATFORM) --target $(BUILD_TARGET) --link -O quick --save-temps $(REPORT) --kernel $(KERNEL_NAME) --input_files ../../$(XO_FILE) $(KERNEL_LDCLFLAGS) $(KERNEL_FLAGS) $(KERNEL_ADDITIONAL_FLAGS) --output $(KERNEL_EXE).xclbin

# Create the AFI.
# The steps are:
Expand All @@ -812,7 +813,7 @@ $(BUILD_DIR)/$(KERNEL_EXE).awsxclbin: $(DEST_DIR)/$(KERNEL_EXE).xclbin
@# Create bucket if it doesn't exist.
aws s3api create-bucket --bucket '$(S3_BUCKET)' --acl private > /dev/null && aws s3api wait bucket-exists --bucket '$(S3_BUCKET)'
# Create AFI and Wait for creation to complete. afi-<id> and <timestamp>_afi_id.txt are extracted into files for use.
cd $(DEST_DIR) && $(SDACCEL_DIR)/tools/create_sdaccel_afi.sh -xclbin=$(KERNEL_EXE).xclbin -o=$(KERNEL_NAME) -s3_bucket=$(S3_BUCKET) -s3_dcp_key=$(S3_DCP_KEY) -s3_logs_key=$(S3_LOGS_KEY) -aws_profile_name=$(AWS_PROFILE) \
cd $(DEST_DIR) && $(VITIS_DIR)/tools/create_vitis_afi.sh -xclbin=$(KERNEL_EXE).xclbin -o=$(KERNEL_NAME) -s3_bucket=$(S3_BUCKET) -s3_dcp_key=$(S3_DCP_KEY) -s3_logs_key=$(S3_LOGS_KEY) -aws_profile_name=$(AWS_PROFILE) \
&& grep '"afi-' *_afi_id.txt | sed 's/^.*"\(afi-[0-9a-zA-Z]*\)".*$$/\1/' > $(KERNEL_NAME)_afi_id.txt \
&& ls *_afi_id.txt | sed 's/^\(.*\)_afi_id.txt$$/\1/' > $(KERNEL_NAME)_timestamp.txt \
&& wait_for_afi.py --afi "$$(cat $(KERNEL_NAME)_afi_id.txt)"
Expand Down
18 changes: 15 additions & 3 deletions framework/build/launch
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@

# TODO: Make a function to wrap commands in sudo.


usage () {
echo "Usage: launch [-p #] [-h host-pid] [-c compile-command] [-w web-server-args] (sw|hw_emu|hw) host-command"
exit 1
Expand Down Expand Up @@ -129,6 +128,12 @@ else
USE_XILINX=true
fi

if [[ $TARGET = "hw" ]]
then
USE_FPGA=true
else
USE_FPGA=false
fi

if [[ $USE_XILINX = "false" ]] && [[ $HOST = "" ]];
then
Expand Down Expand Up @@ -156,8 +161,15 @@ launch () {
if [[ $USE_XILINX = "false" ]];
then
$HOST &
else
sudo -- sh -c "source /opt/xilinx/xrt/setup.sh ; $HOST" &
fi
else if [[ $USE_XILINX = "false" ]] || [[ $USE_FPGA = "false" ]];
then
sudo -- sh -c "source $XILINX_VITIS/settings64.sh; source /opt/xilinx/xrt/setup.sh; source $AWS_FPGA_REPO_DIR/vitis_setup.sh; emconfigutil --nd 1 --platform $AWS_PLATFORM; export XCL_EMULATION_MODE=hw_emu ;$HOST" &
fi

if [[ $USE_XILINX = "true" ]] && [[ $USE_FPGA = "true" ]];
then
sudo -- sh -c "source $XILINX_VITIS/settings64.sh; source /opt/xilinx/xrt/setup.sh; source $AWS_FPGA_REPO_DIR/vitis_setup.sh; source $AWS_FPGA_REPO_DIR/vitis_runtime_setup.sh; export LANG=C; $HOST" &
fi
export HOST_PID=$!
fi
Expand Down
1 change: 1 addition & 0 deletions framework/fpga/f4pga-examples
Submodule f4pga-examples added at a5a44f
2 changes: 1 addition & 1 deletion framework/fpga/scripts/produce_tcl_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def json_to_tcl_config (string):
'create_project kernel_wizard $wizardDir -force\n'
'\n'
'# Instantiate the SDx kernel wizard IP\n'
'create_ip -name sdx_kernel_wizard -vendor xilinx.com -library ip -module_name $kernelName\n\n')
'create_ip -name rtl_kernel_wizard -vendor xilinx.com -library ip -module_name $kernelName\n\n')

string += json_to_tcl_config(config_file)

Expand Down
2 changes: 1 addition & 1 deletion framework/fpga/scripts/tcl/rtl_kernel_wiz.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ set kernelDir $workspace/$kernelPrjName
create_project kernel_wizard $wizardDir -force

# Instantiate the SDx kernel wizard IP
create_ip -name sdx_kernel_wizard -vendor xilinx.com -library ip -module_name $kernelName
create_ip -name rtl_kernel_wizard -vendor xilinx.com -library ip -module_name $kernelName

set cmd "set_property -dict \[list CONFIG.NUM_CLOCKS {2} CONFIG.NUM_INPUT_ARGS {1} CONFIG.ARG00_NAME {ctrl_length} CONFIG.NUM_M_AXI {1} CONFIG.M00_AXI_NUM_ARGS {1} CONFIG.M00_AXI_ARG00_NAME {a} CONFIG.KERNEL_NAME {$kernelName} CONFIG.KERNEL_VENDOR {$kernelVendor}] \[get_ips $kernelName]"
eval $cmd
Expand Down
76 changes: 67 additions & 9 deletions framework/host/hw_kernel.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <sys/stat.h>
#include <sys/time.h>
#include "kernel.h"
#define CL_USE_DEPRECATED_OPENCL_1_2_APIS
#include <CL/opencl.h>

#include <CL/cl_ext.h>
#include "server_main.h"

#if defined(VITIS_PLATFORM)
#define STR_VALUE(arg) #arg
#define GET_STRING(name) STR_VALUE(name)
#define TARGET_DEVICE GET_STRING(VITIS_PLATFORM)
#endif


HW_Kernel::HW_Kernel() {
}
Expand All @@ -64,8 +71,8 @@ void HW_Kernel::perror(const char * msg) {
status = EXIT_FAILURE;
}

int HW_Kernel::load_file_to_memory(const char *filename, char **result) {
uint size = 0;
cl_uint HW_Kernel::load_file_to_memory(const char *filename, char **result) {
cl_uint size = 0;
FILE *f = fopen(filename, "rb");
if (f == NULL) {
*result = NULL;
Expand All @@ -81,6 +88,8 @@ int HW_Kernel::load_file_to_memory(const char *filename, char **result) {
}
fclose(f);
(*result)[size] = 0;
// For Debugging
printf("File loaded to memory\n");
return size;
}

Expand All @@ -90,6 +99,12 @@ void HW_Kernel::initialize_platform() {
cl_uint platform_count;
char cl_platform_vendor[1001];

cl_uint num_devices; // Number of cl_devices if more than one
cl_uint device_found = 0;
cl_device_id devices[16]; // compute device id
char cl_device_name[1001];
char target_device_name[1001] = TARGET_DEVICE;

int err;

int platform_found = 0;
Expand Down Expand Up @@ -129,11 +144,40 @@ void HW_Kernel::initialize_platform() {
#endif
printf("get device, fpga is %d \n", fpga);
err = clGetDeviceIDs(platform_id, fpga ? CL_DEVICE_TYPE_ACCELERATOR : CL_DEVICE_TYPE_CPU,
1, &device_id, NULL);
16, devices, &num_devices);
if (err != CL_SUCCESS) {
perror("Error: Failed to create a device group!\nTest failed\n");
return;
}

//iterate all devices to select the target device.
for (cl_uint i=0; i<num_devices; i++) {
err = clGetDeviceInfo(devices[i], CL_DEVICE_NAME, 1024, cl_device_name, 0);
if (err != CL_SUCCESS) {
printf("ERROR: Failed to get device name for device %d!\n", i);
printf("ERROR: Test failed\n");
return;
}

if (fpga == 0)
{
if(strcmp(cl_device_name, target_device_name) == 0) {
device_id = devices[i];
device_found = 1;
printf("Selected %s as the target device\n", cl_device_name);
}
}
else {
device_id = devices[i];
device_found = 1;
printf("Selected %s as the target device\n", cl_device_name);
}}

if (!device_found) {
printf("ERROR:Target device %s not found. Exit.\n", target_device_name);
return;
}

// Creation of a compute context
context = clCreateContext(0, 1, &device_id, NULL, NULL, &err);
if (!context) {
Expand All @@ -142,13 +186,15 @@ void HW_Kernel::initialize_platform() {
}

// Creation a command commands
commands = clCreateCommandQueue(context, device_id, 0, &err);
commands = clCreateCommandQueue(context, device_id, CL_QUEUE_PROFILING_ENABLE | CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, &err);
if (!commands) {
perror("Error: Failed to create a command commands!\nTest failed\n");
return;
}

status = 0;

printf("Initialize platform complete\n");
}

void HW_Kernel::initialize_kernel(const char *xclbin, const char *kernel_name, int memory_size) {
Expand All @@ -160,18 +206,19 @@ void HW_Kernel::initialize_kernel(const char *xclbin, const char *kernel_name, i
//------------------------------------------------------------------------------
// xclbin
//------------------------------------------------------------------------------
printf("INFO: loading xclbin %s\n", xclbin);
int n_i0 = load_file_to_memory(xclbin, (char **) &kernelbinary);
printf("INFO: Loading xclbin %s\n", xclbin);
cl_uint n_i0 = load_file_to_memory(xclbin, (char **) &kernelbinary);
if (n_i0 < 0) {
perror("Error: Failed to load kernel from the xclbin provided\nTest failed\n");
return;
}
size_t n0 = n_i0;

printf("CL Start create Program\n");
// Create the compute program from offline
program = clCreateProgramWithBinary(context, 1, &device_id, &n0,
(const unsigned char **) &kernelbinary, &status, &err);
// TODO: Looks like kernelbinary is never deallocated. What's the right behavior, here?
free(kernelbinary);

if ((!program) || (err!=CL_SUCCESS)) {
perror("Error: Failed to create a compute program binary!\nTest failed\n");
Expand All @@ -194,6 +241,7 @@ void HW_Kernel::initialize_kernel(const char *xclbin, const char *kernel_name, i

// Create the compute kernel in the program we wish to run
kernel = clCreateKernel(program, kernel_name, &err);
printf("CL created kernel");
if (!kernel || err != CL_SUCCESS) {
perror("Error: Failed to create a compute kernel!\nTest failed\n");
return;
Expand All @@ -215,6 +263,8 @@ void HW_Kernel::initialize_kernel(const char *xclbin, const char *kernel_name, i
}

status = 0;

printf("Initialize kernel complete\n");
}

void HW_Kernel::write_kernel_data(double h_a_input[], int data_size){
Expand Down Expand Up @@ -289,7 +339,15 @@ void HW_Kernel::write_kernel_data(input_struct * input, int data_size) {

void HW_Kernel::start_kernel() {
int err;
err = clEnqueueTask(commands, kernel, 0, NULL, NULL);
// Global and Local variables for CLEnqueue and Range Kernel Call
size_t global[1];
size_t local[1];
// Execute the kernel over the entire range of our 1d input data set
// using the maximum number of work group items for this device

global[0] = 1;
local[0] = 1;
err = clEnqueueNDRangeKernel(commands, kernel, 1, NULL, (size_t*)&global, (size_t*)&local, 0, NULL, NULL);
if (err) {
perror("Error: Failed to execute kernel!\nTest failed\n");
return;
Expand Down
Loading