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


5.11 Memory Efficient Cloning the Probability Profile

QSMM supports a mechanism of deferred copying a probability profile from a source node to a destination node, where a copying operation itself only sets a correspondence between the two nodes—the source node becomes a probability profile source, and the destination node becomes a probability profile user. A node can be a probability profile source for multiple other nodes. Storage redirection functions described in Providing Initial Statistics provide read-only access for the destination node to the probability profile held in the source node.

A deferred copying operation provides copy-on-write behavior for the instances of qsmm_state_s and qsmm_cycle_s structures described in Structures for Accessing Storage. Those instances hold a probability profile along with statistics on the event history. The first operation of writing statistics to such an instance for the destination node causes allocating the instance and copying there a piece of information on the probability profile from the source node.

You can change the values of controlled probability variables for the destination node in the normal way. An assembler program loaded into the source node provides information on how to update the state transition matrix and action emission matrix of the destination node when changing the values of controlled probability variables for the destination node. Updating the state transition matrix and action emission matrix causes the allocation of instances of qsmm_state_s and qsmm_cycle_s for the destination node if they do not yet exist.

The following information held in a source node becomes automatically available for a destination node:

You cannot perform the following operations on a node acting as a probability profile source for other nodes:

You cannot perform the following operations on a node acting as a user of a probability profile provided by another node:

Applying deferred copying operations makes sense when a multinode model allocates storage dynamically—uses map storage for holding statistics on the event history.

When dumping the state transition matrix or action emission matrix of a node acting as a probability profile user or disassembling such node, keep in mind that its set of probabilities of QSMM_PROB_PROFILE type can be incomplete, as some instances of qsmm_state_s structure from a source node might not yet be available for the destination node. Therefore, avoid calculating probabilities of QSMM_PROB_PROFILE type for a node acting as a probability profile user.

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

Use the following function to set a correspondence between two nodes of a multinode model where one node becomes a probability profile source and the other node becomes a probability profile user.

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

This function sets a node of a multinode model as the source of a probability profile and sets another node of this model as a user of this probability profile. The argument node_from specifies the identifier of the source node. The argument node_to specifies the identifier of the destination node. The argument rez1 is for future use and must be equal to 0.

The function clears event history statistics collected for the destination node. If the destination node has a probability profile loaded, the function unloads the profile along with information dependent on it. To clear the event history statistics and unload the profile, this function calls the function qsmm_node_unload described in Unloading the Probability Profile.

If the source node has uncommitted assignments to controlled probability variables, the function qsmm_set_node_profile_source calls the function qsmm_node_var_realize for that node.

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

QSMM_ERR_INVAL

The argument node_from is equal to the argument node_to.

QSMM_ERR_NOTFOUND

The source or destination node does not exist.

QSMM_ERR_NOPROF

The source node does not have a loaded probability profile.

QSMM_ERR_NOEQCLAS

The instruction class set of the source node and the instruction class set of the destination node are different.

QSMM_ERR_NOSTATE

The destination node has the number of states less than it is necessary to hold the probability profile of the source node.

QSMM_ERR_UNTIMELY

The model instance does not exist.

QSMM_ERR_UNSUPPLA

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

QSMM_ERR_PROFSRCU

The source node is a user of a source probability profile provided by another node.

QSMM_ERR_PROFSRCP

One of the following conditions is true:

  • – destination node is a probability profile source for other nodes;
  • – function qsmm_set_node_profile_source called the function qsmm_node_var_realize for the source node, and the latter function has failed because that node is a probability profile source for other nodes.

This error can leave the probability profile of the destination node in inconsistent state. If after removing a reason of this error a repeated call to this function succeeds, the probability profile becomes consistent.

QSMM_ERR_PSUMGT1

The function qsmm_set_node_profile_source called the function qsmm_node_var_realize for the source node, and the latter function failed because the sum of probabilities of case instructions in a choice instruction block would exceed 1.

QSMM_ERR_STORAGE

A Storage API function reported storage failure.

QSMM_ERR_STATS

Inconsistent statistics on an action choice state or cycle type detected.

QSMM_ERR_ILSEQ

Unable to convert a multibyte string to a wide string or vice versa according to a current locale.

QSMM_ERR_NOMEM

There was not enough memory to perform the operation.

Errors QSMM_ERR_PSUMGT1, QSMM_ERR_STORAGE, QSMM_ERR_STATS, QSMM_ERR_ILSEQ, and QSMM_ERR_NOMEM can leave the probability profile of the source or destination node in inconsistent state. If after removing a reason of this error a repeated call to this function succeeds, the probability profile becomes consistent.

The function qsmm_node_unload described in the next section can break off a correspondence between a node acting as a probability profile source and a node acting as a probability profile user.


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