pacman.operations.router_compressors package¶

Module contents¶

class pacman.operations.router_compressors.AbstractCompressor(ordered=True)[source]

Bases: object

MAX_SUPPORTED_LENGTH = 1023
__call__(router_tables, target_length=None)[source]
Parameters: router_tables (MulticastRoutingTables) – target_length (int) – MulticastRoutingTables
compress_table(router_table)[source]
Parameters: router_table (UnCompressedMulticastRoutingTable) – Original routing table for a single chip Raw compressed routing table entries for the same chip list(Entry)
compress_tables(router_tables, progress)[source]

Compress all the unordered routing tables

Tables who start of smaller than target_length are not compressed

Parameters: router_tables (MulticastRoutingTables) – Routing tables progress (ProgressBar) – Progress bar to show while working The compressed but still unordered routing tables MulticastRoutingTables MinimisationFailedError – on failure
static intersect(key_a, mask_a, key_b, mask_b)[source]

Return if key-mask pairs intersect (i.e., would both match some of the same keys).

For example, the key-mask pairs 00XX and 001X both match the keys 0010 and 0011 (i.e., they do intersect):

>>> intersect(0b0000, 0b1100, 0b0010, 0b1110)
True


But the key-mask pairs 00XX and 11XX do not match any of the same keys (i.e., they do not intersect):

>>> intersect(0b0000, 0b1100, 0b1100, 0b1100)
False

merge(entry1, entry2)[source]

Merges two entries/triples into one that covers both

The assumption is that they both have the same known spinnaker_route

Parameters: entry1 (Entry) – Key, Mask, defaultable from the first entry entry2 (Entry) – Key, Mask, defaultable from the second entry Key, Mask, defaultable from merged entry tuple(int, int, bool)
ordered
class pacman.operations.router_compressors.CheckedUnorderedPairCompressor[source]

Bases: pacman.operations.router_compressors.unordered_pair_compressor.UnorderedPairCompressor

A version of the pair compressor that does not consider order but does check the lengths

There is no known case where this would generate a better result than the standard (ordered) Pair Compressor. This class is purely for expirimental purposes.

The results are checked for length so an error is raised if any table is too big.

__call__(router_tables)[source]
Parameters: router_tables (MulticastRoutingTables) – MulticastRoutingTables PacmanElementAllocationException – if the compressed table won’t fit
verify_lengths(compressed)[source]
Parameters: compressed (MulticastRoutingTables) – PacmanElementAllocationException – if the compressed table won’t fit
class pacman.operations.router_compressors.Entry(key, mask, defaultable, spinnaker_route)[source]

Bases: object

Parameters: key (int) – mask (int) – defaultable (bool) – spinnaker_route (int) –
defaultable
static from_MulticastRoutingEntry(mre)[source]
Parameters: mre (MulticastRoutingEntry) – Entry
key
mask
spinnaker_route
to_MulticastRoutingEntry()[source]
Return type: MulticastRoutingEntry
class pacman.operations.router_compressors.PairCompressor(ordered=True)[source]

Bases: pacman.operations.router_compressors.abstract_compressor.AbstractCompressor

Routing Table compressor based on brute force. Finds mergable pairs to replace.

This algorithm assumes unordered routing tables and returns a possibly ordered routing tables. If unordered it can be used as a precompressor for another that makes use of order.

In the simplest format the algorithm is:

1. For every pair of entries in the table
1. If they have the same spinnaker_route
1. Create a merged entry
2. Check that does not intersect any entry with a different route
1. Remove the two original entries
3. Start over

A slightly optimised algorithm is:

1. Split the entries into buckets based on spinnaker route
2. Process the buckets one at a time
1. For each entry in the buckets
1. For each other entry in the bucket
1. Create a merge entry
2. Make sure there is no clash with an entry in another bucket
3. Replace the two entries and add the merge
4. Start the bucket over
2. If no merge found move the entry from the bucket to the result list
2. When the bucket is empty the result list becomes the bucket

A farther optimisation is to do the whole thing in place in a single list:

1. Step 1 is sort the list by route in place
2. Step 2 do the compression route by route using indexes into the array
1. The array is split into 6 parts.
1. 0 to _previous_pointer(-1): Entries in buckets that have already been compressed
2. _previous_pointer to _write_pointer(-1): Finished entries for the current bucket
3. _write_pointer to left(-1): Unused space due to previous merges
4. left to right: Not yet finished entries from the current bucket
5. right(+ 1) to _remaining_index(-1): Unused space due to previous merges
6. _remaining_index to max_index(-1): Entries in buckets not yet compressed
3. Step 3 use only the entries up to _write_pointer(-1)

A farther optimisation is to uses order. The entries are sorted by route frequency from low to high. The results are considered ordered so previous routes are not considered.

The advantage is this allows all the entries from the most frequent route to be merged into a single entry. And the second most frequent only has to consider the most frequent routes.

Step 1 requires the counting of the frequency of routes and the sorting the routes based on this frequency. The current tie break between routes with the same frequency is the route but this is arbitrary at the algorithm level. This code does not use a dictionary to keep the code the same as the C.

Step 2 is change in that the previous entries (0 to _previous_pointer(-1)) are not considered for clash checking

compress_table(router_table)[source]

Compresses all the entries for a single table.

Compressed the entries for this unordered table returning a new table with possibly fewer entries

The resulting table may be ordered or unordered depending on the value of ordered passed into the init method. Ordered tables may be shorted than unordered ones.

Parameters: router_table (UnCompressedMulticastRoutingTable) – Original Routing table for a single chip Compressed routing table for the same chip list(Entry)
update_frequency(route)[source]
Parameters: route (int) –
class pacman.operations.router_compressors.UnorderedPairCompressor[source]

Bases: pacman.operations.router_compressors.pair_compressor.PairCompressor

A version of the pair compressor that does not consider order or length

The resulting entries are unordered, which allows the use of a second follow on compressor.

The results are not checked for length so the results may be too big to be used unless compressed again.