Repository navigation
Store completion tables with the rows innermost - #1069
Merged
Merged
Conversation
A scan looks up the completion bounds of one prefix for consecutive rows s, with the same values on each block. With each row's tables contiguous, these lookups were offsets[-1] bytes apart and each missed the caches. Index the tables as (offsets[b] + x) * (num_rows - 1) + s instead, so that they share cache lines. The stored bounds, the decisions made from them, and the cost model are unchanged. The fill collects the tables of up to 64 rows in a tile and transposes it into place, reading the tile a word at a time. A test checks the bounds of a basis of more rows than one tile holds against their definition. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Tables without blocks, such as NO_TABLES and the tables of tails without ones, have offsets[-1] == 0, so counting their rows divided by zero. Return the bound zero for them before counting, as the lookup did before the rows moved innermost. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The test of a basis of many rows checked one random bound from each row of its tables, on blocks of four columns. Check instead every entry of the tables against the least weight of each value plus two rows, found by enumerating the pairs on each block. The tails cover the cases of the transposing fill: fewer and more rows of tables than the 64 that it transposes at once, blocks of fewer than eight values and of 256 values, and narrower last blocks. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Check the bounds that completion tables give from every row, not only their entries, against the least weights found by enumerating pairs. Replace the tails of fewer rows of tables than one tile with tails of three tiles, so that rows past the first 128 are stored and looked up, and add tails with an entry of 16, the largest distance. Fill storage that starts with a value that no entry takes, so that entries left unwritten show, and fill a strided view, so that the tables fill the storage given and leave the bytes between them unchanged. Drop the tails of 66 rows, whose cases the others cover. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Check every entry and every bound of completion tables for each combination of 130 or 258 rows, which cross tiles of rows and row 256, and blocks of 1, 2 or 8 columns, so that rows of tables of several words cross tiles too. Fill both contiguous storage and every other byte of storage, check that the bytes between entries stay unchanged, and look the bounds up in the strided tables. This covers the case of strided storage of the test of building in place, which is dropped. Compute the least weights from each row by adding the pairs of that row to those from the next row, so that 258 rows stay quick as plain Python. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add tails of 65 rows on blocks of one column, whose 64 rows of tables fill exactly one tile, to the cases whose every entry and bound are checked, and keep of the larger tails only those of 258 rows. Fill every other byte of storage backward instead of forward, so that the tables and their bounds are also checked with a negative stride. Bound the tables without blocks with their own block width, which is zero for NO_TABLES. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Draw the cases whose every entry and bound are checked at random: row counts that straddle the tiles of 64 rows of tables, column counts that straddle the words of 64 columns, blocks of 1, 2 or 8 columns, and sparse tails, so that rows differ and single ones fall in late rows and columns. Each seed has a full last tile, a later partial tile of several rows, more than 256 rows, and later tiles of blocks past the first word or of more than four words, and fills contiguous and reversed storage. These replace the fixed cases of 258 and 65 rows. Check that the byte shifts take each byte of a word to its lowest byte on machines of either byte order, from copies of the module imported as if on each. Check also that a bound stopped early at a limit is at most the bound and at least the smaller of the bound and the limit. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add later tiles of blocks of sixteen columns, whose tile rows hold more than 64 words, to the random cases whose every entry and bound are checked. Fill tables as plain Python from copies of the module imported as if on machines of either byte order, with words that view memory in that order, and check their entries and bounds, instead of checking only the byte shifts. Fill every other byte of storage forward through the build, and check the bytes between entries and the bounds from every row. Check also the bounds of two equal rows of 260 ones, which pass the largest byte, with the contract of early stops at every limit. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Check one fixed case of a full and a partial tile of 64 rows, natively and as on a big-endian machine, and drop the cases that the existing tests already guard or that test behavior this change leaves unchanged. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
The Brouwer-Zimmermann scan looks up the completion bounds of one prefix for consecutive rows
sof a search basis, with the same values on each block. The completion tables stored each row's tables contiguously, so these lookups wereoffsets[-1]bytes apart and each one missed the caches. On codes whose search spends its time in tabled layers, these lookups took 56-100 ns each and most of the search's time. Examples are a [[232,...]] pair-partition code, a lifted-product code, and a hypergraph-product code of gross-code size.Changes
completion_bounds.pyindexes the tables as(offsets[b] + x) * (num_rows - 1) + s, so that the lookups of one prefix share cache lines. The fill collects the tables of up to 64 rows in a tile and transposes it into place, reading the tile a word at a time. Tables without blocks, which haveoffsets[-1] == 0, return the bound zero before any row arithmetic, as the lookup did before. The stored bounds, the decisions made from them, and the cost model are unchanged. Section 3.9 ofbrouwer_zimmermann.mddescribes the layout.Validation
On 39 small and medium codes, distances by both methods equal the baseline, the literature, and each other. The numbers of supports weighed, lookups and skips per layer are identical on three instances. A test checks the bounds of every row and block of a 67-row basis, more rows than one tile holds, against their definition, and one checks tables without blocks.
Brouwer-Zimmermann distance searches, 1 thread, warm; paired runs, medians of 3:
Building the tables takes about 1.6 times as long, which is tens of milliseconds on these codes.