Skip to content

Commit 515844a

Browse files
zakn-amdeddieh-xlnxclavin-xlnx
authored
Alpha submission (Xilinx#48)
* Alpha submission infrastructure and documentation Signed-off-by: Zak Nafziger <[email protected]> * fix various minor typos Co-authored-by: eddieh-xlnx <[email protected]> * Combine SHELL and update comment Signed-off-by: Eddie Hung <[email protected]> * Run test-container with GitHub Actions Signed-off-by: Eddie Hung <[email protected]> * Update .github/workflows/test-container.yml * fix typos in docs/alpha_submission Co-authored-by: Chris Lavin <[email protected]> * Link to alpha_submission.html Signed-off-by: Eddie Hung <[email protected]> * small wording change * Update docs/alpha_submission.md --------- Signed-off-by: Zak Nafziger <[email protected]> Signed-off-by: Eddie Hung <[email protected]> Co-authored-by: eddieh-xlnx <[email protected]> Co-authored-by: Chris Lavin <[email protected]>
1 parent 8e1b1db commit 515844a

File tree

9 files changed

+309
-8
lines changed

9 files changed

+309
-8
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Copyright (C) 2023, Advanced Micro Devices, Inc. All rights reserved.
2+
#
3+
# Author: Eddie Hung, AMD
4+
#
5+
# SPDX-License-Identifier: MIT
6+
#
7+
8+
name: test-container
9+
on:
10+
push:
11+
pull_request:
12+
jobs:
13+
test-container:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v3
17+
with:
18+
submodules: 'recursive'
19+
- name: Setup Apptainer
20+
env:
21+
APPTAINER_VERSION: '1.2.5'
22+
run: |
23+
wget https://github.com/apptainer/apptainer/releases/download/v${APPTAINER_VERSION}/apptainer_${APPTAINER_VERSION}_amd64.deb
24+
sudo dpkg -i apptainer_${APPTAINER_VERSION}_amd64.deb || true
25+
sudo apt-get -f install
26+
- run: |
27+
make test-container
28+
- uses: actions/upload-artifact@v3
29+
with:
30+
name: rwroute_container.sif
31+
path: |
32+
*.sif

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ build/
88
*.dcp
99
*.tcl
1010
*.wirelength
11+
*.sif
1112
wirelength_analyzer/test/data/
1213
**/__pycache__/

Makefile

Lines changed: 73 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
# SPDX-License-Identifier: MIT
66
#
77

8+
SHELL := /bin/bash -o pipefail
9+
810
# List of all benchmarks (default to all)
911
BENCHMARKS ?= boom_med_pb \
1012
vtr_mcml \
@@ -21,6 +23,14 @@ BENCHMARKS ?= boom_med_pb \
2123

2224
BENCHMARKS_URL = https://github.com/Xilinx/fpga24_routing_contest/releases/latest/download/benchmarks.tar.gz
2325

26+
# Inherit proxy settings from the host if they exist
27+
HTTPHOST=$(firstword $(subst :, ,$(subst http:,,$(subst /,,$(HTTP_PROXY)))))
28+
HTTPPORT=$(lastword $(subst :, ,$(subst http:,,$(subst /,,$(HTTP_PROXY)))))
29+
HTTPSHOST=$(firstword $(subst :, ,$(subst http:,,$(subst /,,$(HTTPS_PROXY)))))
30+
HTTPSPORT=$(lastword $(subst :, ,$(subst http:,,$(subst /,,$(HTTPS_PROXY)))))
31+
JAVA_PROXY=$(if $(HTTPHOST),-Dhttp.proxyHost=$(HTTPHOST) -Dhttp.proxyPort=$(HTTPPORT),) \
32+
$(if $(HTTPSHOST),-Dhttps.proxyHost=$(HTTPSHOST) -Dhttps.proxyPort=$(HTTPSPORT),)
33+
2434
# Choice of router (default to rwroute)
2535
# (other supported values: nxroute-poc)
2636
ROUTER ?= rwroute
@@ -33,7 +43,6 @@ export TIME=Wall-clock time (sec): %e
3343
VERBOSE ?= 0
3444
ifneq ($(VERBOSE), 0)
3545
log_and_or_display = 2>&1 | tee $(1)
36-
SHELL := /bin/bash -o pipefail
3746
else
3847
log_and_or_display = > $(1) 2>&1
3948
endif
@@ -46,20 +55,22 @@ else
4655
JVM_HEAP ?= -Xms32736m -Xmx32736m
4756
endif
4857

58+
export RAPIDWRIGHT_PATH = $(abspath RapidWright)
4959

5060
# Default recipe: route and score all given benchmarks
5161
.PHONY: run-$(ROUTER)
5262
run-$(ROUTER): score-$(ROUTER)
5363

54-
# Use Gradle to compile Java source code in this repository
55-
# as well as the RapidWright repository
64+
# Use Gradle to compile Java source code in this repository as well as the RapidWright repository.
65+
# Also download/generate all device files necessary for the xcvu3p device
5666
.PHONY: compile-java
5767
compile-java:
58-
./gradlew compileJava
68+
./gradlew $(JAVA_PROXY) compileJava
69+
_JAVA_OPTIONS="$(JAVA_PROXY)" RapidWright/bin/rapidwright Jython -c "FileTools.ensureDataFilesAreStaticInstallFriendly('xcvu3p')"
5970

6071
.PHONY: install-python-deps
6172
install-python-deps:
62-
pip install -q -r requirements.txt --pre
73+
pip install -q -r requirements.txt --pre --user
6374

6475
# Download and unpack all benchmarks
6576
.PHONY: download-benchmarks
@@ -106,7 +117,7 @@ score-$(ROUTER): $(foreach b,$(BENCHMARKS),$b_$(ROUTER).wirelength $b_$(ROUTER).
106117
setup-net_printer setup-wirelength_analyzer: | install-python-deps fpga-interchange-schema/interchange/capnp/java.capnp
107118

108119
clean:
109-
rm -f *.{phys,check,wirelength}*
120+
rm -f *.{phys,check,wirelength,sif}*
110121

111122
distclean: clean
112123
rm -rf *.device *_unrouted.phys *.netlist*
@@ -131,5 +142,61 @@ distclean: clean
131142

132143
#### END ROUTER RECIPES
133144

145+
#### BEGIN CONTEST SUBMISSION RECIPES
146+
147+
# Required Apptainer args:
148+
# --pid: ensures all processes apptainer spawns are killed with the container
149+
# --home `pwd`: overrides the home directory inside the container to be the current dir
150+
APPTAINER_RUN_ARGS = --pid --home `pwd`
151+
ifneq ($(wildcard /tools),)
152+
# Creates a read-only mount of the host system's `/tools` directory to the container's
153+
# /tools` directory, which allows the container to access the host Vivado installation
154+
APPTAINER_RUN_ARGS += --mount src=/tools/,dst=/tools/,ro
155+
endif
156+
157+
# Default Apptainer args. Contestants may modify as necessary.
158+
# --rocm --bind /etc/OpenCL: enables OpenCL access in the container
159+
APPTAINER_RUN_ARGS += --rocm
160+
ifneq ($(wildcard /etc/OpenCL),)
161+
APPTAINER_RUN_ARGS += --bind /etc/OpenCL
162+
endif
163+
164+
# Build an Apptainer image from a definition file in the alpha_submission directory
165+
%_container.sif: alpha_submission/%_container.def
166+
apptainer build $@ $<
167+
168+
# Use the <ROUTER>_container.sif Apptainer image to run all benchmarks
169+
.PHONY: run-container
170+
run-container: $(ROUTER)_container.sif
171+
apptainer run $(APPTAINER_RUN_ARGS) $< make ROUTER="$(ROUTER)" BENCHMARKS="$(BENCHMARKS)" VERBOSE="$(VERBOSE)"
172+
173+
# Use the <ROUTER>_container.sif Apptainer image to run a single small benchmark for testing
174+
.PHONY: test-container
175+
test-container: $(ROUTER)_container.sif
176+
apptainer run $(APPTAINER_RUN_ARGS) $< make ROUTER="$(ROUTER)" BENCHMARKS="boom_med_pb" VERBOSE="$(VERBOSE)"
177+
178+
SUBMISSION_NAME = $(ROUTER)_submission_$(shell date +%Y%m%d%H%M%S)
179+
180+
# distclean the repo and create an archive ready for submission
181+
# Submission name is <ROUTER NAME>_submission_<timestamp>
182+
.PHONY: distclean-and-package-submission
183+
distclean-and-package-submission: distclean
184+
tar -czf ../$(SUBMISSION_NAME).tar.gz .
185+
mv ../$(SUBMISSION_NAME).tar.gz .
186+
187+
#### END CONTEST SUBMISSION RECIPES
188+
189+
#### BEGIN EXAMPLE RECIPES
190+
191+
# Build and run an example OpenCL application in an Apptainer container
192+
opencl_example_container.sif: alpha_submission/opencl_example/opencl_example_container.def
193+
apptainer build $@ $<
194+
195+
.PHONY: run-opencl-example
196+
run-opencl-example: opencl_example_container.sif
197+
apptainer run $(APPTAINER_RUN_ARGS) $<
198+
199+
#### END EXAMPLE RECIPES
200+
134201
# Tell make to not treat routed results as intermediate files (which would get deleted)
135202
.PRECIOUS: %_$(ROUTER).phys

alpha_submission/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Alpha Submission Containers
2+
3+
This directory contains example [Apptainer](https://apptainer.org/docs/user/latest/)
4+
definition files that show how to containerize a router for submission.
5+
Contestants not building on top of RWRoute are required to provide a new file named `<router_name>_container.def`
6+
builds the environment for running their router.
7+
8+
For further details on the alpha submission please refer to
9+
[this webpage](https://xilinx.github.io/fpga24_routing_contest/alpha_submission.html).
10+
11+
The contents of this directory are as follows:
12+
13+
* `rwroute_container.def` -- an example Apptainer definition file for `rwroute`
14+
* `nxroute-poc_container.def` -- an example Apptainer definition file for `nxroute-poc` (this is actually a link to `rwroute_container.def` since both routers require an identical environment)
15+
* `opencl_example/opencl_example_container.def` -- an example Apptainer definition file for a C++/OpenCL "Hello World" application
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rwroute_container.def
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
BootStrap: docker
2+
From: ubuntu:20.04
3+
4+
%post
5+
apt-get -y update
6+
apt-get -y install ocl-icd-libopencl1 ocl-icd-opencl-dev opencl-headers git build-essential
7+
git clone https://github.com/cqcallaw/ocl-samples.git
8+
cd /ocl-samples
9+
make
10+
11+
%runscript
12+
cd /ocl-samples/
13+
./hello
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
BootStrap: docker
2+
From: eclipse-temurin:17 # Base image with Java VM 17 on Ubuntu
3+
4+
%post
5+
# Install remaining system dependencies
6+
apt-get -y update
7+
apt-get -y install git python3 pip pkg-config libcapnp-dev time libtinfo5
8+
# Create a mount point for Vivado
9+
mkdir /tools
10+
11+
%environment
12+
# Add the host Vivado to the path
13+
export PATH=$PATH:/tools/Xilinx/Vivado/2022.2/bin/

docs/alpha_submission.md

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
# Alpha Submission
2+
3+
In order to ensure that the contest environment is able to support all router
4+
entries ahead of the final submission deadline, a mandatory step for continued
5+
participation in the contest is the submission of an early "alpha" release.
6+
The performance of this alpha submission will have **zero** effect on the
7+
final submission score; instead, the organizers will endeavour to work with
8+
contestants to ensure that the runtime environment is as desired.
9+
Contestants will receive private feedback from the organizers assessing the
10+
performance of just their router on the released benchmark suite (plus a hidden
11+
benchmark) when run on contest hardware.
12+
13+
## Key Details
14+
15+
* Alpha submission is mandatory for continued participation in the contest
16+
* Performance of alpha submissions will be shared privately with contestants and will not impact the final score
17+
* Alpha submissions will be evaluated on [AMD Heterogeneous Compute Cluster (HACC)](https://www.amd-haccs.io/) hardware
18+
* Contestants are required to use [Apptainer](https://apptainer.org/docs/user/latest/) to containerize their submission (details below)
19+
20+
## Runtime Environment
21+
22+
Aside from running under Linux without network access, no restrictions are
23+
placed on the languages, software dependencies, or runtime environment that
24+
contestants may use to implement their router. In order to enable this platform
25+
independence, contestants must containerize their router and runtime environment
26+
with the [Apptainer](https://apptainer.org/docs/user/latest/) framework.
27+
28+
### Apptainer
29+
30+
From the [Apptainer documentation](https://apptainer.org/docs/user/latest/introduction.html):
31+
> Apptainer is a container platform. It allows you to create and run containers that package up pieces of software in a way that is portable and reproducible. You can build a container using Apptainer on your laptop, and then run it on many of the largest HPC clusters in the world, local university or company clusters, a single server, in the cloud, or on a workstation down the hall. Your container is a single file, and you don’t have to worry about how to install all the software you need on each different operating system.
32+
33+
Apptainer containers may be described with a `*.def`
34+
[definition file](https://apptainer.org/docs/user/latest/definition_files.html)
35+
that specifies the base operating system image, and any further customisations
36+
(such as library installations) required to support an application. A
37+
definition file can then be compiled into an executable `*.sif` image which
38+
allows the application to be run in an isolated environment.
39+
40+
The [contest repository](https://github.com/Xilinx/fpga24_routing_contest/)
41+
has been updated with example `*.def` files in the `alpha_submission` directory
42+
for both `rwroute` and `nxroute-poc`. To build and run the default container
43+
(which on a fresh clone would be `rwroute`) one would just run:
44+
45+
```
46+
make run-container
47+
```
48+
49+
This is roughly equivalent to:
50+
```
51+
apptainer build rwroute_container.sif alpha_submission/rwroute_container.def
52+
apptainer run --pid --home `pwd` --rocm --bind /etc/OpenCL --mount src=/tools/,dst=/tools/,ro rwroute_container.sif make
53+
```
54+
55+
The `apptainer build` command creates an image from the `rwroute_container.def`
56+
definition, and the `apptainer run` command runs this image. The Apptainer
57+
command line options do the following:
58+
59+
* `--pid` runs the container in a new process ID namespace to ensure processes
60+
spawned by the container are not orphaned if the container is killed.
61+
* ``--home `pwd` `` sets the container home directory to be the current directory
62+
* `--rocm --bind /etc/OpenCL` configures [GPU Access](alpha_submission.md#gpu-access)
63+
* `--mount ...` creates a read-only mount of the host system's `/tools`
64+
directory to the container's `/tools` directory, which allows the container to
65+
access the host Vivado installation.
66+
67+
The remainder of the Apptainer command line simply runs the default make target from inside the
68+
container.
69+
70+
Finally, in order to aid in development the Makefile target:
71+
72+
```
73+
make test-container
74+
```
75+
76+
has also been provided. This target is identical to the `run-container` target,
77+
except that results are only collected for the `boom_med_pb` benchmark, instead
78+
of collecting results for every benchmark. This allows contestants to quickly
79+
test their Apptainer flow and avoid overloading shared resources should they
80+
be working on a shared cluster.
81+
82+
For further information about working with Apptainer containers please refer to
83+
[the user documentation](https://apptainer.org/docs/user/latest/introduction.html).
84+
85+
### GPU Access
86+
87+
It is possible to access AMD GPU resources on the host from an Apptainer
88+
container. The directory `alpha_submission/opencl_example` contains a sample
89+
`*.def` file that builds a [C++/OpenCL "Hello World" example](https://github.com/cqcallaw/ocl-samples).
90+
To run this example:
91+
92+
```
93+
make run-opencl-example
94+
```
95+
96+
This `make` target builds a `*.sif` image from the
97+
`opencl_example_container.def` definition file and runs it with the command:
98+
99+
```
100+
apptainer run --pid --home `pwd` --rocm --bind /etc/OpenCL opencl_example_container.sif
101+
```
102+
103+
The `--rocm` switch enables AMD ROCm support in the container. The
104+
`--bind /etc/OpenCL` switch mounts the host OpenCL directory in the container,
105+
which is required to allow the containerized OpenCL stack to discover the host
106+
resources.
107+
108+
Please note that contestants are free to use GPU interfaces other than OpenCL,
109+
such as [AMD HIP](https://github.com/ROCm-Developer-Tools/HIP).
110+
111+
## Submission Format
112+
113+
Contestants are required to submit a clone of the contest
114+
repository which has been modified to run their router in Apptainer.
115+
Specifically, organizers must be able to run the submitted router by calling only
116+
the `make run-container` target. By default, in a fresh checkout of the contest
117+
repository, this target will run `rwroute` in an Apptainer container.
118+
Thus in addition to their router contestants must supply a custom `*.def` file
119+
in the `alpha_submission` directory, as well as a Makefile that has been
120+
modified to run their router by default. To set the default router in the
121+
Makefile contestants must change the value of the `ROUTER` variable from
122+
`rwroute` to the name of their router.
123+
124+
Starting from a clone of the contest repository that has already had its
125+
Makefile `ROUTER` variable modified such that `make` invokes the contestant
126+
router, one would just execute:
127+
128+
```
129+
make distclean-and-package-submission
130+
```
131+
132+
Which generates a submission artifact named
133+
`<router_name>_submission_<timestamp>.tar.gz` in the current directory.
134+
Internally, this executes the following commands:
135+
136+
```
137+
make distclean
138+
tar -czf ../<router_name>_submission_<timestamp>.tar.gz.tar.gz .
139+
mv ../<router_name>_submission_<timestamp>.tar.gz.tar.gz .
140+
```
141+
142+
Note that `make distclean` will delete all unrouted design files, routed
143+
results and logs, as well as the device description. The organizers will then
144+
evaluate the artifact with a process similar to the following:
145+
146+
```
147+
mkdir <router_name>_alpha_submission
148+
cd <router_name>_alpha_submission
149+
tar -xvf <router_name>_submission_<timestamp>.tar.gz
150+
make run-container
151+
```
152+
153+
### Closed-Source Submissions
154+
155+
While contestants are strongly encouraged to open-source their solutions at the
156+
conclusion of the contest, there is no requirement to do so. In such cases,
157+
it is still necessary to use the flow described above to produce a binary only
158+
submission. That is, any precompiled router must still work inside Apptainer
159+
and be invoke-able using `make run-container` on the contest hardware.

docs/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Given a pre-placed design in the [FPGA Interchange Format](http://www.rapidwrigh
66
and a multi-core machine with an AMD GPU, build a router that focuses on minimizing the wall-clock time required to return
77
a legal, fully routed solution.
88

9-
| ℹ️ **NOTE:** | [Registration](#registration) deadline extended to 20 November 2023 |
9+
| ℹ️ **NOTE:** | [Alpha Submission](alpha_submission.html) deadline is 20 December 2023 |
1010
| - | - |
1111

1212
## Introduction
@@ -58,7 +58,7 @@ More information can be found in [Contest Details](details.html).
5858
|-----------------|-------|
5959
|September 2023 | Contest Announced |
6060
|~20 October 2023~<br>**EXTENDED 20 November 2023**| Registration Deadline ([mandatory, see below](#registration))|
61-
|20 December 2023 | Alpha Submission (details to be announced)|
61+
|20 December 2023 | Alpha Submission ([details](alpha_submission.html))|
6262
|31 January 2024 | Final Submission (details to be announced)|
6363
|3-5 March 2024 | Prizes awarded to top 5 teams at [FPGA 2024 conference](https://www.isfpga.org/)|
6464

0 commit comments

Comments
 (0)