Debian Codegraph @

tests/workloads/pointer_chasing/README.md

raw symbols SCIP
1 # Pointer Chasing Workload
2
3 ## Overview
4
5 The pointer chasing workload is designed to stress the CPU's memory hierarchy by following a chain
6 of pointers through memory in a pseudo-random pattern.
7
8 ### Core Concept
9
10 The workload creates a linked list where nodes are distributed randomly throughout a large memory
11 buffer. When executed, the CPU must follow pointer chains, causing cache misses and memory stalls.
12 The buffer and span sizes can be customized to target specific hierarchies in the cache subsystem,
13 or sized sufficiently large for main memory.
14
15 ### Key Components
16
17 1. **Data Structure (`ptr_node`)**
18
19 - 64-byte aligned union containing a pointer to the next node and a value
20
21 2. **Setup Phase (`ptr_chase_setup`)**
22
23 - Parses buffer size and span size from command line arguments
24 - Allocates memory and creates a randomized linked list
25 - Buffer size: Total memory allocated
26 - Span size: Used in conjunction with `CACHE_LINE_SIZE` to determine how many linked list nodes
27 are traversed
28
29 3. **Linked List Generation (`createLinkedList`)**
30
31 - Creates a pseudo-random chain of pointers within the specified span
32 - Uses a seeded random number generator for reproducible results
33 - Ensures each node is visited exactly once
34
35 4. **Execution (`run_ptr_chasing`)**
36 - Follows the pointer chain using optimized assembly code
37 - Assembly loop continues until reaching a NULL pointer
38
39 ### Assembly Implementation
40
41 The core loop is implemented in assembly for precise control:
42
43 ```assembly
44 __chasing_code_loop:
45 mov (%rax), %rax ; Load next pointer
46 test %rax, %rax ; Check if NULL
47 jne __chasing_code_loop ; Continue if not NULL
48 ret ; Return when done
49 ```
50
51 ### ptr_chase_setup parameters
52
53 The `ptr_chase_setup` function expects two arguments:
54
55 - **Buffer Size**: Total memory allocated (in hexadecimal)
56 - **Span Size**: Used in conjunction with `CACHE_LINE_SIZE` to determine how many linked list
57 nodes are traversed. As span size approaches buffer size, it will take longer
58 to create the LinkedList. Recommended to keep buffer size slightly larger than
59 span size.
60
61 In the `tests/busypolling_1ms_rtworkload` example, the following values are used:
62
63 - Buffer size: 0x4A4000 (~4.6MB total allocation)
64 - Span size: 0x129000 (~1.2MB used for linked list)
65
66 ## Example RTC-Testbench configuration file for pointer chasing
67
68 See `tests/busypolling_1ms_rtworkload/mirror_vid100_cml.yaml`.
69
70 ## Build Instructions
71
72 From the main project build directory:
73
74 ```bash
75 make pointer_chasing # Build shared library
76 ```
77
78 ## Copyright
79
80 Copyright (C) 2025 Intel Corporation
81
82 ## License
83
84 BSD-2 Clause and Dual BSD/GPL for all eBPF programs