diff --git a/Docker/Dockerfile b/Docker/Dockerfile index 3698e20a082..6cdfcd3834a 100644 --- a/Docker/Dockerfile +++ b/Docker/Dockerfile @@ -1,33 +1,61 @@ -FROM ubuntu:20.04 -ARG GID +FROM centos:centos8 +ARG VHLS_PATH ARG UID -RUN echo "Group ID: $GID" -RUN echo "User ID: $UID" +ARG GID 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 +# Basic packages +RUN dnf update -y +RUN dnf install -y gcc-c++ sudo vim openssh-clients \ + wget curl-devel expat-devel gettext-devel zlib-devel \ + perl-CPAN perl-devel git -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 +# Vitis HLS dependences +RUN dnf install -y libXext libXrender libXtst gettext libtool \ + rpm-sign autoconf automake binutils bison \ + flex make patch pkgconfig redhat-rpm-config \ + rpm-build ncurses-compat-libs +RUN dnf install -y https://extras.getpagespeed.com/release-el8-latest.rpm +RUN dnf install -y gperftools gperftools-devel -CMD ["bash"] +# Phism dependences +RUN dnf install -y llvm clang python3 gmp-devel pcre-devel \ + openssl openssl-devel llvm-devel +RUN dnf --enablerepo=powertools install texinfo -y +RUN python3 -m pip install pandas +# build the following packages from source: +RUN mkdir -p /dkrPkgs +# cmake 3.20 +RUN cd /dkrPkgs \ + && wget https://github.com/Kitware/CMake/releases/download/v3.20.3/cmake-3.20.3.tar.gz \ + && tar zxvf cmake-3.20.3.tar.gz \ + && cd cmake-3.20.3 \ + && ./bootstrap --prefix=/usr/local \ + && make -j $(grep -c ^processor /proc/cpuinfo) \ + && make install -RUN apt-get install sudo --assume-yes +CMD ["bash"] # Add dev-user -RUN groupadd -g $GID dev-user +RUN getent group $GID || 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 +# Add environment variables +# Vitis HLS setup 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 +ENV vhls $VHLS_PATH +RUN echo "source ${vhls}/Vitis_HLS/2020.2/settings64.sh" >> /home/dev-user/.bashrc +RUN echo 'source /workspace/scripts/setup-vitis-hls-llvm.sh' >> /home/dev-user/.bashrc +# PATH +RUN echo 'export PATH=$PATH:/workspace/llvm/build/bin:/workspace/build/bin' >> /home/dev-user/.bashrc +# Thread setup +RUN echo 'export nproc=$(grep -c ^processor /proc/cpuinfo)' >> /home/dev-user/.bashrc +# Evaluation script path: +RUN echo 'export PYTHONPATH=/workspace' >> /home/dev-user/.bashrc + WORKDIR workspace + diff --git a/Makefile b/Makefile index e5645732c16..997be8a7da8 100644 --- a/Makefile +++ b/Makefile @@ -1,66 +1,44 @@ 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 +vhls=/tools/Xilinx/2020.2 +th=1 # Build Phism build-docker: test-docker - docker run -it -v $(shell pwd):/workspace -v $(vhls):/tools phism20:latest /bin/bash \ - -c "make build_" + docker run -it -v $(shell pwd):/workspace -v $(vhls):$(vhls) phism8:latest /bin/bash \ + -c "make build-phism" echo "Phism has been installed successfully!" -# Clone submodule and build docker container +# 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) + (cd Docker; docker build --build-arg UID=$(user) --build-arg GID=$(group) --build-arg VHLS_PATH=$(vhls) . --tag phism8) # Enter docker container shell: - docker run -it -v $(shell pwd):/workspace -v $(vhls):/tools phism20:latest /bin/bash + docker run -it -v $(shell pwd):/workspace -v $(vhls):$(vhls) phism8: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 + python3 scripts/pb-flow.py -c -j $(th) example/polybench # 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 + python3 scripts/pb-flow.py -c -p -j $(th) example/polybench # 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) +build-phism: + source scripts/setup-vitis-hls-llvm.sh + ./scripts/build-llvm.sh + ./scripts/build-phism.sh + +# Sync and update submodules +sync: + git submodule sync + git submodule update --init --recursive -clean: clean_phism +clean: clean-phism rm -rf $(phism)/llvm/build -clean_phism: +clean-phism: rm -rf $(phism)/build diff --git a/docs/DOCKER.md b/docs/DOCKER.md index a2b89db231d..df5b461b5da 100644 --- a/docs/DOCKER.md +++ b/docs/DOCKER.md @@ -6,12 +6,8 @@ Author: Jianyi Cheng 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} +make sync +make build-docker vhls=${YOUR_VITIS_DIR} ``` PS: To check your `${YOUR_VITIS_DIR}`, you should see the following when run: ``` @@ -19,7 +15,13 @@ $ ls ${YOUR_VITIS_DIR} DocNav Model_Composer Vitis Vitis_HLS Vivado xic ``` +To use Phism in the Docker container: +``` +make shell vhls=${YOUR_VITIS_DIR} +``` + For instance, to run Polybench: ``` +# In the docker container: make test-polybench ``` diff --git a/scripts/pb-flow.py b/scripts/pb-flow.py index 54a43f4b907..dddade09472 100755 --- a/scripts/pb-flow.py +++ b/scripts/pb-flow.py @@ -1,5 +1,9 @@ #!/usr/bin/env python3 # A python version of the old pb-flow. Should be way faster with parallelism! +# +# USE: cd $PHSIM \ +# && PYTHONPATH=$PWD \ +# && python3 scripts/pb-flow.py -c example/polybench import subprocess import os diff --git a/scripts/pb-report.py b/scripts/pb-report.py index 53454e82a4a..8c7bdf9f334 100755 --- a/scripts/pb-report.py +++ b/scripts/pb-report.py @@ -1,5 +1,9 @@ #!/usr/bin/env python3 # Summarize the results from pb-flow runs. +# +# USE: cd $PHISM \ +# && PYTHONPATH=$PWD \ +# && python3 scripts/pb-report.py tmp/phism/pb-flow.20210608-235502 import os import argparse