5.9 Cloning the Probability Profile

To load the same probability profile into multiple nodes of a multinode model, you can load an assembler program into one node and copy its probability profile to other nodes—clone a probability profile. Cloning a probability profile from a node to other nodes is faster than loading the same assembler program into them.

Use the function described below to clone a probability profile.

Function: int qsmm_node_profile_clone (qsmm_t model, qsmm_sig_t node_from, qsmm_sig_t node_to, unsigned int flags)

This function copies a probability profile from a node of a multinode model to another node of the model. The argument node_from specifies the identifier of a source node. The argument node_to specifies the identifier of a destination node.

The function clears event history statistics collected for the destination node. If it already has a probability profile loaded, the function first unloads the profile from the node along with additional information the function can copy (see the description of flags argument below). To clear event history statistics and unload the profile, this function calls the function qsmm_node_unload described in Unloading the Probability Profile.

The function qsmm_node_profile_clone cannot copy probability profiles manually written to storage without prior calling the function qsmm_node_asm.

The argument flags is a bitmask specifying the types of information to copy from the source node to the destination node along with the probability profile. The following macros specify the bits of the bitmask taken into account.

Macro: QSMM_NODE_CLONE_VARS

Copy definitions of controlled and output probability variables and arrays. This copying makes it possible to modify controlled probability variables of the destination node and to retrieve its output probability variables and arrays, as you can modify and retrieve them for the source node. Before copying definitions of controlled probability variables, this function calls the function qsmm_node_var_realize for the source node if it has uncommitted assignments to controlled probability variables.

Macro: QSMM_NODE_CLONE_STATE_NAMES

Copy names assigned to node states by arguments of stt instructions. The functions qsmm_get_node_state_name and qsmm_get_node_state_by_name can retrieve this information from the destination node. The function qsmm_node_disasm can use this information when disassembling the destination node. The function qsmm_mat_goto_dump_v2 uses this information when dumping the state transition matrix of that node. The function qsmm_mat_action_dump_v2 uses this information when dumping the action emission matrix of that node.

Macro: QSMM_NODE_CLONE_TEMPLATE

If the source node has an associated assembler program template, copy the template. The function qsmm_node_disasm uses the template when disassembling the destination 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_UNTIMELY

A model instance does not exist.

QSMM_ERR_NOPROF

The source node does not have a probability profile specified.

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;
  • on passing QSMM_NODE_CLONE_VARS, the source node had uncommitted assignments to controlled probability variables, so qsmm_node_profile_clone called the function qsmm_node_var_realize to commit them, 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 the error a repeated call to this function succeeds, the probability profile becomes consistent.

QSMM_ERR_NOEQCLAS

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

QSMM_ERR_NOTSUP

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

QSMM_ERR_PSUMGT1

On passing QSMM_NODE_CLONE_VARS, the source node had uncommitted assignments to controlled probability variables, so qsmm_node_profile_clone called the function qsmm_node_var_realize to commit them, and the latter function has failed because the sum of probabilities of case instructions in a choice instruction block would exceed 1.

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

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_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 an error a repeated call to this function succeeds, the probability profile becomes consistent.