pacman.utilities package

Submodules

pacman.utilities.constants module

class pacman.utilities.constants.EDGES

Bases: enum.Enum

An enumeration.

EAST = 0
NORTH = 2
NORTH_EAST = 1
SOUTH = 5
SOUTH_WEST = 4
WEST = 3
pacman.utilities.constants.SARK_PER_MALLOC_SDRAM_USAGE = 8

The number of bytes used by SARK per memory allocation

pacman.utilities.json_utils module

Miscellaneous minor functions for converting between JSON and Python objects.

pacman.utilities.json_utils.iptag_resource_from_json(json_dict)[source]
pacman.utilities.json_utils.iptag_resource_to_json(iptag)[source]
pacman.utilities.json_utils.iptag_resources_from_json(json_list)[source]
pacman.utilities.json_utils.iptag_resources_to_json(iptags)[source]
pacman.utilities.json_utils.json_to_object(json_object)[source]

Makes sure this is a JSON object reading in a file if required

Parameters:json_object (dict or list or str) – Either a JSON Object or a string pointing to a file
Returns:a JSON object
Return type:dict or list
pacman.utilities.json_utils.key_mask_to_json(key_mask)[source]
pacman.utilities.json_utils.placement_from_json(json_dict, graph=None)[source]
pacman.utilities.json_utils.placement_to_json(placement)[source]
pacman.utilities.json_utils.placements_to_json()[source]
pacman.utilities.json_utils.reverse_iptag_from_json(json_dict)[source]
pacman.utilities.json_utils.reverse_iptag_to_json(iptag)[source]
pacman.utilities.json_utils.reverse_iptags_from_json(json_list)[source]
pacman.utilities.json_utils.reverse_iptags_to_json(iptags)[source]
pacman.utilities.json_utils.vertex_from_json(json_dict)[source]
pacman.utilities.json_utils.vertex_lookup(label, graph=None)[source]
pacman.utilities.json_utils.vertex_to_json(vertex)[source]

pacman.utilities.utility_calls module

pacman.utilities.utility_calls.allocator_bits_needed(size)[source]

Get the bits needed for the routing info allocator.

Parameters:size (int) – The size to calculate the number of bits for
Returns:the number of bits required for that size
Return type:int
pacman.utilities.utility_calls.compress_bits_from_bit_array(bit_array, bit_positions)[source]

Compress specific positions from a bit array of 32 uint8 value, where is a 1 or 0, into a 32-bit value.

Parameters:
  • bit_array (ndarray(uint8)) – The array to extract the value from
  • bit_positions (ndarray(int)) – The positions of the bits to extract, each value being between 0 and 31
Return type:

int

pacman.utilities.utility_calls.compress_from_bit_array(bit_array)[source]

Compress a bit array of 32 uint8 values, where each is a 1 or 0, into a 32-bit value.

Parameters:bit_array (ndarray(uint8)) – The array to compress
Return type:int
pacman.utilities.utility_calls.expand_to_bit_array(value)[source]

Expand a 32-bit value in to an array of length 32 of uint8 values, each of which is a 1 or 0.

Parameters:value (int) – The value to expand
Return type:ndarray(uint8)
pacman.utilities.utility_calls.get_field_based_index(base_key, vertex_slice, shift=0)[source]

Map field based keys back to indices.

Parameters:
  • base_key (int) – The base key
  • vertex_slice (Slice) – The slice to translate
  • shift (int) – The left shift to apply to the atom key before adding to the key. Can be used to make space for additional information at the bottom of the key.
Return type:

dict(int,int)

pacman.utilities.utility_calls.get_field_based_keys(key, vertex_slice, shift=0)[source]

Translate a vertex slice with potentially multiple dimensions into a list of keys, one for each atom of the vertex, by putting the values into fields of the keys based on the shape of the slice.

Parameters:
  • key (int) – The base key
  • vertex_slice (Slice) – The slice to translate
  • shift (int) – The left shift to apply to the atom key before adding to the key. Can be used to make space for additional information at the bottom of the key.
Return type:

list(int)

pacman.utilities.utility_calls.get_key_ranges(key, mask)[source]

Get a generator of base_key, n_keys pairs that represent ranges allowed by the mask.

Parameters:
  • key (int) – The base key
  • mask (int) – The mask
Return type:

iterable(tuple(int,int))

pacman.utilities.utility_calls.get_n_bits(n_values)[source]

Determine how many bits are required for the given number of values.

Parameters:n_values (int) – the number of values (starting at 0)
Returns:the number of bits required to express that many values
Return type:int
pacman.utilities.utility_calls.get_n_bits_for_fields(field_sizes)[source]

Get the number of bits required for the fields in the vertex slice.

Parameters:field_sizes (iterable(int)) – The sizes each of the fields
Return type:int
pacman.utilities.utility_calls.is_equal_or_None(a, b)[source]

If a and b are both not None, return True iff they are equal, otherwise return True.

Return type:bool
pacman.utilities.utility_calls.is_single(iterable)[source]

Test if there is exactly one item in the iterable.

Return type:bool
pacman.utilities.utility_calls.md5(string)[source]

Get the MD5 hash of the given string, which is UTF-8 encoded.

Parameters:string (str) –
Return type:str

Module contents