lava.magma.runtime

lava.magma.runtime.mgmt_token_enums

digraph inheritancee08e8a5bdf { bgcolor=transparent; rankdir=TB; size=""; "MGMT_COMMAND" [URL="../lava/lava.magma.runtime.html#lava.magma.runtime.mgmt_token_enums.MGMT_COMMAND",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="Signifies the Mgmt Command being sent between two actors. These may be"]; "MGMT_RESPONSE" [URL="../lava/lava.magma.runtime.html#lava.magma.runtime.mgmt_token_enums.MGMT_RESPONSE",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="Signifies the response to a Mgmt command. This response can be sent"]; }

Defines message tokens for Actions (Commands) and Responses. Also defines helper functions to convert scalar values to these message tokens.

class lava.magma.runtime.mgmt_token_enums.MGMT_COMMAND

Bases: object

Signifies the Mgmt Command being sent between two actors. These may be between runtime and runtime_service or the runtime_service and process model.

GET_DATA = array([-3.])

Signifies Read a variable

PAUSE = array([-2.])

Signifies a PAUSE command from one actor to another

RUN = array([0.])

Signifies a RUN command for 0 timesteps from one actor to another. Any non negative integer signifies a run command

SET_DATA = array([-4.])

Signifies Write a variable

STOP = array([-1.])

Signifies a STOP command from one actor to another

class lava.magma.runtime.mgmt_token_enums.MGMT_RESPONSE

Bases: object

Signifies the response to a Mgmt command. This response can be sent by any actor upon receiving a Mgmt command

DONE = array([0.])

Signfies Ack or Finished with the Command

ERROR = array([-2.])

Signifies Error raised

PAUSED = array([-3.])

Signifies Execution State to be Paused

REQ_PAUSE = array([-4.])

Signifies Request of PAUSE

REQ_STOP = array([-5.])

Signifies Request of STOP

SET_COMPLETE = array([-6.])

Signifies Completion of Set Var

TERMINATED = array([-1.])

Signifies Termination

lava.magma.runtime.mgmt_token_enums.enum_equal(a, b)

Helper function to compare two np arrays created by enum_to_np.

Parameters:
  • a (array) – 1-D array created by enum_to_np

  • b (array) – 1-D array created by enum_to_np

Return type:

bool

Returns:

True if the two arrays are equal

lava.magma.runtime.mgmt_token_enums.enum_to_np(value, d_type=<class 'numpy.float64'>)

Helper function to convert an int (or EnumInt) or a float to a single value np array so as to pass it via the message passing framework. The dtype of the np array is specified by d_type with the default of np.int32.

Parameters:
  • value (Union[int, float]) – value to be converted to a 1-D array

  • d_type (type) – type of the converted np array

Return type:

array

Returns:

np array with the value

lava.magma.runtime.runtime

digraph inheritanced3128e74d8 { bgcolor=transparent; rankdir=TB; size=""; "Runtime" [URL="../lava/lava.magma.runtime.html#lava.magma.runtime.runtime.Runtime",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="Lava runtime which consumes an executable and run"]; }
class lava.magma.runtime.runtime.Runtime(exe, message_infrastructure_type, loglevel=30)

Bases: object

Lava runtime which consumes an executable and run run_condition. Exposes the APIs to start, pause, stop and wait on an execution. Execution could be blocking and non-blocking as specified by the run run_condition.

__del__()

On destruction, terminate Runtime automatically to free compute resources.

__enter__()

Initialize the runtime on entering “with” block of a context manager.

__exit__(exc_type, exc_val, exc_tb)

Stop the runtime when exiting “with” block of a context manager.

get_var(var_id, idx=None)

Gets value of a variable with id ‘var_id’.

Return type:

ndarray

initialize(node_cfg_idx=0)

Initializes the runtime

join()

Join all ports and processes

property node_cfg: List[NodeConfig]

Returns the selected NodeCfg.

pause()

Pauses the execution

set_var(var_id, value, idx=None)

Sets value of a variable with id ‘var_id’.

start(run_condition)

Given a run condition, starts the runtime

Parameters:

run_condition (AbstractRunCondition) – AbstractRunCondition

Returns:

None

stop()

Stops an ongoing or paused run.

wait()

Waits for existing run to end. This is helpful if the execution was started in non-blocking mode earlier.

lava.magma.runtime.runtime.target_fn(*args, **kwargs)

Function to build and attach a system process to

Parameters:
  • args – List Parameters to be passed onto the process

  • kwargs – Dict Parameters to be passed onto the process

Returns:

None