Skip to content
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

Co-simulation in pb-flow #7

Merged
merged 33 commits into from
May 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
6d8b75e
Added initial Dockerfile for Phism
May 10, 2021
4062876
Added test command for polybench
May 10, 2021
4736125
Added docker instructions to README.md
May 10, 2021
b31dc72
Added required package for Vitis HLS
May 10, 2021
4c8ff31
Format
May 10, 2021
c1b46a9
Added initial template for cosim script in pb-flow
May 11, 2021
3ab8afb
Added script for co-simulations - results unverified
May 12, 2021
cce1984
Updated cosim script
May 13, 2021
676cb35
Updated docs and scripts
kumasento May 10, 2021
08da29d
Updated CI script to use the latest build script
kumasento May 10, 2021
f43260b
Self host workflow (#6)
kumasento May 10, 2021
0661ca9
Try out self-hosted workflow
kumasento May 10, 2021
d79a043
Reverted libclang prefix configure
kumasento May 10, 2021
91e6480
Improved the README a bit
kumasento May 12, 2021
38059ca
Ignore debug directories
kumasento May 13, 2021
3bf5a77
Added docker instructions to README.md
May 10, 2021
34e4306
New DOCKER doc
kumasento May 13, 2021
9ea494c
Refactorized pb-flow with getopts
kumasento May 13, 2021
8f9b469
Added LD_LIBRARY_PATH into Dockerfile
May 13, 2021
e7e49ab
Updated Makefile with the latest pb-flow options
May 13, 2021
efb74ed
Fixed path error for utilities
kumasento May 14, 2021
cc39e82
Renamed GitHub workflow
kumasento May 14, 2021
3d40a01
Updated docs and scripts
kumasento May 10, 2021
5e2b2a5
Merge branch 'main' of github.com:kumasento/phism into cosim
kumasento May 14, 2021
1e97886
Add synth & cosim to CI
kumasento May 14, 2021
8e8c3ba
Fixed llvm hash problem
kumasento May 14, 2021
4e75276
Fixed a typo in path
kumasento May 14, 2021
f679e1e
Ask to build locally instead of /tmp
kumasento May 14, 2021
3202223
README updated, removed cosim in CI
kumasento May 15, 2021
f99a111
Removed workflow MD5 from LLVM cache
kumasento May 15, 2021
7f82b17
Add constant propagation to fix loop bounds
kumasento May 15, 2021
113249f
Added Ninja detection and fixed CC/CXX issue
kumasento May 15, 2021
8556859
Fixed various Polygeist issues
kumasento May 17, 2021
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This is a basic workflow to help you get started with Actions

name: Build and Test
name: Self-hosted Build and Test

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
Expand Down Expand Up @@ -34,18 +34,13 @@ jobs:
run: clang --version
shell: bash

- name: Get workflow spec hash
id: get-workflow-hash
run: echo "::set-output name=hash::$(md5sum $GITHUB_WORKSPACE/.github/workflows/buildAndTest.yml)"
shell: bash

# Try to fetch LLVM from the cache.
- name: Cache LLVM
id: cache-llvm
uses: actions/cache@v2
with:
path: llvm/build
key: ${{ runner.os }}-llvm-${{ steps.get-llvm-hash.outputs.hash }}-${{ steps.get-workflow-hash.outputs.hash }}
key: ${{ runner.os }}-llvm-${{ steps.get-llvm-hash.outputs.hash }}

# Build LLVM if we didn't hit in the cache.
- name: Rebuild and Install LLVM
Expand All @@ -60,22 +55,10 @@ jobs:

# Build Phism and run its tests.
build-phism:
name: Build and Test Phism
name: Build Phism
needs: build-llvm
runs-on: self-hosted
steps:
# - name: Configure Environment
# run: echo "${GITHUB_WORKSPACE}/llvm/install/bin" >> $GITHUB_PATH
# - name: Get dependences
# run: |
# sudo apt-get update -y
# sudo apt-get install -y build-essential libtool autoconf pkg-config flex bison libgmp-dev clang-9 libclang-9-dev texinfo
# - name: Update the LLVM/Clang version to 9
# run: |
# sudo update-alternatives --install /usr/bin/llvm-config llvm-config /usr/bin/llvm-config-9 100
# sudo update-alternatives --install /usr/bin/FileCheck FileCheck /usr/bin/FileCheck-9 100


# Clone the Phism repo and its submodules. Do shallow clone to save clone
# time.
- name: Get Phism
Expand All @@ -93,18 +76,13 @@ jobs:
run: echo "::set-output name=hash::$(git rev-parse @:./llvm)"
shell: bash

- name: Get workflow spec hash
id: get-workflow-hash
run: echo "::set-output name=hash::$(md5sum $GITHUB_WORKSPACE/.github/workflows/buildAndTest.yml)"
shell: bash

# Try to fetch LLVM from the cache.
- name: Cache LLVM
id: cache-llvm
uses: actions/cache@v2
with:
path: llvm/build
key: ${{ runner.os }}-llvm-${{ steps.get-llvm-hash.outputs.hash }}-${{ steps.get-workflow-hash.outputs.hash }}
key: ${{ runner.os }}-llvm-${{ steps.get-llvm-hash.outputs.hash }}

# Build LLVM if we didn't hit in the cache. Even though we build it in
# the previous job, there is a low chance that it'll have been evicted by
Expand All @@ -115,9 +93,8 @@ jobs:
./scripts/build-llvm.sh ci

# --------
# Build and test Phism in both debug and release mode.
# Build Phism in debug mode.
# --------
- name: Build and Test Phism (Assert)
- name: Build Phism
run: |
./scripts/build-phism.sh ci

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,6 @@ build/

# Editor
.vscode/

# Temporary output
/tmp*
33 changes: 33 additions & 0 deletions Docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
FROM ubuntu:20.04
ARG GID
ARG UID
RUN echo "Group ID: $GID"
RUN echo "User ID: $UID"

USER root
RUN apt-get update
RUN DEBIAN_FRONTEND="noninteractive" apt-get -y install tzdata --assume-yes

# Install Essential Packages
RUN apt-get update
RUN apt-get install build-essential libtool autoconf pkg-config flex bison libgmp-dev clang-9 libclang-9-dev texinfo cmake vim ninja-build git libncurses5 gcc-multilib --assume-yes

RUN update-alternatives --install /usr/bin/llvm-config llvm-config /usr/bin/llvm-config-9 100
RUN update-alternatives --install /usr/bin/FileCheck FileCheck /usr/bin/FileCheck-9 100
RUN update-alternatives --install /usr/bin/clang clang /usr/bin/clang-9 100
RUN update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-9 100

CMD ["bash"]

RUN apt-get install sudo --assume-yes

# Add dev-user
RUN groupadd -g $GID dev-user
RUN useradd -r -g $GID -u $UID -m -d /home/dev-user -s /sbin/nologin -c "User" dev-user
RUN echo "dev-user ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
USER dev-user

RUN echo 'PATH=$PATH:/workspace/llvm/build/bin:/workspace/build/bin:/tools/Vitis_HLS/2020.2/bin' >> /home/dev-user/.bashrc
RUN echo 'export LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:$LIBRARY_PATH' >> /home/dev-user/.bashrc
RUN echo 'export LD_LIBRARY_PATH=""' >> /home/dev-user/.bashrc
WORKDIR workspace
66 changes: 66 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
user=$(if $(shell id -u),$(shell id -u),9001)
group=$(if $(shell id -g),$(shell id -g),1000)
phism=/workspace
vhls=~/tools/Xilinx/2020.2

# Build Phism
build-docker: test-docker
docker run -it -v $(shell pwd):/workspace -v $(vhls):/tools phism20:latest /bin/bash \
-c "make build_"
echo "Phism has been installed successfully!"

# Clone submodule and build docker container
test-docker:
git submodule update --init --recursive
(cd Docker; docker build --no-cache --build-arg UID=$(user) --build-arg GID=$(group) . --tag phism20)

# Enter docker container
shell:
docker run -it -v $(shell pwd):/workspace -v $(vhls):/tools phism20:latest /bin/bash

# Evaluate polybench (baseline) - need to be used in environment
test-polybench:
./scripts/pb-flow ./example/polybench -c COSIM 2>&1 | tee phism-test.log

# Evaluate polybench (polymer) - need to be used in environment
test-polybench-polymer:
./scripts/pb-flow ./example/polybench -p USE POLYMER -c COSIM 2>&1 | tee phism-test.log

# Build LLVM and Phism
build_:
set -e # Abort if one of the commands fail
mkdir -p $(phism)/llvm/build
(cd $(phism)/llvm/build; \
cmake ../llvm \
-DCMAKE_C_COMPILER=gcc \
-DCMAKE_CXX_COMPILER=g++ \
-DLLVM_ENABLE_PROJECTS="mlir;llvm;clang;clang-extra-tools" \
-DCMAKE_BUILD_TYPE=DEBUG \
-DLLVM_BUILD_EXAMPLES=OFF \
-DLLVM_TARGETS_TO_BUILD="host" \
-DLLVM_OPTIMIZED_TABLEGEN=ON \
-DLLVM_ENABLE_OCAMLDOC=OFF \
-DLLVM_ENABLE_BINDINGS=OFF \
-DLLVM_INSTALL_UTILS=ON \
-DBUILD_POLYMER=ON \
-DPLUTO_LIBCLANG_PREFIX=$(shell llvm-config-9 --prefix) \
-DLLVM_ENABLE_ASSERTIONS=ON; \
cmake --build . --target all -- -j 32)
mkdir -p $(phism)/build
(cd $(phism)/build; \
cmake .. \
-DCMAKE_BUILD_TYPE=Debug \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DMLIR_DIR=$(phism)/llvm/build/lib/cmake/mlir/ \
-DLLVM_DIR=$(phism)/llvm/build/lib/cmake/llvm/ \
-DCMAKE_C_COMPILER=clang-9 \
-DCMAKE_CXX_COMPILER=clang++-9 \
-DLLVM_EXTERNAL_LIT=$(phism)/llvm/build/bin/llvm-lit \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON; \
cmake --build . --target check-phism -- -j 32)

clean: clean_phism
rm -rf $(phism)/llvm/build

clean_phism:
rm -rf $(phism)/build
17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,19 @@ It should run the Phism regression test in the end. And if all the tests passed,

## Usage

[pb-flow](scripts/pb-flow) provides a CLI utility to test Phism with Polybench examples. You can grab a rough idea about the whole Phism pipeline over there.
### The `pb-flow` script

More usage info will be added later.
[pb-flow](scripts/pb-flow) provides a CLI utility to test Phism with Polybench examples. You can grab a rough idea about the whole Phism pipeline over there. You can use `pb-flow` in the following ways:

```sh
./scripts/pb-flow example/polybench # Run all polybench synth-only, w/o Polyhedral optimization.
./scripts/pb-flow example/polybench -p # Run all polybench synth-only, w/ Polyhedral optimization.
./scripts/pb-flow example/polybench -c # Run all polybench w/ cosim, w/ Polyhedral optimization.
./scripts/pb-flow example/polybench -pc # Run all polybench w/ cosim, w/o Polyhedral optimization.
```

If you attach `-d`, the build effort won't be set to `high`. This can save some time.

### Using Docker

This [doc](docs/DOCKER.md) gives an introduction on how to run Phism with docker.
25 changes: 25 additions & 0 deletions docs/DOCKER.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
Author: Jianyi Cheng
---

# Build with Docker

To build a Docker container with Phism installed:
```sh
make build-docker
```

To use Phism in the Docker container:
```
make shell vhls=${YOUR_VITIS_DIR}
```
PS: To check your `${YOUR_VITIS_DIR}`, you should see the following when run:
```
$ ls ${YOUR_VITIS_DIR}
DocNav Model_Composer Vitis Vitis_HLS Vivado xic
```

For instance, to run Polybench:
```
make test-polybench
```
2 changes: 1 addition & 1 deletion llvm
15 changes: 12 additions & 3 deletions scripts/build-llvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ echo ""

TARGET="${1:-"local"}"

# If ninja is available, use it.
CMAKE_GENERATOR="Unix Makefiles"
if which ninja &>/dev/null; then
CMAKE_GENERATOR="Ninja"
fi

# The absolute path to the directory of this script.
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"

Expand All @@ -30,8 +36,10 @@ mkdir -p build
cd build

# Configure CMake
CC=gcc CXX=g++ cmake ../llvm \
-DLLVM_ENABLE_PROJECTS="mlir;llvm;clang;clang-extra-tools" \
export CC=gcc
export CXX=g++
cmake ../llvm \
-DLLVM_ENABLE_PROJECTS="mlir;llvm;clang" \
-DCMAKE_BUILD_TYPE=RELEASE \
-DLLVM_BUILD_EXAMPLES=OFF \
-DLLVM_TARGETS_TO_BUILD="host" \
Expand All @@ -41,7 +49,8 @@ CC=gcc CXX=g++ cmake ../llvm \
-DLLVM_INSTALL_UTILS=ON \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DBUILD_POLYMER=ON \
-DPLUTO_LIBCLANG_PREFIX="$(llvm-config --prefix)"
-DPLUTO_LIBCLANG_PREFIX="$(llvm-config --prefix)" \
-G "${CMAKE_GENERATOR}"

# Run building
cmake --build . --target all -- -j "$(nproc)"
Expand Down
Loading