sim_pipe/
lib.rs

1// Copyright (c) 2025 Graphcore Ltd. All rights reserved.
2
3//! Simulate a flow-controlled pipeline.
4//!
5//! This allows the user to understand the performance impact on the pipeline
6//! of different parameters like buffer size and credit delay.
7//!
8//! The simulation will create:
9//! ```text
10//!  Source -> Limiter -> FcPipeline -> Limiter -> Sink
11//! ```
12//!
13//! # Examples
14//!
15//! Running a basic simulation
16//! ```text
17//! cargo run --bin sim-pipe --release -- --kib-to-send 1024 --stdout
18//! ```
19//!
20//! # Impact of buffer size
21//!
22//! In order to see the impact of buffer size has on the throughput you can
23//! run with simulations with different buffer sizes.
24//!
25//! If you use the default parameters you will get a pipeline which has a
26//! bandwidth of 128-bits per cycle and frames that are 128-bit (8-byte header,
27//! 8-byte payload). So the pipe will carry an entire frame every cycle.
28//!
29//! The default pipe has a 10-entry buffer and a latency in both directions
30//! (data and credit) of 5 ticks. This results in a maximum data rate of the
31//! 14.9GiB/s.
32//! ```text
33//! cargo run --bin sim-pipe --release -- --kib-to-send 1024 --stdout --progress
34//! ```
35//!
36//! However, if you reduce the size of the buffer in the pipeline then you will
37//! see the effective data rate reduce:
38//! ```text
39//! cargo run --bin sim-pipe --release -- --kib-to-send 1024 --stdout --progress --pipe-buffer-entries 9
40//! ```
41//!
42//! In order to observe the bubbles in the pipeline you can use perfetto logs:
43//! ```text
44//! cargo run --bin sim-pipe --release -- --kib-to-send 1024 --stdout --progress --pipe-buffer-entries 9 --perfetto
45//! ```
46//! Then browse to <https://ui.perfetto.dev> and open the `trace.pftrace` file
47//! that will have been generated. Within the `top::pipe::credit_pipe` row you
48//! will see that it drops below the maximum value.
49
50pub mod frame_gen;