Skip to content

Commit

Permalink
Docker no clang (#1946)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
steveri authored Jul 30, 2024
1 parent 2a4e412 commit 8226ede
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 16 deletions.
28 changes: 20 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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
Expand All @@ -197,17 +211,15 @@ 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

# 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
Expand Down
40 changes: 32 additions & 8 deletions aha/bin/docker-bashrc
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 8226ede

Please sign in to comment.