├── root ├── usr │ └── local │ │ └── src │ │ ├── dot.profile │ │ └── dot.bashrc └── etc │ ├── services.d │ └── jupyter-notebook │ │ └── run │ └── cont-init.d │ └── 10-adduser ├── .dockerignore ├── .gitignore ├── src └── README │ ├── readme_example_repos.md │ └── readme.md ├── cacti.patch ├── LICENSE ├── docker-compose.yaml ├── README-WSL.md ├── .gitmodules ├── docker-entrypoint.sh ├── README.md ├── Makefile └── Dockerfile /root/usr/local/src/dot.profile: -------------------------------------------------------------------------------- 1 | source $HOME/.bashrc 2 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | .git 2 | .gitignore 3 | Dockerfile* 4 | docker-compose* 5 | README.md 6 | LICENSE 7 | .vscode 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore emacs backup files 2 | 3 | *~ 4 | \#*\# 5 | 6 | # Ignore .nfs temp file 7 | 8 | .nfs* 9 | 10 | # Application-specific ignores 11 | 12 | -------------------------------------------------------------------------------- /root/usr/local/src/dot.bashrc: -------------------------------------------------------------------------------- 1 | export PS1="docker% " 2 | export TIMELOOP_ACCURATE_READS_WITU=1 3 | export JUPYTER_RUNTIME_DIR="/tmp" 4 | export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib 5 | -------------------------------------------------------------------------------- /src/README/readme_example_repos.md: -------------------------------------------------------------------------------- 1 | ## Example Repos 2 | - MICRO2019 Tutorial Examples: https://github.com/jsemer/timeloop-accelergy-exercises 3 | - contains example designs for timeloop, accelergy, and the combined system 4 | - Compute-in-Memory/Processing-in-Memory Examples: 5 | - contains example PIM DNN accelerator designs and it associated energy tables, which 6 | can be integrated to the system using the `accelergyTables` command (details in the readme of the repo) -------------------------------------------------------------------------------- /root/etc/services.d/jupyter-notebook/run: -------------------------------------------------------------------------------- 1 | #!/usr/bin/with-contenv bash 2 | 3 | UMASK_SET=${UMASK_SET:-022} 4 | umask "$UMASK_SET" 5 | 6 | # Set default environment variables 7 | source /usr/local/src/dot.bashrc 8 | 9 | # Set HOME/SHELL so the user jupyter notebook shell works 10 | export HOME=/home/workspace 11 | export SHELL=/bin/bash 12 | 13 | # Switch to user home directory 14 | cd $HOME 15 | 16 | echo "Starting Jupter Notebook." 17 | exec \ 18 | s6-setuidgid workspace \ 19 | /usr/local/bin/jupyter-lab --ip=0.0.0.0 --no-browser ${JUPYTER_SWITCHES} 20 | -------------------------------------------------------------------------------- /cacti.patch: -------------------------------------------------------------------------------- 1 | diff --git a/cacti.mk b/cacti.mk 2 | index b675d75..d7722e2 100644 3 | --- a/cacti.mk 4 | +++ b/cacti.mk 5 | @@ -13,7 +13,7 @@ INCS = -lm 6 | 7 | ifeq ($(TAG),dbg) 8 | DBG = -Wall 9 | - OPT = -ggdb -g -O0 -DNTHREADS=1 -gstabs+ 10 | + OPT = -ggdb -g -O0 -DNTHREADS=1 11 | else 12 | DBG = 13 | OPT = -g -msse2 -mfpmath=sse -DNTHREADS=$(NTHREADS) 14 | @@ -21,8 +21,8 @@ endif 15 | 16 | #CXXFLAGS = -Wall -Wno-unknown-pragmas -Winline $(DBG) $(OPT) 17 | CXXFLAGS = -Wno-unknown-pragmas $(DBG) $(OPT) 18 | -CXX = g++ -m64 19 | -CC = gcc -m64 20 | +CXX = g++ 21 | +CC = gcc 22 | 23 | SRCS = area.cc bank.cc mat.cc main.cc Ucache.cc io.cc technology.cc basic_circuit.cc parameter.cc \ 24 | decoder.cc component.cc uca.cc subarray.cc wire.cc htree2.cc extio.cc extio_technology.cc \ 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Joel Emer, Yannan Wu 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /docker-compose.yaml: -------------------------------------------------------------------------------- 1 | # 2 | # Docker-compose file for running timeloop/accelergy 3 | # 4 | # Notes: 5 | # The READMEs are put in ./workspace 6 | # The workspace will be owned by $USER_UID:$USER_GID 7 | # 8 | 9 | # Run as follows: 10 | # 11 | # 1) Put this file in an otherwise empty directory 12 | # 2) Change USER_UID and USER_GID to the desired owner of your files (echo $UID ) 13 | # 3) Cd to the directory containing this file 14 | # 4) Run the following command: 15 | # 16 | # % If you are using x86 CPU (Intel, AMD) 17 | # % DOCKER_ARCH=amd64 docker-compose run infrastructure 18 | # 19 | # % If you are using arm CPU (Apple M1/M2) 20 | # % DOCKER_ARCH=arm64 docker-compose run infrastructure 21 | # 22 | # % If you want to avoid typing "DOCKER_ARCH=" every time, 23 | # % "export DOCKER_ARCH=" >> ~/.bashrc && source ~/.bashrc 24 | # 25 | 26 | version: '3' 27 | 28 | services: 29 | infrastructure: 30 | hostname: accelergy-timeloop 31 | image: timeloopaccelergy/accelergy-timeloop-infrastructure:latest-${DOCKER_ARCH} 32 | volumes: 33 | - ./workspace:/home/workspace 34 | environment: 35 | - USER_UID=1000 36 | - USER_GID=1000 37 | stdin_open: true 38 | tty: true 39 | -------------------------------------------------------------------------------- /src/README/readme.md: -------------------------------------------------------------------------------- 1 | ## Accelergy-Timeloop Infrastructure 2 | This docker aims to provide an experimental environment for easy plug-and-play of examples that run on the accelergy-timeloop DNN accelerator evaluation infrastructure. 3 | 4 | ### System Setup 5 | Inside this docker you can find the source files of all necessary setups: 6 | - accelergy: the energy estimation backend 7 | - timeloop: the mapping exploration frontend 8 | - accelergy-cacti-plug-in: SRAM estimation plug-in 9 | - accelergy-aladdin-plug-in: 45nm component plug-in 10 | - accelergy-table-based-plug-in: entry point for creating your own table-based plug-ins 11 | They are already built/installed and ready to run! 12 | 13 | ### How to use the docker 14 | - Check if you can run the necessary commands below, i.e., you should not see `command not found` message 15 | - accelergy 16 | - accelergyTables 17 | - cacti 18 | - timeloop-mapper 19 | - timeloop-model 20 | 21 | - Get some examples running! 22 | - You can clone example repos that we provide to you to your docker folder (available example repos can be found in the example repo readme) 23 | - You can create your own models (if you already know the tools) 24 | 25 | Note, to skip this intro: 26 | ```touch ~/.nointro``` -------------------------------------------------------------------------------- /README-WSL.md: -------------------------------------------------------------------------------- 1 | Installation requirements 2 | 3 | ``` 4 | apt install python3 5 | 6 | apt install build-essential 7 | apt install scons 8 | 9 | apt install libncurses-dev 10 | apt install libgpm-dev 11 | apt install libconfig++-dev 12 | apt install libboost-dev 13 | apt install libboost-iostreams-dev 14 | apt install libboost-serialization-dev 15 | apt install libyaml-cpp-dev 16 | 17 | ``` 18 | 19 | Build procedure 20 | 21 | ``` 22 | git clone --recurse-submodules https://github.com/Accelergy-Project/accelergy-timeloop-infrastructure.git 23 | cd accelergy-timeloop-infrastructure 24 | 25 | cd src/cacti ; make ; cd .. 26 | cd accelergy-neurosim-plug-in ; make ; cd .. 27 | pip3 install ./accelergy 28 | pip3 install ./accelergy-aladdin-plug-in 29 | pip3 install ./accelergy-cacti-plug-in 30 | pip3 install ./accelergy-table-based-plug-ins 31 | pip3 install ./accelergy-neurosim-plug-in 32 | pip3 install ./accelergy-library-plug-in 33 | pip3 install ./accelergy-adc-plug-in 34 | cp -r ./cacti ~/.local/share/accelergy/estimation_plug_ins/accelergy-cacti-plug-in/ 35 | 36 | cd timeloop 37 | ln -s "$(pwd)/pat-public/src/pat" ./src 38 | scons --accelergy --static -j 16 39 | cp build/timeloop-* ~/.local/bin 40 | ``` 41 | 42 | Running locally 43 | 44 | ``` 45 | export PATH=~/.local/bin:$PATH 46 | cd src/timeloop-accelergy-exercises/exercise 47 | ``` 48 | -------------------------------------------------------------------------------- /root/etc/cont-init.d/10-adduser: -------------------------------------------------------------------------------- 1 | #!/usr/bin/with-contenv bash 2 | 3 | USER_UID=${USER_UID:-911} 4 | USER_GID=${USER_GID:-911} 5 | 6 | groupmod -o -g "$USER_GID" workspace 7 | usermod -o -u "$USER_UID" workspace 8 | 9 | # Copy in default .profile if not already there 10 | if [ ! -e /home/workspace/.profile ] 11 | then 12 | cp /usr/local/src/dot.profile /home/workspace/.profile 13 | chown $USER_UID:$USER_GID /home/workspace/.profile 14 | fi 15 | 16 | # Copy in default bashrc if not already there 17 | if [ ! -e /home/workspace/.bashrc ] 18 | then 19 | cp /usr/local/src/dot.bashrc /home/workspace/.bashrc 20 | chown $USER_UID:$USER_GID /home/workspace/.bashrc 21 | fi 22 | 23 | # Set default accelergy config file if there is no existing one 24 | if [ ! -e /home/workspace/.config/accelergy/accelergy_config.yaml ] 25 | then 26 | # create necessary directories 27 | if [ ! -e /home/workspace/.config ] 28 | then 29 | mkdir /home/workspace/.config 30 | fi 31 | # create necessary directories 32 | if [ ! -e /home/workspace/.config/accelergy ] 33 | then 34 | mkdir /home/workspace/.config/accelergy 35 | fi 36 | # infrastructure docker should already have the default config file ready in /usr/local/src 37 | cp /usr/local/src/accelergy_default_config.yaml /home/workspace/.config/accelergy/accelergy_config.yaml 38 | chown -R $USER_UID:$USER_GID /home/workspace/.config 39 | fi 40 | 41 | echo " 42 | ------------------------------------- 43 | User uid: $(id -u workspace) 44 | User gid: $(id -g workspace) 45 | ------------------------------------- 46 | " 47 | chown -R workspace:workspace /home/workspace 48 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "src/accelergy-table-based-plug-ins"] 2 | path = src/accelergy-table-based-plug-ins 3 | url = https://github.com/Accelergy-Project/accelergy-table-based-plug-ins.git 4 | [submodule "src/accelergy-aladdin-plug-in"] 5 | path = src/accelergy-aladdin-plug-in 6 | url = https://github.com/Accelergy-Project/accelergy-aladdin-plug-in.git 7 | [submodule "src/accelergy"] 8 | path = src/accelergy 9 | url = https://github.com/Accelergy-Project/accelergy.git 10 | [submodule "src/accelergy-cacti-plug-in"] 11 | path = src/accelergy-cacti-plug-in 12 | url = https://github.com/Accelergy-Project/accelergy-cacti-plug-in.git 13 | [submodule "src/cacti"] 14 | path = src/cacti 15 | url = https://github.com/HewlettPackard/cacti.git 16 | [submodule "src/timeloop"] 17 | path = src/timeloop 18 | url = https://github.com/NVlabs/timeloop.git 19 | [submodule "src/timeloop-python"] 20 | path = src/timeloop-python 21 | url = https://github.com/Accelergy-Project/timeloop-python.git 22 | branch = main 23 | [submodule "src/accelergy-library-plug-in"] 24 | path = src/accelergy-library-plug-in 25 | url = https://github.com/Accelergy-Project/accelergy-library-plug-in.git 26 | branch = main 27 | [submodule "src/accelergy-neurosim-plug-in"] 28 | path = src/accelergy-neurosim-plug-in 29 | url = https://github.com/Accelergy-Project/accelergy-neurosim-plug-in.git 30 | branch = main 31 | [submodule "src/accelergy-adc-plug-in"] 32 | path = src/accelergy-adc-plug-in 33 | url = https://github.com/Accelergy-Project/accelergy-adc-plug-in.git 34 | branch = main 35 | [submodule "src/timeloopfe"] 36 | path = src/timeloopfe 37 | url = https://github.com/Accelergy-Project/timeloopfe.git 38 | -------------------------------------------------------------------------------- /docker-entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | 4 | # Set UID/GID if not provided with enviromental variable(s). 5 | if [ -z "$USER_UID" ]; then 6 | USER_UID=$(cat /etc/passwd | grep workspace | cut -d: -f3) 7 | echo "USER_UID variable not specified, defaulting to workspace user id ($USER_UID)" 8 | fi 9 | 10 | if [ -z "$USER_GID" ]; then 11 | USER_GID=$(cat /etc/group | grep workspace | cut -d: -f3) 12 | echo "USER_GID variable not specified, defaulting to workspace user group id ($USER_GID)" 13 | fi 14 | 15 | # Look for existing group, if not found create group "workspace" with specified GID. 16 | FIND_GROUP=$(grep ":$USER_GID:" /etc/group) 17 | 18 | if [ -z "$FIND_GROUP" ]; then 19 | usermod -g users workspace 20 | groupdel workspace 21 | groupadd -g $USER_GID workspace 22 | fi 23 | 24 | # Set "workspace" account's UID. 25 | usermod -u $USER_UID -g $USER_GID --non-unique workspace > /dev/null 2>&1 26 | 27 | # Populate "workspace" directory, and 28 | # change ownership of files in "workspace" home 29 | if [ ! -d /home/workspace/README ] 30 | then 31 | cp -r /usr/local/src/README /home/workspace 32 | chown -R $USER_UID:$USER_GID /home/workspace/README 33 | fi 34 | 35 | # Change owner/permissions on "workspace" home folder 36 | chown $USER_UID:$USER_GID /home/workspace 37 | chmod 755 /home/workspace 38 | 39 | if [ ! -e /home/workspace/.nointro ] 40 | then 41 | more /home/workspace/README/readme.md 42 | fi 43 | 44 | # Default environment variable for Timeloop 45 | export TIMELOOP_ACCURATE_READS_WITU=1 46 | 47 | # Set shorter prompt name if there is no custom setup in users' own directories 48 | if [ ! -e /home/workspace/.bashrc ] 49 | then 50 | cp /usr/local/src/.bashrc /home/workspace/.bashrc 51 | fi 52 | 53 | # Set default accelergy config file if there is no exsiting one 54 | if [ ! -e /home/workspace/.config/accelergy/accelergy_config.yaml ] 55 | then 56 | # create necessary directories 57 | if [ ! -e /home/workspace/.config ] 58 | then 59 | mkdir /home/workspace/.config 60 | fi 61 | # create necessary directories 62 | if [ ! -e /home/workspace/.config/accelergy ] 63 | then 64 | mkdir /home/workspace/.config/accelergy 65 | fi 66 | 67 | cp /usr/local/src/accelergy_default_config.yaml /home/workspace/.config/accelergy/accelergy_config.yaml 68 | fi 69 | 70 | #if [ "$#" -eq 0 ] || [ "${1#-}" != "$1" ] 71 | if [ "$@" != "bash" ] 72 | then 73 | echo "Command: >>> $@ <<<" 74 | exec "$@" 75 | fi 76 | 77 | exec su workspace -s "/bin/bash" # -c "$@" 78 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Accelergy-Timeloop Infrastructure 2 | --------------------------------------------------- 3 | 4 | This docker aims to provide an experimental environment for easy plug-and-play of examples that run on the accelergy-timeloop DNN accelerator evaluation infrastructure. 5 | You can also use the src included in this docker to perform native installation of the tools. 6 | 7 | See instructions for both options below 8 | 9 | This docker is modified based on: https://github.com/jsemer/timeloop-accelergy-tutorial 10 | 11 | Native Install 12 | ----------------- 13 | 14 | ``` 15 | % git clone --recurse-submodules https://github.com/Accelergy-Project/accelergy-timeloop-infrastructure.git 16 | % cd accelergy-timeloop-infrastructure 17 | % make pull 18 | % cd src/ # check all the sources here 19 | % to install all the tools: http://accelergy.mit.edu/infra_instructions.html 20 | ``` 21 | 22 | Start the container 23 | ----------------- 24 | 25 | - Put the *docker-compose.yaml* file in an otherwise empty directory 26 | - Cd to the directory containing the file 27 | - Edit USER_UID and USER_GID in the file to the desired owner of your files (echo $UID, echo $GID) 28 | - Run the following command: 29 | ``` 30 | % If you are using x86 CPU (Intel, AMD) 31 | % DOCKER_ARCH=amd64 docker-compose run infrastructure 32 | 33 | % If you are using arm CPU (Apple M1/M2) 34 | % DOCKER_ARCH=arm64 docker-compose run infrastructure 35 | 36 | % If you want to avoid typing "DOCKER_ARCH=" every time, 37 | % "export DOCKER_ARCH=" >> ~/.bashrc && source ~/.bashrc 38 | ``` 39 | - Follow the instructions in the REAME directory to get public examples for this infrastructure 40 | 41 | 42 | Refresh the container 43 | ---------------------- 44 | 45 | To update the Docker container run: 46 | 47 | ``` 48 | % If you are using x86 CPU (Intel, AMD) 49 | % DOCKER_ARCH=amd64 docker-compose pull 50 | 51 | % If you are using arm CPU (Apple M1/M2) 52 | % DOCKER_ARCH=arm64 docker-compose pull 53 | 54 | % If you want to avoid typing "DOCKER_ARCH=" every time, 55 | % "export DOCKER_ARCH=" >> ~/.bashrc && source ~/.bashrc 56 | ```` 57 | 58 | 59 | 60 | Build the image 61 | --------------- 62 | 63 | ``` 64 | % git clone --recurse-submodules https://github.com/Accelergy-Project/accelergy-timeloop-infrastructure.git 65 | % cd accelergy-timeloop-infrastructure 66 | % export DOCKER_EXE= 67 | % make pull 68 | % "make build-amd64" or "make build-arm64" depending on your architecture 69 | ``` 70 | 71 | Push the image to docker hub 72 | ---------------------------- 73 | 74 | ``` 75 | % cd accelergy-timeloop-infrastructure 76 | % export DOCKER_NAME= 77 | % export DOCKER_PASS= 78 | % "make push-amd64" or "make push-arm64" 79 | ``` 80 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Utility Makefile to build/push Docker images 3 | # 4 | # To use an alternate tag invoke as: 5 | # 6 | # make build ALTTAG= 7 | # 8 | # Optionally override 9 | # 10 | # DOCKER_EXE= 11 | # DOCKER_NAME= 12 | # 13 | # Set this envirnment or command line variable 14 | # 15 | # DOCKER_PASS= 16 | # 17 | DOCKER_EXE ?= docker 18 | DOCKER_NAME ?= timeloopaccelergy 19 | 20 | VERSION := 0.2 21 | 22 | USER := timeloopaccelergy 23 | REPO := accelergy-timeloop-infrastructure 24 | 25 | NAME := ${USER}/${REPO} 26 | TAG := $$(git log -1 --pretty=%h) 27 | IMG := ${NAME}:${TAG} 28 | 29 | ALTTAG := latest 30 | ALTIMG := ${NAME}:${ALTTAG} 31 | 32 | # For Timeloop installation 33 | BARVINOK_VER ?= 0.41.6 34 | NTL_VER ?= 11.5.1 35 | 36 | all: build 37 | 38 | 39 | # Pull all submodules 40 | 41 | pull: 42 | # Only update top-level submodules 43 | GIT_MAX_RECURSION=1 git submodule update --remote --merge --recursive 44 | 45 | cp cacti.patch ./src/cacti/ && \ 46 | cd ./src/cacti/ && \ 47 | git reset --hard && \ 48 | git apply cacti.patch 49 | 50 | cp cacti.patch ./src/accelergy-cacti-plug-in/cacti/ && \ 51 | cd ./src/accelergy-cacti-plug-in/cacti/ && \ 52 | git reset --hard && \ 53 | git apply cacti.patch 54 | 55 | # Build and tag docker image 56 | build-amd64: 57 | "${DOCKER_EXE}" build ${BUILD_FLAGS} --platform linux/amd64 \ 58 | --build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \ 59 | --build-arg VCS_REF=${TAG} \ 60 | --build-arg BUILD_VERSION=${VERSION} \ 61 | -t ${IMG}-amd64 . 62 | "${DOCKER_EXE}" tag ${IMG}-amd64 ${ALTIMG}-amd64 63 | 64 | build-arm64: 65 | "${DOCKER_EXE}" build ${BUILD_FLAGS} --platform linux/arm64 \ 66 | --build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \ 67 | --build-arg VCS_REF=${TAG} \ 68 | --build-arg BUILD_VERSION=${VERSION} \ 69 | -t ${IMG}-arm64 . 70 | "${DOCKER_EXE}" tag ${IMG}-arm64 ${ALTIMG}-arm64 71 | 72 | # Push docker image 73 | 74 | push-amd64: 75 | @echo "Pushing ${NAME}:${ALTTAG}-amd64" 76 | #Push Amd64 version 77 | "${DOCKER_EXE}" push ${NAME}:${ALTTAG}-amd64 78 | #Combine Amd64 version into multi-architecture docker image. 79 | "${DOCKER_EXE}" manifest create \ 80 | ${NAME}:${ALTTAG} \ 81 | --amend ${NAME}:${ALTTAG}-amd64 \ 82 | --amend ${NAME}:${ALTTAG}-arm64 83 | "${DOCKER_EXE}" manifest push ${NAME}:${ALTTAG} 84 | 85 | 86 | 87 | push-arm64: 88 | @echo "Pushing ${NAME}:${ALTTAG}-arm64" 89 | #Push Arm64 version 90 | "${DOCKER_EXE}" push ${NAME}:${ALTTAG}-arm64 91 | #Combine Arm64 version into multi-architecture docker image. 92 | "${DOCKER_EXE}" manifest create \ 93 | ${NAME}:${ALTTAG} \ 94 | --amend ${NAME}:${ALTTAG}-amd64 \ 95 | --amend ${NAME}:${ALTTAG}-arm64 96 | "${DOCKER_EXE}" manifest push ${NAME}:${ALTTAG} 97 | 98 | # Lint the Dockerfile 99 | 100 | lint: 101 | "${DOCKER_EXE}" run --rm -i hadolint/hadolint < Dockerfile || true 102 | 103 | 104 | # Login to docker hub 105 | 106 | login: 107 | "${DOCKER_EXE}" login --username ${DOCKER_NAME} --password ${DOCKER_PASS} 108 | 109 | install_accelergy: 110 | python3 -m pip install setuptools wheel libconf numpy joblib 111 | cd src/accelergy-cacti-plug-in && make 112 | cd src/accelergy-neurosim-plug-in && make 113 | cd src && pip3 install ./accelergy* 114 | 115 | install_timeloop: 116 | mkdir -p /tmp/build-timeloop 117 | 118 | sudo apt-get update \ 119 | && sudo DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install tzdata \ 120 | && sudo apt-get install -y --no-install-recommends \ 121 | locales \ 122 | curl \ 123 | git \ 124 | wget \ 125 | python3-dev \ 126 | python3-pip \ 127 | scons \ 128 | make \ 129 | autotools-dev \ 130 | autoconf \ 131 | automake \ 132 | libtool \ 133 | && sudo apt-get install -y --no-install-recommends \ 134 | g++ \ 135 | cmake 136 | 137 | sudo apt-get update \ 138 | && sudo apt-get install -y --no-install-recommends \ 139 | g++ \ 140 | libconfig++-dev \ 141 | libboost-dev \ 142 | libboost-filesystem-dev \ 143 | libboost-iostreams-dev \ 144 | libboost-log-dev \ 145 | libboost-serialization-dev \ 146 | libboost-thread-dev \ 147 | libyaml-cpp-dev \ 148 | libncurses5-dev \ 149 | libtinfo-dev \ 150 | libgpm-dev \ 151 | libgmp-dev 152 | 153 | cd /tmp/build-timeloop \ 154 | && wget https://libntl.org/ntl-${NTL_VER}.tar.gz \ 155 | && tar -xvzf ntl-${NTL_VER}.tar.gz \ 156 | && cd ntl-${NTL_VER}/src \ 157 | && ./configure NTL_GMP_LIP=on SHARED=on \ 158 | && make -j8 \ 159 | && sudo make install 160 | 161 | cd /tmp/build-timeloop \ 162 | && wget https://barvinok.sourceforge.io/barvinok-${BARVINOK_VER}.tar.gz \ 163 | && tar -xvzf barvinok-${BARVINOK_VER}.tar.gz \ 164 | && cd barvinok-${BARVINOK_VER} \ 165 | && ./configure --enable-shared-barvinok \ 166 | && make -j8 \ 167 | && sudo make install 168 | 169 | cd src/timeloop \ 170 | && cp -r pat-public/src/pat src/pat \ 171 | && scons -j8 --with-isl --static --accelergy \ 172 | && scons -j8 --with-isl --accelergy 173 | 174 | cp src/timeloop/build/timeloop-mapper ~/.local/bin/timeloop-mapper 175 | cp src/timeloop/build/timeloop-metrics ~/.local/bin/timeloop-metrics 176 | cp src/timeloop/build/timeloop-model ~/.local/bin/timeloop-model 177 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:22.04 AS builder 2 | 3 | ENV BUILD_DIR=/usr/local/src 4 | 5 | RUN apt-get update \ 6 | && DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install tzdata \ 7 | && apt-get install -y --no-install-recommends locales \ 8 | && apt-get install -y --no-install-recommends git \ 9 | && apt-get install -y --no-install-recommends scons \ 10 | && apt-get install -y --no-install-recommends make \ 11 | && apt-get install -y --no-install-recommends python3 \ 12 | && apt-get install -y --no-install-recommends python3-pip \ 13 | && apt-get install -y --no-install-recommends doxygen \ 14 | && rm -rf /var/lib/apt/lists/* \ 15 | && if [ ! -d $BUILD_DIR ]; then mkdir $BUILD_DIR; fi 16 | 17 | # Cacti 18 | 19 | WORKDIR $BUILD_DIR 20 | 21 | COPY src/cacti $BUILD_DIR/cacti 22 | 23 | RUN apt-get update \ 24 | && apt-get install -y --no-install-recommends \ 25 | g++ \ 26 | libconfig++-dev \ 27 | && rm -rf /var/lib/apt/lists/* \ 28 | && cd cacti \ 29 | && make \ 30 | && chmod -R 777 . 31 | 32 | 33 | # NeuroSim 34 | WORKDIR $BUILD_DIR 35 | COPY src/accelergy-neurosim-plug-in $BUILD_DIR/accelergy-neurosim-plug-in 36 | RUN cd accelergy-neurosim-plug-in \ 37 | && mkdir -p NeuroSim \ 38 | && cp -r DNN_NeuroSim_V1.3/Inference_pytorch/NeuroSIM/* ./NeuroSim/ \ 39 | && cp -rf drop_in/* ./NeuroSim/ \ 40 | && cd NeuroSim \ 41 | && make \ 42 | && chmod -R 777 . 43 | 44 | # Build and install timeloop 45 | 46 | WORKDIR $BUILD_DIR 47 | 48 | COPY src/timeloop $BUILD_DIR/timeloop 49 | 50 | ENV BARVINOK_VER=0.41.8 51 | ENV NTL_VER=11.5.1 52 | 53 | RUN apt-get update \ 54 | && DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install tzdata \ 55 | && apt-get install -y --no-install-recommends \ 56 | locales \ 57 | curl \ 58 | git \ 59 | wget \ 60 | python3-dev \ 61 | python3-pip \ 62 | scons \ 63 | make \ 64 | autotools-dev \ 65 | autoconf \ 66 | automake \ 67 | libtool \ 68 | && apt-get install -y --no-install-recommends \ 69 | g++ \ 70 | cmake 71 | 72 | RUN apt-get update \ 73 | && apt-get install -y --no-install-recommends \ 74 | g++ \ 75 | libconfig++-dev \ 76 | libboost-dev \ 77 | libboost-iostreams-dev \ 78 | libboost-serialization-dev \ 79 | libyaml-cpp-dev \ 80 | libncurses5-dev \ 81 | libtinfo-dev \ 82 | libgpm-dev \ 83 | libgmp-dev \ 84 | && rm -rf /var/lib/apt/lists/* 85 | 86 | WORKDIR $BUILD_DIR 87 | RUN wget https://libntl.org/ntl-$NTL_VER.tar.gz \ 88 | && tar -xvzf ntl-$NTL_VER.tar.gz \ 89 | && cd ntl-$NTL_VER/src \ 90 | && ./configure NTL_GMP_LIP=on SHARED=on NATIVE=off \ 91 | && make \ 92 | && make install 93 | 94 | WORKDIR $BUILD_DIR 95 | RUN wget https://barvinok.sourceforge.io/barvinok-$BARVINOK_VER.tar.gz \ 96 | && tar -xvzf barvinok-$BARVINOK_VER.tar.gz \ 97 | && cd barvinok-$BARVINOK_VER \ 98 | && ./configure --enable-shared-barvinok \ 99 | && make \ 100 | && make install 101 | 102 | RUN apt-get update \ 103 | && apt-get install -y --no-install-recommends \ 104 | scons \ 105 | libconfig++-dev \ 106 | libboost-all-dev \ 107 | libboost-dev \ 108 | libboost-iostreams-dev \ 109 | libboost-serialization-dev \ 110 | libyaml-cpp-dev \ 111 | libncurses-dev \ 112 | libtinfo-dev \ 113 | libgpm-dev \ 114 | git \ 115 | build-essential \ 116 | python3-pip 117 | 118 | RUN apt-get update \ 119 | && apt-get install -y --no-install-recommends \ 120 | g++ \ 121 | libconfig++-dev \ 122 | libboost-dev \ 123 | libboost-iostreams-dev \ 124 | libboost-serialization-dev \ 125 | libyaml-cpp-dev \ 126 | libncurses5-dev \ 127 | libtinfo-dev \ 128 | libgpm-dev \ 129 | && rm -rf /var/lib/apt/lists/* \ 130 | && cd ./timeloop/src \ 131 | && ln -s ../pat-public/src/pat . \ 132 | && cd .. \ 133 | && scons --accelergy -j 4 \ 134 | && scons --static --accelergy -j 4 \ 135 | && cp build/timeloop-mapper /usr/local/bin \ 136 | && cp build/timeloop-metrics /usr/local/bin \ 137 | && cp build/timeloop-model /usr/local/bin 138 | 139 | WORKDIR $BUILD_DIR 140 | 141 | RUN cd ./timeloop \ 142 | && doxygen .doxygen-config 143 | 144 | # 145 | # Main image 146 | # 147 | FROM ubuntu:22.04 148 | 149 | LABEL maintainer="timeloop-accelergy@mit.edu" 150 | 151 | # Arguments 152 | ARG BUILD_DATE 153 | ARG VCS_REF 154 | ARG BUILD_VERSION 155 | 156 | # Labels 157 | LABEL org.label-schema.schema-version="1.0" 158 | LABEL org.label-schema.build-date=$BUILD_DATE 159 | LABEL org.label-schema.name="Accelergy-Project/accelergy-timeloop-infrastructure" 160 | LABEL org.label-schema.description="Infrastructure setup for Timeloop/Accelergy tools" 161 | LABEL org.label-schema.url="http://accelergy.mit.edu/" 162 | LABEL org.label-schema.vcs-url="https://github.com/Accelergy-Project/accelergy-timeloop-infrastructure" 163 | LABEL org.label-schema.vcs-ref=$VCS_REF 164 | LABEL org.label-schema.vendor="Wu" 165 | LABEL org.label-schema.version=$BUILD_VERSION 166 | LABEL org.label-schema.docker.cmd="docker run -it --rm -v ~/workspace:/home/workspace timeloopaccelergy/accelergy-timeloop-infrastructure" 167 | 168 | ENV BIN_DIR=/usr/local/bin 169 | ENV BUILD_DIR=/usr/local/src 170 | ENV LIB_DIR=/usr/local/lib 171 | ENV SHARE_DIR=/usr/local/share 172 | ENV INCLUDE_DIR=/usr/local/include 173 | 174 | RUN apt-get update \ 175 | && apt-get install -y --no-install-recommends \ 176 | curl \ 177 | git \ 178 | wget \ 179 | vim \ 180 | && apt-get install -y --no-install-recommends python3-dev \ 181 | && apt-get install -y --no-install-recommends python3-pip \ 182 | && DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install tzdata \ 183 | && apt-get install -y --no-install-recommends \ 184 | g++ \ 185 | libconfig++-dev \ 186 | libboost-dev \ 187 | libboost-iostreams-dev \ 188 | libboost-serialization-dev \ 189 | libyaml-cpp-dev \ 190 | libncurses5-dev \ 191 | libtinfo-dev \ 192 | libgpm-dev \ 193 | cmake \ 194 | ninja-build \ 195 | && rm -rf /var/lib/apt/lists/* \ 196 | && groupadd workspace \ 197 | && useradd -m -d /home/workspace -c "Workspace User Account" -s /usr/sbin/nologin -g workspace workspace \ 198 | && if [ ! -d $BUILD_DIR ]; then mkdir $BUILD_DIR; fi 199 | 200 | # Get tools built in other containers 201 | 202 | WORKDIR $BUILD_DIR 203 | 204 | COPY --from=builder $BUILD_DIR/timeloop/build/timeloop-mapper $BIN_DIR 205 | COPY --from=builder $BUILD_DIR/timeloop/build/timeloop-metrics $BIN_DIR 206 | COPY --from=builder $BUILD_DIR/timeloop/build/timeloop-model $BIN_DIR 207 | 208 | COPY --from=builder $BUILD_DIR/cacti/cacti $BIN_DIR 209 | 210 | # Get libraries and includes 211 | 212 | WORKDIR $BUILD_DIR 213 | 214 | COPY --from=builder $BUILD_DIR/timeloop/lib/*.a $LIB_DIR/ 215 | COPY --from=builder $BUILD_DIR/timeloop/lib/*.so $LIB_DIR/ 216 | COPY --from=builder $BUILD_DIR/timeloop/include/* $INCLUDE_DIR/timeloop/ 217 | 218 | RUN apt-get update \ 219 | && DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install tzdata \ 220 | && apt-get install -y --no-install-recommends \ 221 | locales \ 222 | curl \ 223 | git \ 224 | wget \ 225 | python3-dev \ 226 | python3-pip \ 227 | scons \ 228 | make \ 229 | autotools-dev \ 230 | autoconf \ 231 | automake \ 232 | libtool \ 233 | graphviz \ 234 | && apt-get install -y --no-install-recommends \ 235 | g++ \ 236 | cmake 237 | 238 | 239 | # 240 | # Set version for s6 overlay 241 | # 242 | ARG OVERLAY_VERSION="v2.1.0.2" 243 | ARG OVERLAY_ARCH="amd64" 244 | 245 | ADD https://github.com/just-containers/s6-overlay/releases/download/${OVERLAY_VERSION}/s6-overlay-${OVERLAY_ARCH}-installer /tmp/ 246 | 247 | RUN chmod +x /tmp/s6-overlay-${OVERLAY_ARCH}-installer && \ 248 | /tmp/s6-overlay-${OVERLAY_ARCH}-installer / && \ 249 | rm /tmp/s6-overlay-${OVERLAY_ARCH}-installer 250 | 251 | RUN echo "**** create container user and make folders ****" && \ 252 | userdel workspace && \ 253 | useradd -u 911 -U -d /home/workspace -s /bin/bash workspace && \ 254 | usermod -G users workspace 255 | 256 | 257 | # Get all source 258 | 259 | WORKDIR $BUILD_DIR 260 | 261 | COPY src/ $BUILD_DIR/ 262 | 263 | WORKDIR $BUILD_DIR 264 | RUN echo "YES" | python3 $BUILD_DIR/timeloop/scripts/hyphens2underscores.py $BUILD_DIR/timeloop-python 265 | 266 | #WORKDIR $BUILD_DIR 267 | #RUN apt-get update \ 268 | # && apt-get install -y --no-install-recommends locales \ 269 | # && locale-gen en_US.UTF-8 270 | #ENV LC_CTYPE en_US.UTF-8 271 | #ENV LANG en_US.UTF-8 272 | #RUN python3 -m pip install setuptools \ 273 | # && cd terminal_markdown_viewer \ 274 | # && python3 -m pip install . 275 | 276 | # Get Timeloop documentation 277 | 278 | COPY --from=builder $BUILD_DIR/timeloop/docs $BUILD_DIR/timeloop 279 | 280 | # Accelergy 281 | 282 | WORKDIR $BUILD_DIR 283 | 284 | # Note source for accelergy was copied in above 285 | RUN mkdir $BUILD_DIR/accelergy-neurosim-plug-in/NeuroSim 286 | COPY --from=builder $BUILD_DIR/accelergy-neurosim-plug-in/NeuroSim/main $BUILD_DIR/accelergy-neurosim-plug-in/NeuroSim/main 287 | 288 | WORKDIR $BUILD_DIR 289 | 290 | # accelergy-neurosim-main $BUILD_DIR/accelergy-neurosim-main 291 | 292 | RUN python3 -m pip install setuptools \ 293 | && python3 -m pip install wheel \ 294 | && python3 -m pip install libconf \ 295 | && python3 -m pip install numpy \ 296 | && python3 -m pip install pydot \ 297 | && python3 -m pip install jupyterlab \ 298 | && python3 -m pip install ./accelergy \ 299 | && python3 -m pip install ./accelergy-aladdin-plug-in \ 300 | && cd accelergy-cacti-plug-in && make && cd .. \ 301 | && python3 -m pip install ./accelergy-cacti-plug-in \ 302 | && python3 -m pip install ./accelergy-table-based-plug-ins \ 303 | && python3 -m pip install ./accelergy-neurosim-plug-in \ 304 | && python3 -m pip install ./accelergy-library-plug-in \ 305 | && python3 -m pip install ./accelergy-adc-plug-in \ 306 | && chmod -R 777 $SHARE_DIR/accelergy/estimation_plug_ins 307 | 308 | 309 | # PyTimeloop 310 | 311 | ENV BARVINOK_VER=0.41.6 312 | ENV NTL_VER=11.5.1 313 | 314 | RUN apt-get update \ 315 | && apt-get install -y --no-install-recommends \ 316 | g++ \ 317 | libconfig++-dev \ 318 | libboost-dev \ 319 | libboost-iostreams-dev \ 320 | libboost-serialization-dev \ 321 | libyaml-cpp-dev \ 322 | libncurses5-dev \ 323 | libtinfo-dev \ 324 | libgpm-dev \ 325 | libgmp-dev \ 326 | && rm -rf /var/lib/apt/lists/* 327 | 328 | WORKDIR $BUILD_DIR 329 | RUN wget https://libntl.org/ntl-$NTL_VER.tar.gz \ 330 | && tar -xvzf ntl-$NTL_VER.tar.gz \ 331 | && cd ntl-$NTL_VER/src \ 332 | && ./configure NTL_GMP_LIP=on SHARED=on NATIVE=off \ 333 | && make \ 334 | && make install 335 | 336 | WORKDIR $BUILD_DIR 337 | RUN wget https://barvinok.sourceforge.io/barvinok-$BARVINOK_VER.tar.gz \ 338 | && tar -xvzf barvinok-$BARVINOK_VER.tar.gz \ 339 | && cd barvinok-$BARVINOK_VER \ 340 | && ./configure --enable-shared-barvinok \ 341 | && make \ 342 | && make install 343 | 344 | WORKDIR $BUILD_DIR 345 | RUN wget -O islpy-2024.2.tar.gz https://github.com/inducer/islpy/archive/refs/tags/v2024.2.tar.gz \ 346 | && tar -xvzf islpy-2024.2.tar.gz \ 347 | && cd islpy-2024.2 \ 348 | && sed -i 's/python/python3/g' build-with-barvinok.sh \ 349 | # && ./build-with-barvinok.sh /usr/local 350 | && ./configure.py --use-barvinok --isl-inc-dir=/usr/local/include --isl-lib-dir=/usr/local/lib --barvinok-inc-dir=/usr/local/include --barvinok-lib-dir/usr/local/lib --no-use-shipped-isl --no-use-shipped-imath \ 351 | && python3 -m pip install . 352 | 353 | WORKDIR $BUILD_DIR 354 | RUN apt-get update \ 355 | && apt-get install -y --no-install-recommends \ 356 | g++ \ 357 | cmake \ 358 | make \ 359 | && cd timeloop/src \ 360 | && ln -s ../pat-public/src/pat . \ 361 | && cd ../../timeloop-python \ 362 | && rm -rf build \ 363 | && apt-get install -y --no-install-recommends \ 364 | libisl-dev \ 365 | && TIMELOOP_INCLUDE_PATH=$BUILD_DIR/timeloop/include \ 366 | TIMELOOP_LIB_PATH=$LIB_DIR \ 367 | python3 -m pip install . 368 | 369 | 370 | # 371 | # Set up root 372 | # 373 | COPY /root / 374 | 375 | USER $NB_USER 376 | WORKDIR /home/workspace/ 377 | 378 | 379 | # Set up entrypoint 380 | 381 | EXPOSE 8888 382 | 383 | ENTRYPOINT ["/init"] 384 | --------------------------------------------------------------------------------