Skip to content

Commit

Permalink
[snippy] refactor memory scheme
Browse files Browse the repository at this point in the history
This patch makes memory scheme exclusively a configuration class and
strips if of all sampling duties. This allows for clear separation of
concerns as we now use separate Sampler class to deal with random
address sampling. Attributes were simplified a lot. Memory sampling
error reports were greatly improved.Memory scheme dumps were simplified
and now produce reusable YAML
  • Loading branch information
arrv-sc authored and sc-sw-publisher committed Nov 7, 2024
1 parent de7e507 commit 186a04a
Show file tree
Hide file tree
Showing 33 changed files with 1,184 additions and 1,158 deletions.
22 changes: 12 additions & 10 deletions llvm/test/tools/llvm-snippy/RV64DefaultMemScheme.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# RUN: llvm-snippy %s -march=riscv64-linux-gnu --dump-layout -o %t 2>&1 | FileCheck %s
# RUN: llvm-snippy %s -o %t 2>&1 | FileCheck %s

options:
march: riscv64-unknown-elf
dump-rand-mem-accesses: true

sections:
- no: 1
Expand Down Expand Up @@ -31,12 +35,10 @@ histogram:
- [LW, 10.0]
- [SW, 10.0]

# CHECK: Memory access scheme:
# CHECK-NEXT: Memory access 0:
# CHECK-NEXT: Memory range:
# CHECK-NEXT: Weight: 1
# CHECK-NEXT: Start: 2147483648
# CHECK-NEXT: Size: 4194304
# CHECK-NEXT: Stride: 8
# CHECK-NEXT: FirstOffset: 0
# CHECK-NEXT: LastOffset: 0
# CHECK: access-ranges:
# CHECK-NEXT: - weight: 1
# CHECK-NEXT: start: 0x80000000
# CHECK-NEXT: size: 0x400000
# CHECK-NEXT: stride: 0x8
# CHECK-NEXT: first-offset: 0x0
# CHECK-NEXT: last-offset: 0x0
188 changes: 69 additions & 119 deletions llvm/test/tools/llvm-snippy/memory-scheme/access-weighted-groups.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,122 +81,72 @@ access-groups:
last-offset: 2
weight: 4


# CHECK: Memory access 0:
# CHECK-NEXT: Memory eviction:
# CHECK-NEXT: Weight: 1
# CHECK-NEXT: Mask: 0x3c0000
# CHECK-NEXT: Fixed: 0x80000000

# CHECK: Memory access 1:
# CHECK-NEXT: Memory eviction:
# CHECK-NEXT: Weight: 2
# CHECK-NEXT: Mask: 0xbe000
# CHECK-NEXT: Fixed: 0x80001000

# CHECK: Memory access 2:
# CHECK-NEXT: Memory eviction:
# CHECK-NEXT: Weight: 1
# CHECK-NEXT: Mask: 0x3c0000
# CHECK-NEXT: Fixed: 0x80000000

# CHECK: Memory access 3:
# CHECK-NEXT: Memory range:
# CHECK-NEXT: Weight: 4.5
# CHECK-NEXT: Start: 2147491840
# CHECK-NEXT: Size: 4096
# CHECK-NEXT: Stride: 16
# CHECK-NEXT: FirstOffset: 1
# CHECK-NEXT: LastOffset: 2

# CHECK: Memory access 4:
# CHECK-NEXT: Memory range:
# CHECK-NEXT: Weight: 12
# CHECK-NEXT: Start: 2147500032
# CHECK-NEXT: Size: 512
# CHECK-NEXT: Stride: 8
# CHECK-NEXT: FirstOffset: 4
# CHECK-NEXT: LastOffset: 6

# CHECK: Memory access 5:
# CHECK-NEXT: Memory addresses:
# CHECK-NEXT: Weight: 7.5
# CHECK-NEXT: Ordered: 1
# CHECK-NEXT: Plain:
# CHECK-NEXT: - Addr: 0x80200000
# CHECK-NEXT: Access-size: 16
# CHECK-NEXT: - Addr: 0x80201234
# CHECK-NEXT: Access-size: 16
# CHECK-NEXT: - Addr: 0x802020bc
# CHECK-NEXT: Access-size: 16

# CHECK: Memory access 6:
# CHECK-NEXT: Memory addresses:
# CHECK-NEXT: Weight: 3
# CHECK-NEXT: Ordered: 0
# CHECK-NEXT: Plain:
# CHECK-NEXT: - Addr: 0x80200050
# CHECK-NEXT: Access-size: 12

# CHECK: Memory access 7:
# CHECK-NEXT: Memory addresses:
# CHECK-NEXT: Weight: 9
# CHECK-NEXT: Ordered: 1
# CHECK-NEXT: Plain:
# CHECK-NEXT: - Addr: 0x80200f00
# CHECK-NEXT: Access-size: 16

# CHECK: Memory access 8:
# CHECK-NEXT: Memory eviction:
# CHECK-NEXT: Weight: 5
# CHECK-NEXT: Mask: 0x3c0000
# CHECK-NEXT: Fixed: 0x80000000

# CHECK: Memory access 9:
# CHECK-NEXT: Memory eviction:
# CHECK-NEXT: Weight: 10
# CHECK-NEXT: Mask: 0xbe000
# CHECK-NEXT: Fixed: 0x80001000

# CHECK: Memory access 10:
# CHECK-NEXT: Memory eviction:
# CHECK-NEXT: Weight: 5
# CHECK-NEXT: Mask: 0x3c0000
# CHECK-NEXT: Fixed: 0x80000000

# CHECK: Memory access 11:
# CHECK-NEXT: Memory addresses:
# CHECK-NEXT: Weight: 10
# CHECK-NEXT: Ordered: 1
# CHECK-NEXT: Plain:
# CHECK-NEXT: - Addr: 0x80200000
# CHECK-NEXT: Access-size: 16
# CHECK-NEXT: - Addr: 0x80201234
# CHECK-NEXT: Access-size: 16
# CHECK-NEXT: - Addr: 0x802020bc
# CHECK-NEXT: Access-size: 16

# CHECK: Memory access 12:
# CHECK-NEXT: Memory addresses:
# CHECK-NEXT: Weight: 17.5
# CHECK-NEXT: Ordered: 0
# CHECK-NEXT: Plain:
# CHECK-NEXT: - Addr: 0x80200050
# CHECK-NEXT: Access-size: 12

# CHECK: Memory access 13:
# CHECK-NEXT: Memory addresses:
# CHECK-NEXT: Weight: 5
# CHECK-NEXT: Ordered: 1
# CHECK-NEXT: Plain:
# CHECK-NEXT: - Addr: 0x80200f00
# CHECK-NEXT: Access-size: 16

# CHECK: Memory access 14:
# CHECK-NEXT: Memory range:
# CHECK-NEXT: Weight: 0
# CHECK-NEXT: Start: 2147491840
# CHECK-NEXT: Size: 4096
# CHECK-NEXT: Stride: 16
# CHECK-NEXT: FirstOffset: 1
# CHECK-NEXT: LastOffset: 2
# CHECK: access-ranges:
# CHECK-NEXT: - weight: 4.5
# CHECK-NEXT: start: 0x80002000
# CHECK-NEXT: size: 0x1000
# CHECK-NEXT: stride: 0x10
# CHECK-NEXT: first-offset: 0x1
# CHECK-NEXT: last-offset: 0x2
# CHECK-NEXT: - weight: 12
# CHECK-NEXT: start: 0x80004000
# CHECK-NEXT: size: 0x200
# CHECK-NEXT: stride: 0x8
# CHECK-NEXT: first-offset: 0x4
# CHECK-NEXT: last-offset: 0x6
# CHECK-NEXT: - weight: 0
# CHECK-NEXT: start: 0x80002000
# CHECK-NEXT: size: 0x1000
# CHECK-NEXT: stride: 0x10
# CHECK-NEXT: first-offset: 0x1
# CHECK-NEXT: last-offset: 0x2
# CHECK: access-evictions:
# CHECK-NEXT: - weight: 1
# CHECK-NEXT: mask: 0x3C0000
# CHECK-NEXT: fixed: 0x80000000
# CHECK-NEXT: - weight: 2
# CHECK-NEXT: mask: 0xBE000
# CHECK-NEXT: fixed: 0x80001000
# CHECK-NEXT: - weight: 1
# CHECK-NEXT: mask: 0x3C0000
# CHECK-NEXT: fixed: 0x80000000
# CHECK-NEXT: - weight: 5
# CHECK-NEXT: mask: 0x3C0000
# CHECK-NEXT: fixed: 0x80000000
# CHECK-NEXT: - weight: 10
# CHECK-NEXT: mask: 0xBE000
# CHECK-NEXT: fixed: 0x80001000
# CHECK-NEXT: - weight: 5
# CHECK-NEXT: mask: 0x3C0000
# CHECK-NEXT: fixed: 0x80000000
# CHECK: access-addresses:
# CHECK-NEXT: - weight: 7.5
# CHECK-NEXT: ordered: true
# CHECK-NEXT: plain:
# CHECK-NEXT: - addr: 0x80200000
# CHECK-NEXT: - addr: 0x80201234
# CHECK-NEXT: - addr: 0x802020BC
# CHECK-NEXT: - weight: 3
# CHECK-NEXT: ordered: false
# CHECK-NEXT: plain:
# CHECK-NEXT: - addr: 0x80200050
# CHECK-NEXT: access-size: 12
# CHECK-NEXT: - weight: 9
# CHECK-NEXT: ordered: false
# CHECK-NEXT: plain:
# CHECK-NEXT: - addr: 0x80200F00
# CHECK-NEXT: - weight: 10
# CHECK-NEXT: ordered: true
# CHECK-NEXT: plain:
# CHECK-NEXT: - addr: 0x80200000
# CHECK-NEXT: - addr: 0x80201234
# CHECK-NEXT: - addr: 0x802020BC
# CHECK-NEXT: - weight: 17.5
# CHECK-NEXT: ordered: false
# CHECK-NEXT: plain:
# CHECK-NEXT: - addr: 0x80200050
# CHECK-NEXT: access-size: 12
# CHECK-NEXT: - weight: 5
# CHECK-NEXT: ordered: false
# CHECK-NEXT: plain:
# CHECK-NEXT: - addr: 0x80200F00
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ access-evictions:
fixed: 0x80000010
weight: 0

# CHECK: error: Memory schemes are too restrictive to generate the requested instructions. Size: 1 Alignment: 1
# CHECK: error: Cannot sample memory access for instruction
# CHECK: Memory schemes are to restrictive to generate access (size: 1, alignment: 1)
Loading

0 comments on commit 186a04a

Please sign in to comment.