161 lines
5.6 KiB
Markdown
161 lines
5.6 KiB
Markdown
# fossbench
|
|
|
|
fossbench is an open-source CPU benchmark with nine assembly workloads and a
|
|
small C driver. It measures each workload twice: once on a single core and once
|
|
across every available core. The final report includes separate single-core and
|
|
multicore scores.
|
|
|
|
The repository currently builds an executable named `fossmark` for ARM64 and
|
|
x86-64. The C driver handles timing, memory, threads, output, and scoring. The
|
|
performance-sensitive kernels live in architecture-specific assembly files.
|
|
|
|
## Workloads
|
|
|
|
| Test | What it measures |
|
|
|---|---|
|
|
| Integer math | 64-bit multiplication, division, shifts, and bit operations |
|
|
| Floating point math | Scalar double-precision multiplication, addition, division, and square roots |
|
|
| Prime numbers | A sieve of Eratosthenes up to 2,000,000 |
|
|
| Extended instructions | 128-bit SIMD integer and floating point work using NEON or SSE2 |
|
|
| Compression | An LZ77 match finder over a 4 MiB generated corpus |
|
|
| Encryption | ChaCha20 with 20 rounds over a 1 MiB buffer |
|
|
| Physics | Direct-sum gravity for 512 bodies |
|
|
| Sorting | In-place heapsort of one million 32-bit integers |
|
|
| Memory latency | Dependent pointer chasing through a private 16 MiB cycle |
|
|
|
|
The benchmark increases each test's iteration count until one run takes at
|
|
least two seconds. It then keeps the fastest of three runs. Each kernel returns
|
|
a checksum, and fossbench stops if repeated runs produce different results.
|
|
|
|
During the multicore pass, every thread gets its own mutable workspace. This
|
|
keeps the kernels free of data races and prevents shared scratch buffers from
|
|
distorting the result.
|
|
|
|
## Build and run
|
|
|
|
You need a C compiler, GNU Make, pthreads, and the system math library.
|
|
|
|
```sh
|
|
make
|
|
make bench
|
|
```
|
|
|
|
`make` builds a binary for the host at
|
|
`dist/fossmark-<os>-<arch>`. `make bench` builds that binary and runs it.
|
|
|
|
Other targets are available for explicit platforms and architectures:
|
|
|
|
```sh
|
|
make linux-arm64
|
|
make linux-amd64
|
|
make macos-arm64
|
|
make macos-amd64
|
|
make all
|
|
```
|
|
|
|
`make all` builds both Linux targets. Cross-compilation requires a suitable
|
|
toolchain. Override the target compiler when its name differs from the default:
|
|
|
|
```sh
|
|
make linux-arm64 CC_ARM64=aarch64-linux-gnu-gcc
|
|
make linux-amd64 CC_AMD64=x86_64-linux-gnu-gcc
|
|
```
|
|
|
|
Apple Clang can build either macOS architecture with `-arch`. Windows timing
|
|
and allocation code exists in the driver, but the Makefile does not include a
|
|
Windows target and the x86-64 assembly currently follows the System V ABI.
|
|
|
|
Run the benchmark with extra per-test details by passing `--verbose`:
|
|
|
|
```sh
|
|
./dist/fossmark-linux-amd64 --verbose
|
|
```
|
|
|
|
The exact filename depends on the host platform and architecture.
|
|
|
|
## Continuous integration and releases
|
|
|
|
Pushing a Git tag runs the GitHub Actions build and correctness tests. If they
|
|
succeed, the workflow creates a GitHub Release named `Release <tag name>` with
|
|
Linux and macOS archives for AMD64 and ARM64, plus a `SHA256SUMS` file.
|
|
|
|
## Scores
|
|
|
|
Each workload receives a score relative to a reference rate:
|
|
|
|
```text
|
|
test score = 10000 * measured rate / reference rate
|
|
```
|
|
|
|
The single-core and multicore totals are weighted geometric means of the nine
|
|
test scores. Both passes use the same reference rates and weights, so their
|
|
ratio gives a direct view of scaling across the machine's available cores.
|
|
|
|
| Test | Weight |
|
|
|---|---:|
|
|
| Integer math | 20% |
|
|
| Memory latency | 16% |
|
|
| Compression | 14% |
|
|
| Sorting | 12% |
|
|
| Extended instructions | 11% |
|
|
| Floating point math | 9% |
|
|
| Encryption | 8% |
|
|
| Prime numbers | 6% |
|
|
| Physics | 4% |
|
|
|
|
The reference rates, weights, target score, workload sizes, calibration floor,
|
|
and repeat count are compile-time constants in `src/main.c`. Changing them
|
|
creates a different benchmark profile, so scores from that build should not be
|
|
compared with scores from the default build.
|
|
|
|
Memory latency is displayed as nanoseconds per access, but its score uses the
|
|
underlying pointer-chase throughput. Latency results are sensitive to memory
|
|
placement and operating-system activity, so some variation between runs is
|
|
normal.
|
|
|
|
## Architecture support
|
|
|
|
The assembly kernels use only baseline instructions for their architecture:
|
|
|
|
* `src/fossmark.S` uses ARMv8-A and NEON under AAPCS64.
|
|
* `src/fossmark_x86_64.S` uses baseline x86-64 and SSE2 under the System V ABI.
|
|
|
|
The kernel files contain no system calls or calls into the C library. The same
|
|
ARM64 source can be assembled for Linux, macOS, Windows, and BSD object formats.
|
|
The current x86-64 source supports Linux, macOS, and the BSDs that use the
|
|
System V calling convention.
|
|
|
|
One binary cannot run on every supported target because operating systems and
|
|
architectures use different executable formats and instruction sets. Build a
|
|
separate binary for each operating system and architecture pair.
|
|
|
|
## Tests
|
|
|
|
The correctness suite checks all nine kernels against C reference
|
|
implementations, known answers, or invariants. Most checks also run concurrently
|
|
on every available core to catch shared-state and reentrancy bugs.
|
|
|
|
```sh
|
|
make test
|
|
```
|
|
|
|
The suite covers the RFC 8439 ChaCha20 test vector, prime counts, sorting output,
|
|
physics momentum, pointer-chase behavior, and deterministic results. It exits
|
|
with a nonzero status if any check fails.
|
|
|
|
## Source layout
|
|
|
|
```text
|
|
src/main.c portable benchmark driver and scoring
|
|
src/fossmark.S ARM64 kernels
|
|
src/fossmark_x86_64.S x86-64 kernels
|
|
src/test_kernels.c correctness suite
|
|
Makefile native and cross-build targets
|
|
dist/ generated binaries
|
|
```
|
|
|
|
## License
|
|
|
|
No license file is included in this repository yet. Add one before distributing
|
|
fossbench or accepting outside contributions as an open-source project.
|