Skip to content

Commit cc7e731

Browse files
committed
Created script for running apptainer; Added instructions in README with more build details
1 parent fdd6ff7 commit cc7e731

4 files changed

Lines changed: 121 additions & 22 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
/.vscode
33
*.cache
44
*.code-workspace
5-
miscs/apptainer/vortex_fpga.sif
5+
miscs/apptainer/vortex.sif

miscs/apptainer/README.md

Lines changed: 79 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,105 @@ Go to `apptainer` directory
1111
$ pwd
1212
vortex/miscs/apptainer
1313
14-
$ apptainer build --no-https vortex_fpga.sif vortex_fpga.def
14+
$ apptainer build --no-https vortex.sif vortex.def
1515
1616
```
17+
18+
1719
To start the apptainer,
1820
```
19-
$ apptainer shell --fakeroot --cleanenv --writable-tmpfs --bind /opt/xilinx/:/opt/xilinx/ --bind /netscratch/rn84/devnull:/dev/null --bind /dev/bus/usb,/sys/bus/pci --bind /projects:/projects --bind /tools:/tools --bind /netscratch:/netscratch vortex_fpga.sif
21+
$ chmod +x run_apptainer.sh
22+
$ ./run_apptainer.sh
2023
```
2124

25+
26+
| Note: Set env variables in `run_apptainer.sh` accordingly.
27+
28+
2229
Inside the Apptainer,
2330
```
31+
# should show devices connected to machine on which you are running this command
2432
Apptainer> lsusb
2533
26-
should show devices connected to machine on which you are running this command
2734
```
2835

2936

37+
# Vortex Simulation inside Apptainer
38+
39+
Go to bind of vortex repo,
40+
```
41+
Apptainer> cd /home/vortex
42+
Apptainer> mkdir build
43+
Apptainer> cd build
44+
Apptainer> ../configure --xlen=32 --tooldir=$HOME/tools
45+
46+
47+
Skip the below 3 steps, If tools are already present in the $HOME/tools
48+
Apptainer> sed -i 's/\btar /tar --no-same-owner /g' ci/toolchain_install.sh
49+
Apptainer> ./ci/toolchain_install.sh --all
50+
Apptainer> sed -i 's/\btar --no-same-owner /tar /g' ci/toolchain_install.sh
51+
52+
53+
Apptainer> source ./ci/toolchain_env.sh
54+
Apptainer> verilator --version
55+
```
56+
57+
58+
### Running SIMX, RTLSIM and XRTSIM
59+
```
60+
Compile the Vortex codebase
61+
Apptainer> make -s
62+
63+
Run the programs by specifying the appropriate driver as shown below:
64+
65+
SIMX
66+
Apptainer> ./ci/blackbox.sh --cores=2 --app=demo --driver=simx
67+
68+
RTLSIM
69+
Apptainer> ./ci/blackbox.sh --cores=2 --app=demo --driver=rtlsim
70+
71+
XRTSIM
72+
Apptainer> ./ci/blackbox.sh --cores=2 --app=demo --driver=xrt
73+
```
74+
75+
76+
### Vortex Bitstream on FPGA
77+
78+
Common Commands
3079
```
3180
Apptainer> source /opt/xilinx/xrt/setup.sh
3281
Apptainer> source /tools/reconfig/xilinx/Vitis/2023.1/settings64.sh
3382
3483
Apptainer> platforminfo -l
84+
3585
```
3686

87+
##### Building Vortex Bitstream
88+
89+
```
90+
Apptainer> pwd
91+
/home/vortex/build
92+
93+
Apptainer> source ci/toolchain_env.sh
94+
95+
Apptainer> verilator --version
96+
Verilator 5.026 2024-06-15 rev v5.026-43-g065f36ab5
97+
98+
Apptainer> cd hw/syn/xilinx/xrt
99+
Apptainer> PREFIX=test1 PLATFORM=xilinx_u50_gen3x16_xdma_5_202210_1 TARGET=hw NUM_CORES=1 make > build_u50_hw_1c.log 2>&1 &
100+
Creates ../test1_xilinx_u50_gen3x16_xdma_5_202210_1_hw/bin/vortex_afu.xclbin
101+
```
102+
103+
##### Running Vortex Bitstream on FPGA
104+
```
105+
Apptainer> cd ../../../../
106+
Apptainer> pwd
107+
/home/vortex/build
37108
109+
Apptainer> make -C runtime/ clean
38110
111+
Apptainer> FPGA_BIN_DIR=hw/syn/xilinx/xrt/test1_xilinx_u50_gen3x16_xdma_5_202210_1_hw/bin TARGET=hw PLATFORM=xilinx_u50_gen3x16_xdma_5_202210_1 ./ci/blackbox.sh --driver=xrt --app=demo
39112
113+
Verify following line being printed:
114+
info: device name=xilinx_u50_gen3x16_xdma_base_5, memory_capacity=0x200000000 bytes, memory_banks=32.
115+
```

miscs/apptainer/run_apptainer.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
# Set environment variables with fallback default values.
4+
# The :- means if the variable CONTAINER_IMAGE is not set or is empty, then use the default value vortex.sif
5+
export GIT_REPO_PATH=${GIT_REPO_PATH:-~/USERSCRATCH/vortex}
6+
export CONTAINER_IMAGE=${CONTAINER_IMAGE:-vortex.sif}
7+
export DEVNULL_BIND=${DEVNULL_BIND:-~/USERSCRATCH/devnull}
8+
export VORTEX_TOOLCHAIN_PATH=${VORTEX_TOOLCHAIN_PATH:-~/USERSCRATCH/tools}
9+
10+
# Launch the Apptainer container with the bind mount
11+
apptainer shell --fakeroot --cleanenv --writable-tmpfs \
12+
--bind /dev/bus/usb,/sys/bus/pci \
13+
--bind /projects:/projects \
14+
--bind /lib/firmware:/lib/firmware \
15+
--bind /opt/xilinx/:/opt/xilinx/ \
16+
--bind /tools:/tools \
17+
--bind /netscratch:/netscratch \
18+
--bind "$VORTEX_TOOLCHAIN_PATH":/home/tools \
19+
--bind "$GIT_REPO_PATH":/home/vortex \
20+
"$CONTAINER_IMAGE"
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
Bootstrap: docker
22
From: ubuntu:22.04
33

4-
54
%files
65
install_boost_openssl.sh .
76
openssl-package.deb .
@@ -10,21 +9,19 @@ From: ubuntu:22.04
109
%post
1110
echo "Setting up the environment..."
1211

13-
1412
touch /var/log/apt/term.log
1513
if [ -f /var/log/apt/term.log ]; then
1614
chown root:adm /var/log/apt/term.log || true
1715
fi
1816

19-
2017
# Set environment variable to avoid interactive prompts during installation
2118
export DEBIAN_FRONTEND=noninteractive
2219
echo 'APT::Sandbox::User "root";' > /etc/apt/apt.conf.d/no-sandbox
2320
mkdir -p /netscratch
2421

25-
# Update and install base dependencies
22+
# Update and install base dependencies (including wget here)
2623
apt-get update
27-
apt-get install -y libc6 fakeroot
24+
apt-get install -y libc6 fakeroot wget git vim
2825

2926
# Fix dependency issues
3027
apt-get install -f -y || true
@@ -38,25 +35,23 @@ From: ubuntu:22.04
3835
rm -f /var/lib/dpkg/lock
3936
rm -f /var/cache/apt/archives/lock
4037

41-
# mount -o remount,rw /usr
42-
# mount -o remount,rw /var
38+
# Adjust permissions for dbus helper
4339
chown -R root:root /usr/lib/dbus-1.0/dbus-daemon-launch-helper || true
4440

45-
4641
# Install necessary packages
4742
apt-get install -y fontconfig libfontconfig1 libpangoft2-1.0-0 libbluray2 \
4843
libpangocairo-1.0-0 libavformat58 libpango-1.0-0 \
4944
openjdk-11-jre-headless libcairo2 librsvg2-2 librsvg2-common \
5045
openjdk-11-jre-zero libtheora0 libavcodec58 libcairo-gobject2 \
5146
ca-certificates-java libchromaprint1 software-properties-common perl-modules bzip2 \
52-
unzip zlib1g-dev libtinfo5 g++ usbutils gawk bison gcc make wget tar python3.9 locales zstd uuid-dev git || true
47+
unzip zlib1g-dev libtinfo5 g++ usbutils gawk bison gcc make tar python3.9 locales zstd uuid-dev ccache || true
5348

5449
ln -s /usr/bin/python3 /usr/bin/python
5550

5651
locale-gen en_US.UTF-8
5752
update-locale LANG=en_US.UTF-8 LANGUAGE=en_US.UTF-8 LC_ALL=en_US.UTF-8
5853

59-
# Run dpkg to ensure everything is properly configured
54+
# Run dpkg to ensure configuration is complete
6055
dpkg --configure -a || true
6156

6257
# Clean up apt cache
@@ -65,10 +60,19 @@ From: ubuntu:22.04
6560

6661
echo "Setting up the environment..."
6762

68-
# Copy the installation script into the container
63+
# Install CMake 3.26
64+
echo "Installing CMake 3.26..."
65+
wget https://github.com/Kitware/CMake/releases/download/v3.26.0/cmake-3.26.0-linux-x86_64.sh -O /tmp/cmake.sh
66+
chmod +x /tmp/cmake.sh
67+
mkdir -p /opt/cmake
68+
/tmp/cmake.sh --skip-license --prefix=/opt/cmake
69+
ln -sf /opt/cmake/bin/cmake /usr/local/bin/cmake
70+
rm -f /tmp/cmake.sh
71+
72+
# Copy the boost and openssl installation script into the container
6973
cp install_boost_openssl.sh /tmp/
7074

71-
# Execute the script
75+
# Execute the installation script
7276
chmod +x /tmp/install_boost_openssl.sh
7377
/tmp/install_boost_openssl.sh
7478

@@ -79,19 +83,18 @@ From: ubuntu:22.04
7983
export LANG=en_US.UTF-8
8084
export LANGUAGE=en_US.UTF-8
8185
export LC_ALL=en_US.UTF-8
82-
export HOME=/home/developer
83-
84-
86+
export HOME=/home
87+
export LD_LIBRARY_PATH=/opt/boost-1.66/lib:/opt/openssl-1.1/lib:$LD_LIBRARY_PATH
8588

8689
%runscript
8790
exec /bin/bash
8891

8992
%labels
90-
Author Rahul
91-
Version 1.0
93+
Author Rahul, Udit
94+
Version 2.0
9295

9396
%test
94-
echo "Container test successful!"
9597
locale
9698
lsusb || echo "lsusb not available"
9799
ls -l /dev/null
100+
echo "Container test successful!"

0 commit comments

Comments
 (0)