lava.magma.compiler.subcompilers

lava.magma.compiler.subcompilers.address

digraph inheritance4d7a4127d4 { bgcolor=transparent; rankdir=TB; size=""; "ABC" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Helper class that provides a standard way to create an ABC using"]; "NcLogicalAddress" [URL="../lava/lava.magma.compiler.subcompilers.html#lava.magma.compiler.subcompilers.address.NcLogicalAddress",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Represents Logical Id of a resource."]; "ResourceAddress" -> "NcLogicalAddress" [arrowsize=0.5,style="setlinewidth(0.5)"]; "NcVirtualAddress" [URL="../lava/lava.magma.compiler.subcompilers.html#lava.magma.compiler.subcompilers.address.NcVirtualAddress",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Represents Virtual Id of a resource."]; "ResourceAddress" -> "NcVirtualAddress" [arrowsize=0.5,style="setlinewidth(0.5)"]; "ResourceAddress" [URL="../lava.magma.compiler.builders.html#lava.magma.compiler.builders.interfaces.ResourceAddress",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; "ABC" -> "ResourceAddress" [arrowsize=0.5,style="setlinewidth(0.5)"]; }
class lava.magma.compiler.subcompilers.address.NcLogicalAddress(chip_id, core_id)

Bases: ResourceAddress

Represents Logical Id of a resource.

chip_id: int
core_id: int
class lava.magma.compiler.subcompilers.address.NcVirtualAddress(chip_id, core_id)

Bases: ResourceAddress

Represents Virtual Id of a resource.

chip_id: int
core_id: int

lava.magma.compiler.subcompilers.channel_builders_factory

digraph inheritance1849223a01 { bgcolor=transparent; rankdir=TB; size=""; "AbstractCProcessModel" [URL="../lava/lava.magma.compiler.subcompilers.html#lava.magma.compiler.subcompilers.channel_builders_factory.AbstractCProcessModel",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; "AbstractNcProcessModel" [URL="../lava/lava.magma.compiler.subcompilers.html#lava.magma.compiler.subcompilers.channel_builders_factory.AbstractNcProcessModel",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; "ChannelBuildersFactory" [URL="../lava/lava.magma.compiler.subcompilers.html#lava.magma.compiler.subcompilers.channel_builders_factory.ChannelBuildersFactory",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Create ChannelBuilders from a dict-like ChannelMap object with connected"]; }
class lava.magma.compiler.subcompilers.channel_builders_factory.AbstractCProcessModel

Bases: object

class lava.magma.compiler.subcompilers.channel_builders_factory.AbstractNcProcessModel

Bases: object

class lava.magma.compiler.subcompilers.channel_builders_factory.ChannelBuildersFactory

Bases: object

Create ChannelBuilders from a dict-like ChannelMap object with connected ports as keys.

ChannelBuilders allow Runtime to build channels between Process ports.

The from_channel_map method creates a ChannelBuilder for every connection from a source to a destination port in the graph of processes. OutPorts and RefPorts are considered source ports while InPorts and VarPorts are considered destination ports. A ChannelBuilder is only created for terminal connections from one leaf process to another. Intermediate ports of a hierarchical process are ignored.

Once the Runtime has build the channel it can assign the corresponding CSP ports to the ProcessBuilder (i.e. PyProcBuilder.set_csp_ports(..)) and deploy the Process to the appropriate compute node.

from_channel_map(channel_map, compile_config)

Create builders for multiprocessing channels between ports in connected processes.

Parameters:
  • channel_map (A dict-like object with a PortPair key for every channel in) – the process network.

  • compile_config (ty.Optional[ty.Dict[str, ty.Any]]) – Dictionary that may contain configuration options for the overall Compiler as well as all SubCompilers.

Return type:

List[ChannelBuilderMp]

Returns:

  • A list of ChannelBuilders with a build method that allows the runtime to

  • build the actual channels between connected ports.

static get_port_dtype(port)

Returns the d_type of a Process Port, as specified in the corresponding PortImplementation of the ProcessModel implementing the Process

Return type:

Any

lava.magma.compiler.subcompilers.channel_map_updater

digraph inheritance5585256972 { bgcolor=transparent; rankdir=TB; size=""; "ChannelMapUpdater" [URL="../lava/lava.magma.compiler.subcompilers.html#lava.magma.compiler.subcompilers.channel_map_updater.ChannelMapUpdater",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; }
class lava.magma.compiler.subcompilers.channel_map_updater.ChannelMapUpdater(channel_map, payload=None)

Bases: object

add_dst_port(dst_port)
Return type:

None

add_dst_ports(dst_ports)
Return type:

None

add_port_pair(src_port, dst_port)
Return type:

None

add_port_pairs(port_pairs)
Return type:

None

add_src_port(src_port)
Return type:

None

add_src_ports(src_ports)
Return type:

None

property channel_map: ChannelMap

lava.magma.compiler.subcompilers.constants

digraph inheritance9f6bd518a3 { bgcolor=transparent; rankdir=TB; size=""; "EMBEDDED_ALLOCATION_ORDER" [URL="../lava/lava.magma.compiler.subcompilers.html#lava.magma.compiler.subcompilers.constants.EMBEDDED_ALLOCATION_ORDER",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="An enumeration."]; "IntEnum" -> "EMBEDDED_ALLOCATION_ORDER" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Enum" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Generic enumeration."]; "IntEnum" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Enum where members are also (and must be) ints"]; "Enum" -> "IntEnum" [arrowsize=0.5,style="setlinewidth(0.5)"]; }
class lava.magma.compiler.subcompilers.constants.EMBEDDED_ALLOCATION_ORDER(value)

Bases: IntEnum

An enumeration.

NORMAL = 1

Allocate embedded cores in normal order 0, 1, 2

REVERSED = -1

Allocate embedded cores in reverse order 2, 1, 0. This is useful in situations in case of certain tasks which take longer than others and need to be scheduled on embedded core 0 to ensure nxcore does not stop communicating on channels

lava.magma.compiler.subcompilers.exceptions

digraph inheritance81b000e23e { bgcolor=transparent; rankdir=TB; size=""; "ResourceMismatchError" [URL="../lava/lava.magma.compiler.subcompilers.html#lava.magma.compiler.subcompilers.exceptions.ResourceMismatchError",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; }
exception lava.magma.compiler.subcompilers.exceptions.ResourceMismatchError(process, resources)

Bases: Exception

lava.magma.compiler.subcompilers.interfaces

digraph inheritanceb05ca80ebe { bgcolor=transparent; rankdir=TB; size=""; "ABC" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Helper class that provides a standard way to create an ABC using"]; "AbstractSubCompiler" [URL="../lava/lava.magma.compiler.subcompilers.html#lava.magma.compiler.subcompilers.interfaces.AbstractSubCompiler",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Interface for SubCompilers. Their job is to compile connected groups of"]; "ABC" -> "AbstractSubCompiler" [arrowsize=0.5,style="setlinewidth(0.5)"]; "SubCompiler" [URL="../lava/lava.magma.compiler.subcompilers.html#lava.magma.compiler.subcompilers.interfaces.SubCompiler",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; "AbstractSubCompiler" -> "SubCompiler" [arrowsize=0.5,style="setlinewidth(0.5)"]; }
class lava.magma.compiler.subcompilers.interfaces.AbstractSubCompiler

Bases: ABC

Interface for SubCompilers. Their job is to compile connected groups of Processes, whose ProcessModels can be executed on the same type of backend.

abstract compile(channel_map)

Partitions all Processes in the SubCompiler’s ProcGroup onto the available resources.

Return type:

ChannelMap

abstract get_builders(channel_map)

After compilation, creates and returns builders for all Processes.

Return type:

Tuple[Dict[AbstractProcess, AbstractProcessBuilder], ChannelMap]

class lava.magma.compiler.subcompilers.interfaces.SubCompiler(proc_group, compile_config=None)

Bases: AbstractSubCompiler

abstract compile(channel_map)

Partitions all Processes in the SubCompiler’s ProcGroup onto the available resources.

Return type:

ChannelMap

abstract get_builders(channel_map)

After compilation, creates and returns builders for all Processes.

Return type:

Tuple[Dict[AbstractProcess, AbstractProcessBuilder], ChannelMap]