Use Virtuale, upload only the assignment file named as follows: LAB07_APAI_<name_surname>.pdf
Assignment DEADLINE: Sunday 22/11/2026 (end of day, 23:59)
You are encouraged to work on your own laptop using the provided devcontainer (Option A). If that is not possible, you can use the virtual machine available on the lab machines (Option B).
Requirements: Docker, VSCode and the VSCode Dev Containers extension.
- Open a terminal and clone this repository:
git clone https://github.com/EEESlab/APAI26-LAB07-Tiling
cd APAI26-LAB07-Tiling/
- Open VSCode with
code . - On VSCode, click on 'Reopen in container' (the first time, the container image is downloaded, which may take a while).
- Open a new terminal in VSCode: the PULP SDK is configured automatically.
- Now you're ready to start!
On Windows, install WSL 2 first, and choose the Windows version of Docker Desktop (even if you work with WSL). If VSCode reports that Docker cannot be found, enable the WSL integration in Docker Desktop (Settings -> Resources -> WSL integration), then Apply & Restart.
The Ubuntu-based virtual machine already contains the PULP SDK and VSCode (used only to edit the code and open terminals), so no Docker container is needed.
- From a browser outside the virtual machine, download the lab zip file from Virtuale (the only website reachable from the lab machines) and extract it (right-click -> Extract).
- Go to
C:/VM_APAIand double-clickPULP-box.ova. When VirtualBox opens, click on "Finish"/"Fine". - Once the virtual machine is imported, start it with "Start"/"Avvia".
- Log in with username
pulp-boxand passwordpulp. - From the VirtualBox top bar, open Machine -> File Manager (left panel: files of the PC, right panel: files of the VM). Enter the login credentials at the bottom of the right panel.
- Drag and drop the extracted lab folder into a subdirectory of the VM home directory (you need write rights there).
- Inside the VM, open a terminal and go to the lab folder with
cd. - [DO NOT FORGET] Every time you open a new terminal run:
source setup_pulp_sdk.sh
- Now you're ready to start!
- Select the exercise in inc/main.h (
#define EXERCISE1,EXERCISE2orEXERCISE3, exactly one). - Generate the layer data for C channels and an N x N output (the input is (N + K - 1) x (N + K - 1)):
python3 parameters_generate.py --channels=<C> --output-spatial-dimensions=<N>
- Build and run:
make clean all run
Repeat step 2 every time you change the layer: the generated files (inc/dims.h, inc/input.h, inc/weights.h, inc/output.h) hold the dimensions, the data and the expected output of the layer.
To check your by-hand memory and MAC computations:
python3 mem_MACs_computation.py <C> <N>
Useful notes:
- The code sections to complete are marked with
EXERCISE Ncomments and/* YOUR CODE HERE */. An exercise can have several sections in different files, so search the whole project (Ctrl+Shift+Fin VSCode). - The program prints the performance counters of cluster core 0 around the whole layer (DMA transfers + convolution), then checks the output against the expected one.
- If the layer (or the tile) does not fit in L1, you get
ERROR: L1 allocation failed, the layer (or tile) does not fit in L1 (about 56kB usable). Use a larger tiling factor. - If
TILING_PARAMETERdoes not divide N, you getERROR: TILING_PARAMETER must divide the output spatial dimension N = .... - If the output is wrong (forgotten data regeneration, wrong tile overlap, wrong buffer sizes...), you get
ERROR: first mismatch at index ...followed byReceived ... errors(the total number of wrong output values).
All exercises run a 3x3 convolution (stride 1, no padding, C input = C output channels) on the 8-core PULP cluster, with 64kB of L1 memory (about 56kB usable for the layer buffers, the rest holds the cluster stacks).
| Exercise | Features (set automatically in inc/main.h) | Code to write |
|---|---|---|
| 1 - Profile L1 vs L2 | USE_L1_MEM (comment it out for the L2 runs) |
L1 buffer sizes (src/main.c), performance counters (src/layer_execution.c) |
| 2 - Tiling | USE_L1_MEM, ENABLE_TILING |
TILING_PARAMETER (src/main.c), single-buffered tile loop (src/layer_execution.c), tile overlap in tile_load() (src/kernel.c) |
| 3 - Double buffering | USE_L1_MEM, ENABLE_TILING, DOUBLE_BUFFERING |
double-buffered L1 buffer sizes (src/main.c), double-buffered tile loop (src/layer_execution.c) |
The functions to load a tile, run the kernel, store a tile and wait for the DMA are in src/kernel.c (see inc/kernel.h); the convolution kernel itself comes from PULP-NN (src/pulp_nn_conv.c).