|
1 | 1 | # Builtin Atomics Verification |
2 | 2 |
|
3 | | -## Prerequisites |
| 3 | +`vatomic` ships a Boogie-based pipeline that checks each atomic primitive |
| 4 | +against the VSync Memory Model. This directory contains the scripts and |
| 5 | +templates that power the `build_boogie_*` targets exposed by CMake. |
4 | 6 |
|
5 | | -To run the verification scripts, one needs to have *Ruby*, *Rust*, *Boogie* and *Z3* installations. To run the verification with parallelism, the `parallel` gem is also needed and can be installed by |
6 | | -``` |
7 | | - gem install parallel |
8 | | -``` |
| 7 | +## Dependencies |
9 | 8 |
|
10 | | -## Generating the assembly file |
| 9 | +The verification targets are available when configuring the project with |
| 10 | +`VATOMIC_DEV=ON` (the default for top-level builds). Locally you will need: |
11 | 11 |
|
12 | | -The assembly file with the builtin atomics can be generated by: |
| 12 | +- CMake (>= 3.16) and a build backend (Ninja or Make) |
| 13 | +- A Rust toolchain (`cargo`) to build the assembly parser/generator in |
| 14 | + `verify/src` |
| 15 | +- Boogie CLI (`boogie`) and its SMT solver dependency (Z3) |
| 16 | +- Cross compilers: `aarch64-linux-gnu-gcc` (ARMv8) and |
| 17 | + `riscv64-linux-gnu-gcc` (RISC-V) |
13 | 18 |
|
14 | | -``` |
15 | | - aarch64-linux-gnu-gcc -DVATOMIC_BUILTINS -O2 -x c include/vsync/atomic.h -Iinclude -fkeep-inline-functions -S -mno-outline-atomics -o atomics.s |
16 | | -``` |
17 | | - The `atomics.s` file should be located in the `armv8` subfolder |
| 19 | +> Tip: CI uses the container image `ghcr.io/open-s4c/vatomic/boogie-ci:latest`, |
| 20 | +> which bundles all of the above. You can pull it locally if you prefer a |
| 21 | +> hermetic environment. |
18 | 22 |
|
19 | | - ## Running the verification |
| 23 | +## Running the verification suite |
20 | 24 |
|
21 | | - To start the verification for the builtin armv8 atomics, you need a list of functions that should be checked. You can find the lists organized by prefixes in the `lists` subfolder. |
| 25 | +1. Configure the project and enable developer targets: |
22 | 26 |
|
23 | | - The verification for a specific `list.txt` can be started by: |
| 27 | + ```sh |
| 28 | + cmake -S . -B build -DVATOMIC_DEV=ON |
| 29 | + ``` |
24 | 30 |
|
25 | | - ``` |
26 | | - ruby verify_all.rb -a armv8 -s list.txt |
27 | | - ``` |
| 31 | +2. Build one (or all) Boogie targets. Available options are `lse`, `llsc`, |
| 32 | + `lxe`, and `no_polite_await`. |
28 | 33 |
|
29 | | -A specific function `func` can be verified by (git specifying that the boogie files should be generated in `output_folder`): |
| 34 | + ```sh |
| 35 | + cmake --build build --target build_boogie_lse |
| 36 | + ``` |
30 | 37 |
|
31 | | -``` |
32 | | - ruby verify_all.rb -a armv8 -f func -o output_folder |
33 | | -``` |
| 38 | + Each target: |
| 39 | + |
| 40 | + - Preprocesses `vsync/atomic.h` with the chosen compiler flags to obtain |
| 41 | + `atomic.s` (and optionally sanitises it via `cleaner.sh`). |
| 42 | + - Runs the Rust generator (`cargo run` via `generate.sh`) to parse the |
| 43 | + assembly and emit Boogie (`.bpl`) files. |
| 44 | + - Instantiates the templates under `verify/boogie/templates`. |
| 45 | + - Executes Boogie to prove each atomic operation (driven by `verify.sh`). |
| 46 | + |
| 47 | +3. Inspect results via CTest or directly in the generated logs: |
| 48 | + |
| 49 | + ```sh |
| 50 | + ctest --test-dir build/verify -R lse --output-on-failure |
| 51 | + # Logs: build/verify/lse/*.log |
| 52 | + ``` |
| 53 | + |
| 54 | +## Customising the toolchain |
| 55 | + |
| 56 | +- Pass `-DARMV8_CMAKE_C_COMPILER=/path/to/aarch64-linux-gnu-gcc` or |
| 57 | + `-DRISCV_CMAKE_C_COMPILER=/path/to/riscv64-linux-gnu-gcc` to override the |
| 58 | + default cross compilers. |
| 59 | +- Set `BPL`/`Z3_EXE` or adjust `PATH` so Boogie and Z3 are discoverable. |
| 60 | +- Export `CARGO` to point at a specific `cargo` binary when multiple toolchains |
| 61 | + coexist on the system. |
| 62 | + |
| 63 | +## Maintaining the function list |
| 64 | + |
| 65 | +The list of verified entry points lives in `atomics_list.txt`. When adding new |
| 66 | +atomic primitives, make sure to update that file so the verification targets |
| 67 | +cover the new functions. See [boogie/templates/README.md][] for details about |
| 68 | +the available templates and how they correspond to atomic behaviour. |
| 69 | + |
| 70 | +[boogie/templates/README.md]: boogie/templates/README.md |
0 commit comments