Nugget
Loading...
Searching...
No Matches
Functions | Variables
gen Namespace Reference

Functions

 copy_fn (B, U)
 
 set_fn (U)
 
 build ()
 

Variables

str LICENSE
 
list COPIES = [(2, 2), (4, 4), (8, 8), (8, 16), (8, 32), (2, 32), (4, 32), (16, 16), (16, 32)]
 
list SETS = [1, 2, 4, 8, 16, 32, 64]
 
list TREGS = ["$t%d" % i for i in range(8)]
 
list SREGS = ["$s%d" % i for i in range(8)]
 
 text = build()
 
 cur = open("kernels.s").read()
 

Detailed Description

Regenerates kernels.s.

The sweep is a grid, so its assembly is data: nine copy kernels crossing batch
depth with unroll depth, seven set kernels, and an icache-sized block of nops.
Writing those by hand is 1700 lines of transcription and every one of them is a
chance to get an offset wrong - which is the bug the whole test exists to find.
Edit the COPIES and SETS lists below and re-run; do not hand-edit kernels.s.

    ./gen.py            rewrite kernels.s
    ./gen.py --check    exit non-zero if kernels.s is not what this would write

Function Documentation

◆ build()

gen.build ( )

◆ copy_fn()

gen.copy_fn (   B,
  U 
)
B words loaded before any is stored, U words per loop iteration.

Both pointers are bumped at the top and the block is addressed with negative
displacements, so the branch delay slot can carry the block's final store
and the loop tail is 2 addiu + 1 bltu with nothing wasted. The loop ends on
start + count-with-remainder-removed; see the note in memory-s.s about why
it must not be written as end - blocksize.

◆ set_fn()

gen.set_fn (   U)

Variable Documentation

◆ COPIES

list gen.COPIES = [(2, 2), (4, 4), (8, 8), (8, 16), (8, 32), (2, 32), (4, 32), (16, 16), (16, 32)]

◆ cur

gen.cur = open("kernels.s").read()

◆ LICENSE

str gen.LICENSE
Initial value:
1= """/*
2
3MIT License
4
5Copyright (c) 2026 PCSX-Redux authors
6
7Permission is hereby granted, free of charge, to any person obtaining a copy
8of this software and associated documentation files (the "Software"), to deal
9in the Software without restriction, including without limitation the rights
10to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11copies of the Software, and to permit persons to whom the Software is
12furnished to do so, subject to the following conditions:
13
14The above copyright notice and this permission notice shall be included in all
15copies or substantial portions of the Software.
16
17THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23SOFTWARE.
24
25*/
26"""

◆ SETS

list gen.SETS = [1, 2, 4, 8, 16, 32, 64]

◆ SREGS

list gen.SREGS = ["$s%d" % i for i in range(8)]

◆ text

gen.text = build()

◆ TREGS

list gen.TREGS = ["$t%d" % i for i in range(8)]