From 8226ede457db163c7b6887a34a1e66d46c2cbe98 Mon Sep 17 00:00:00 2001 From: steveri Date: Tue, 30 Jul 2024 07:13:14 -0700 Subject: [PATCH] Docker no clang (#1946) * Modify Dockerfile to exclude 1G of clang used to compile Halide * Modify docker bashrc to restore 1G of clang deleted by docker build * oops do not restore clang if no restore needed oops --- Dockerfile | 28 ++++++++++++++++++++-------- aha/bin/docker-bashrc | 40 ++++++++++++++++++++++++++++++++-------- 2 files changed, 52 insertions(+), 16 deletions(-) diff --git a/Dockerfile b/Dockerfile index 886c7ce4..63a55970 100644 --- a/Dockerfile +++ b/Dockerfile @@ -76,9 +76,7 @@ RUN apt-get update && \ update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 100 \ --slave /usr/bin/g++ g++ /usr/bin/g++-9 && \ pip install cmake && \ - wget -nv -O ~/clang7.tar.xz http://releases.llvm.org/7.0.1/clang+llvm-7.0.1-x86_64-linux-gnu-ubuntu-18.04.tar.xz && \ - tar -xvf ~/clang7.tar.xz --strip-components=1 -C /usr/ && \ - rm -rf ~/clang7.tar.xz + echo DONE # Switch shell to bash SHELL ["/bin/bash", "--login", "-c"] @@ -172,15 +170,31 @@ RUN ./misc/install_deps_ahaflow.sh && \ rm -rf /aha/clockwork/*.o /aha/clockwork/bin/*.o && \ echo DONE -# Halide-to-Hardware +# Halide-install step, below, modified to delete 1G of clang when finished. +# Clang will be restored by way of .bashrc (aha/bin/docker-bashrc). + +# Halide-to-Hardware - Step 32/65 ish - requires clang COPY ./Halide-to-Hardware /aha/Halide-to-Hardware WORKDIR /aha/Halide-to-Hardware -RUN export COREIR_DIR=/aha/coreir && make -j2 && make distrib && \ +RUN \ + : CLANG-INSTALL && \ + echo "Install 1G of clang/llvm" && \ + url=http://releases.llvm.org/7.0.1/clang+llvm-7.0.1-x86_64-linux-gnu-ubuntu-18.04.tar.xz && \ + wget -nv -O ~/clang7.tar.xz $url && \ + tar -xvf ~/clang7.tar.xz --strip-components=1 -C /usr/ && \ + rm -rf ~/clang7.tar.xz && \ + : BUILD && \ + echo "Build and test Halide compiler" && \ + export COREIR_DIR=/aha/coreir && make -j2 && make distrib && \ + : CLEANUP && \ echo "Cleanup: 200M lib, 400M gch, 200M distrib, 100M llvm" && \ rm -rf lib/* && \ rm -rf /aha/Halide-to-Hardware/include/Halide.h.gch/ && \ rm -rf /aha/Halide-to-Hardware/distrib/{bin,lib} && \ rm -rf /aha/Halide-to-Hardware/bin/build/llvm_objects && \ + echo "Cleanup: 1G clang in /usr, will be restored by bashrc" && \ + rm -rf /usr/*/{*clang*,*llvm*,*LLVM*} && \ + : DONE && \ echo DONE # Sam 1 - clone and set up sam @@ -197,6 +211,7 @@ COPY ./sam /aha/sam RUN echo "--- ..Sam 2" && cd /aha/sam && make sam && \ source /aha/bin/activate && pip install scipy numpy pytest && pip install -e . +# ------------------------------------------------------------------------------ # Final pip installs: AHA Tools etc. # Note kratos is slow but stable; maybe it should be installed much earlier in dockerfile @@ -204,10 +219,7 @@ RUN echo "--- ..Sam 2" && cd /aha/sam && make sam && \ # For "aha deps install"; copy all the modules that not yet been copied COPY ./archipelago /aha/archipelago COPY ./ast_tools /aha/ast_tools -# COPY ./BufferMapping /aha/BufferMapping COPY ./canal /aha/canal -# COPY ./cgra_pnr/cyclone /aha/cgra_pnr/cyclone -# COPY ./cgra_pnr/thunder /aha/cgra_pnr/thunder COPY ./cgra_pnr /aha/cgra_pnr COPY ./cosa /aha/cosa COPY ./fault /aha/fault diff --git a/aha/bin/docker-bashrc b/aha/bin/docker-bashrc index 7f956cfd..f45621b4 100644 --- a/aha/bin/docker-bashrc +++ b/aha/bin/docker-bashrc @@ -11,22 +11,46 @@ cat << EOF EOF +######################################################################## +# Restore submodules - do it in the background for minimal disruption + cat << EOF Restoring submodule metadata in the background. To monitor progress, can 'cat' or 'tail' log files e.g. - tail -f /tmp/restore-clockwork - tail -f /tmp/restore-halide + tail /tmp/restore-clockwork + tail /tmp/restore-halide EOF # Restore 420MB of clockwork .git data + 320MB of halide data -( - echo '/aha/aha/bin/restore-dotgit.sh clockwork >& /tmp/restore-clockwork' + +( echo ' /aha/aha/bin/restore-dotgit.sh clockwork >& /tmp/restore-clockwork' /aha/aha/bin/restore-dotgit.sh clockwork >& /tmp/restore-clockwork - echo "Finished restoring clockwork metadata" + printf "\nFinished restoring clockwork metadata\n" ) & -( - echo '/aha/aha/bin/restore-dotgit.sh Halide-to-Hardware >& /tmp/restore-halide' + +( echo ' /aha/aha/bin/restore-dotgit.sh Halide-to-Hardware >& /tmp/restore-halide' /aha/aha/bin/restore-dotgit.sh Halide-to-Hardware >& /tmp/restore-halide - echo "Finished restoring halide metadata" + printf "\nFinished restoring halide metadata\n" +) & + +######################################################################## +# Restore clang - do it in the background for minimal disruption + +test -f /usr/bin/clang-7 || cat << EOF + + Restoring clang and llvm in the background. + To monitor progress, can 'cat' or 'tail' log file e.g. + tail /tmp/restore-clang + +EOF +test -f /usr/bin/clang-7 || ( + url=http://releases.llvm.org/7.0.1/clang+llvm-7.0.1-x86_64-linux-gnu-ubuntu-18.04.tar.xz + echo " wget $url" + wget -nv -O ~/clang7.tar.xz $url + echo "" + tar -xvf ~/clang7.tar.xz --strip-components=1 -C /usr/ >& /tmp/restore-clang + rm -rf ~/clang7.tar.xz + printf "\nFinished restoring clang\n" ) & +sleep 1