Next: , Previous: , Up: Assembler Programs   [Contents][Index]


5.12 Memory Efficient Cloning the Probability Profile

The QSMM framework supports a mechanism of deferred copying a probability profile from one node to the other node when no memory is consumed during the copying operation itself. The deferred copying operation only sets a correspondence between two nodes, where one node becomes a source of a probability profile and the other node becomes a user of that probability profile. A node can be a source of probability profile for multiple other nodes. Applying deferred copying operation makes sense when the memory is allocated dynamically, i.e. when the multinode model uses map storage for holding statistics collected on the event history. The longer gets the event history the same efficiency of memory consumption is provided in case when there is no probability profile loaded into a node and in case when the node is a user of a source probability profile provided by another node.

The deferred copying mechanism works in the following way. Information on a probability profile is stored in instances of structures qsmm_state_s and qsmm_cycle_s as described in Structures for Accessing Storage. Statistics collected on the event history is also stored in those instances. However, initially there is no statistics collected for a node, which acts as a user of probability profile7, so the default statistics can be used when needed. Information on a probability profile for that node can be obtained using redirection, i.e. taken from another part of storage that corresponds to a node, which serves as a source of probability profile. When the event history gets longer, and there is a need to update statistics for a particular action choice state or cycle type, the corresponding instance of structure qsmm_state_s or qsmm_cycle_s is allocated in storage. Information on a probability profile is copied there from another part of storage, and updated statistics is written there. Later, the information on a probability profile will be read from the allocated instance directly.

Values of controlled probability variables defined in an assembler program loaded into a node that serves as a source of a probability profile can be changed for a node, which acts as a user of that probability profile, in the ordinary way. Information on how elements of the state transition matrix and the action emission matrix of the latter node should be updated when changing the values of controlled probability variables for that node is taken from the former node. Changing values of probability variables causes allocation of corresponding instances of structures qsmm_state_s and qsmm_cycle_s in storage for the latter node if they are not allocated yet.

The following information stored in a node, which serves as a source of a probability profile, becomes automatically available for a node, which acts as a user of that probability profile.

The following operations cannot be performed on a node that serves as a source of probability profile for other nodes:

The following operations cannot be performed on a node that acts as a user of a probability profile provided by another node:

When dumping the state transition matrix or the action emission matrix, or when disassembling a node, which is a user of a probability profile provided by another node, keep in mind that not all probabilities of type QSMM_PROB_PROFILE may yet be copied from a node, which serves as a source of the probability profile. Because the collection of probabilities can be incomplete, calculating probabilities of that type for a node, which is a user of probability profile, is not recommended.

When the deferred copying mechanism is used for some nodes of a multinode model, this slows down all access operations to storage, which is used by the model, approximately twice (even for other nodes of the model).

To set a correspondence between two nodes of a multinode model, where one node becomes the source of a probability profile and the other node becomes a user of that probability profile, the following function can be used.

Function: int qsmm_set_node_profile_source (qsmm_t model, int node_from, int node_to, int rez1)

This function sets one node of a multinode model specified by handle model as the source of a probability profile and sets the other node of the model as a user of the probability profile. Argument node_from specifies a source node identifier. Argument node_to specifies a destination node identifier. Argument rez1 is reserved for future use and must be equal to 0.

The function clears statistics on the event history that might have been collected for node node_to. If node node_to has a probability profile loaded, then that profile along with information, which depends on the profile, will be unloaded. To clear statistics on the event history and to unload the profile, the function qsmm_node_unload described in the next section is implicitly called.

If node node_from has uncommitted assignments to controlled probability variables, then the function qsmm_node_var_realize will be implicitly called for that node.

The function returns a non-negative value on success or a negative error code on failure. Currently, the following error codes can be returned.

QSMM_ERR_INVAL

The value of node_from is equal to the value of node_to.

QSMM_ERR_NOTFOUND

A node with identifier node_from or node_to does not exist.

QSMM_ERR_NOSTATE

A node with identifier node_to has the number of states less than it is required to hold the probability profile of a node with identifier node_from.

QSMM_ERR_NOSAMENC

Instruction class sets that represent node classes, to which nodes node_from and node_to belong, are not the same.

QSMM_ERR_NOPROF

A probability profile is not loaded into a node with identifier node_from.

QSMM_ERR_PROFSRCU

A node with identifier node_from is a user of a source probability profile provided by another node.

QSMM_ERR_PROFSRCP

One of the following conditions is met:

  • – a node with identifier node_to is a source of probability profile for other nodes;
  • – the function qsmm_node_var_realize was implicitly called, and it turned out that a node with identifier node_from is already a source of probability profile for other nodes.
QSMM_ERR_PSUMGT1

The function qsmm_node_var_realize was implicitly called for node node_from, and it turned out that the sum of probabilities of case instructions in a choice instruction block or the sum of elements of a probabilities list used by a casels instruction will exceed 1 if assignments to controlled probability variables are committed. This could leave the model instance in indeterminate state. If the model instance is in indeterminate state, then after removing a reason of the error, the operation can be repeated, and if the function succeeds, then the model instance state will become determinate.

QSMM_ERR_UNTIMELY

The model instance does not exist.

QSMM_ERR_UNSUPPLA

The multinode model has positive length of the look-ahead signal segment.

QSMM_ERR_STORAGE

Statistics storage failure. This could leave the model instance in indeterminate state. If the model instance is in indeterminate state, then after removing a reason of the error, the operation can be repeated, and if the function succeeds, then the model instance state will become determinate.

QSMM_ERR_NOMEM

There was not enough memory to perform the operation. This could leave the model instance in indeterminate state. If the model instance is in indeterminate state, then after removing a reason of the error, the operation can be repeated, and if the function succeeds, then the model instance state will become determinate.

A correspondence between a node, which is the source of a probability profile, and a node, which is a user of that probability profile, can be broken off by the function qsmm_node_unload described in the next section.


Footnotes

(7)

Statistics is automatically unloaded from a node, which becomes a user of probability profile, when there is set a correspondence for that node with a node, which acts as a source of probability profile.


Next: , Previous: , Up: Assembler Programs   [Contents][Index]