Module caminos_lib::pattern
source · Expand description
A Pattern defines the way elements select their destinations.
see new_pattern
for documentation on the configuration syntax of predefined patterns.
Modules
- Some things most uses of the pattern module will use.
Structs
- Select a block in source/destination sets to send traffic according to a pattern and the remainder according to another. The
uncut_sides
parameter define a large block that may be the whole set, otherwise discarding elements from the end. Thecut_sides
parameter defines a subblock embedded in the former. This defines two sets of nodes: the ones in the subblock and the rest. A pattern can be provided for each of these two sets. It is possible to specify offsets and strides for the subblock. - Maps from a block into another following the natural embedding, keeping the coordinates of every node. Both block must have the same number of dimensions, and each dimension should be greater at the destination than at the source. This is intended to be used to place several small applications in a larger machine. It can combined with CartesianTransform to be placed at an offset, to set a stride, or others.
- Interpretate the origin as with cartesian coordinates. Then add each coordinate with a given factor. It uses default
f64 as usize
, so a small epsilon may be desired. We do not restrict the destination size to be equal to the source size. - Interpretate the origin as with cartesian coordinates. Multiply the first coordinate with a given factor and divide it by each dimension size until it is smaller than the dimension size of a dimension.
- Interpretate the origin as with cartesian coordinates and apply transformations. May permute the dimensions if they have same side. May complement the dimensions. Order of composition is: multiplier, shift, permute, complement, project, randomize, pattern. If you need another order you may compose several of them.
- The node at an
index
sends traffic randomly to one ofindex+g
, whereg
is any of the declaredgenerators
. These sums are made modulo the destination size, which is intended to be equal the source size. the induced communication matrix is a Circulant matrix, hence its name. - Divide the topology according to some given link classes, considering the graph components if the other links were removed. Then apply the
global_pattern
among the components and select randomly inside the destination component. Note that this uses the topology and will cause problems if used as a sub-pattern. - The pattern resulting of composing a list of patterns.
destination=patterns[len-1]( patterns[len-2] ( ... (patterns[1] ( patterns[0]( origin ) )) ) )
. The intermediate sizes along the composition can be stated bymiddle_sizes
, otherwise they are set equal to thetarget_size
of the whole. - A map read from file. Each node has a unique destination. See RandomPermutation for related matters. The file is read at creation and should contain only lines with pairs
source destination
. - Build a random map on initialization, which is then kept constant. Optionally allow self-messages. See
RandomPermutation
andFileMap
. - It keeps a shuffled list, global for all sources, of destinations to which send. Once all have sent it is rebuilt and shuffled again. Independently of past requests, decisions or origin.
- For each group, it keeps a shuffled list of destinations to which send. Once all have sent it is rebuilt and shuffled again. Independently of past requests, decisions or origin.
- The destinations are selected from a given pool of servers.
- Just set
destination = origin
. Mostly to be used inside some meta-patterns. - Partition the nodes in independent regions, each with its own pattern. Source and target sizes must be equal.
- Matrix by vector multiplication. Origin is given coordinates as within a block of size
source_size
. Then the destination coordinate vector isy=Mx
, withx
being the origin andM
the givenmatrix
. This destination vector is converted into an index into a block of sizetarget_size
. - The argument to a builder function of patterns.
- The pattern resulting of composing a pattern with itself a number of times..
- A pattern given by blocks. The elements are divided by blocks of size
block_size
. Theglobal_pattern
is used to describe the communication among different blocks and theblock_pattern
to describe the communication inside a block. Seen as a graph, this is the Kronecker product of the block graph with the global graph. Thus the origin a positioni
in the blockj
will select the destination at positionb(i)
in the blockg(j)
, whereb(i)
is the destination via theblock_pattern
andg(j)
is the destination via theglobal_pattern
. - Build a random involution on initialization, which is then kept constant. An involution is a permutation that is a pairing/matching; if
a
is the destination ofb
thenb
is the destination ofa
. It will panic if given an odd size. See RandomPermutation. - Use either of several patterns, with probability proportional to a weight.
- Build a random permutation on initialization, which is then kept constant. This allows self-messages; with a reasonable probability of having one. See
RandomInvolution
andFileMap
. - Apply some other Pattern over a set of nodes whose indices have been remapped according to a Pattern-given permutation. A source
x
chooses as destinationmap(pattern(invmap(x)))
, wheremap
is the given permutation,invmap
its inverse andpattern
is the underlying pattern to apply. In other words, ifpattern(a)=b
, then destination ofmap(a)
is set tomap(b)
. It can be seen as a Composition that manages building the inverse map. - A pattern in which the destinations are randomly sampled from the destinations for which there are some middle router satisfying some criteria. Note this is only a pattern, the actual packet route does not have to go through such middle router. It has the same implicit concentration scaling as UniformDistance, allowing building a pattern over a multiple of the number of switches.
- Each message gets its destination sampled uniformly at random among the servers attached to neighbour routers. It may build a pattern either of servers or switches, controlled through the
switch_level
configuration flag. This pattern autoscales if requested a size multiple of the network size. - Each destination request will be uniform random among all the range
0..size
minus theorigin
. Independently of past requests, decisions or origin. Has an optional configuration argumentallow_self
, default to false. This can be useful for composed patterns, for example, for a group to send uniformly into another group.
Traits
- A
Pattern
describes how a set of entities decides destinations into another set of entities. The entities are initially servers, but after some operators it may mean router, rows/columns, or other groupings. The source and target set may be or not be the same. Or even be of different size. Thus, aPattern
is a generalization of the mathematical concept of function.
Functions
- Build a new pattern. Patterns are maps between two sets which may depend on the RNG. Generally over the whole set of servers, but sometimes among routers or groups. Check the documentation of the parent Traffic/Permutation for its interpretation.
- Build an integer vector with elements proportional to the given
weights
and with a totaltarget_sum
. Based on https://stackoverflow.com/questions/16226991/allocate-an-array-of-integers-proportionally-compensating-for-rounding-errors