If an instruction class set has an event handler function with the same name, you register the instruction class set by the following macro.
This macro registers an instruction class set instr_class_set_name for a multinode model.
The event handler function of the instruction class set previously declared or defined by the macro QSMM_INSTR_CLASS_SET should have the name instr_class_set_name.
The event handler function will be receiving a parameter paramp in mehcall->param_p on events QSMM_EVT_ENT_INIT, QSMM_EVT_ENT_DONE, QSMM_EVT_ENGINE_INIT, and QSMM_EVT_ENGINE_DONE, where mehcall is an argument of that event handler function.
The macro QSMM_REG_INSTR_CLASS_SET_PARAM expands to:
qsmm_reg_instr_class_set((model), #instr_class_set_name,
&instr_class_set_name, (paramp))
Below there is a description of a function called by the macro QSMM_REG_INSTR_CLASS_SET_PARAM.
You can call the function explicitly with passing NULL as the event handler function pointer to register an instruction class set without an event handler function.
int qsmm_reg_instr_class_set (qsmm_t model, const char *instr_class_set_name, qsmm_instr_class_set_func_t instr_class_set_func, void *paramp) ¶This function registers an instruction class set instr_class_set_name for a multinode model.
A function instr_class_set_func will be the event handler of the instruction class set.
The event handler will be receiving a parameter paramp in mehcall->param_p on events QSMM_EVT_ENT_INIT, QSMM_EVT_ENT_DONE, QSMM_EVT_ENGINE_INIT, and QSMM_EVT_ENGINE_DONE, where mehcall is an argument of that event handler.
If instr_class_set_func is NULL, the function registers an instruction class set without an event handler.
After registering an instruction class set, the function sends the event QSMM_EVT_ENT_INIT to the event handler, and it can perform the initialization of the instruction class set.
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_EXISTA program has already registered an instruction class set or instruction meta-class named instr_class_set_name in the multinode model.
QSMM_ERR_NOMEMThere was not enough memory to perform the operation.
Use the following function to get a pointer to the event handler of an instruction class set and a user parameter passed to that event handler in certain cases.
int qsmm_get_instr_class_set_handler (qsmm_t model, const char *instr_class_set_name, qsmm_instr_class_set_func_t *instr_class_set_func_p, void **param_pp) ¶This function retrieves the parameters of the event handler of an instruction class set instr_class_set_name registered for a multinode model.
If instr_class_set_func_p is not NULL, the function sets *instr_class_set_func_p to a pointer to that event handler or to NULL if the instruction class set does not have an event handler.
If param_pp is not NULL, the function sets *param_pp to a parameter of the event handler passed in mehcall->param_p on events QSMM_EVT_ENT_INIT, QSMM_EVT_ENT_DONE, QSMM_EVT_ENGINE_INIT, and QSMM_EVT_ENGINE_DONE, where mehcall is an argument of that event handler.
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_NOTFOUNDThe instruction class set instr_class_set_name not found.
QSMM_ERR_TYPEAn entity named instr_class_set_name is not an instruction class set. The entity is an instruction meta-class.
QSMM_ERR_NOMEMThere was not enough memory to perform the operation.
If a node belonging to a node class represented by an instruction class set does not have an explicitly specified probability profile, the node uses a default uniform probability profile. Its number of states is equal to the number of node states. It cannot exceed the maximum number of node states specified for the instruction class set. The number of states set for a node does not affect explicit specification of a probability profile for the node by loading an assembler program into it or cloning a probability profile for the node in simple or deferred mode. The default maximum number of states for newly registered instruction class sets is 2.
Use the following functions to query or set the maximum number of node states for an instruction class set.
int qsmm_get_nstate_max_v2 (qsmm_t model, const char *node_class_name, int rez1, unsigned int flags, qsmm_sig_t *nstate_p) ¶This function retrieves the maximum allowed number of states of nodes belonging to a node class represented by an instruction class set named node_class_name in a multinode model. A retrieved number may restrict the number of states of a default probability profile for a node but will not restrict the number of states of a custom probability profile set by loading an assembler program into a node or cloning a probability profile for it in simple or deferred mode. The maximum allowed number of states is also the default number of states for newly created nodes belonging to the node class.
If flags contain bitmask QSMM_EXCEPT_NOTFOUND, and the instruction class set does not exist, the function reports QSMM_ERR_NOTFOUND.
If flags contain bitmask QSMM_EXCEPT_TYPE, and an entity named node_class_name is not an instruction class set, the function reports QSMM_ERR_TYPE.
Bitmask QSMM_EXCEPT_ALL includes QSMM_EXCEPT_NOTFOUND and QSMM_EXCEPT_TYPE.
The argument rez1 is for future use and must be equal to 0.
On success, the function returns a non-negative value and sets *nstate_p if nstate_p is not NULL.
If an entity named node_class_name exists and is an instruction class set, the function sets *nstate_p to the maximum allowed number of states for the instruction class set.
If the entity does not exist, and flags do not contain QSMM_EXCEPT_NOTFOUND, the function sets *nstate_p to QSMM_SIG_INVALID.
If the entity exists but is not an instruction class set, and flags do not contain QSMM_EXCEPT_TYPE, the function sets *nstate_p to QSMM_SIG_INVALID.
On failure, the function returns a negative error code. Currently, the function can return the following error codes.
QSMM_ERR_NOTFOUNDThe instruction class set node_class_name does not exist.
The function reports this error if flags include bitmask QSMM_EXCEPT_NOTFOUND.
Otherwise, the function sets *nstate_p to QSMM_SIG_INVALID (if nstate_p is not NULL) and returns a non-negative value.
QSMM_ERR_TYPEAn entity named node_class_name is not an instruction class set.
The entity is an instruction meta-class.
The function reports this error if flags include bitmask QSMM_EXCEPT_TYPE.
Otherwise, the function sets *nstate_p to QSMM_SIG_INVALID (if nstate_p is not NULL) and returns a non-negative value.
QSMM_ERR_NOMEMThere was not enough memory to perform the operation.
int qsmm_set_nstate_max (qsmm_t model, const char *node_class_name, qsmm_sig_t nstate) ¶This function sets to nstate the maximum allowed number of states of nodes belonging to a node class represented by an instruction class set named node_class_name in a multinode model. That number may restrict the number of states of a default probability profile for a node but will not restrict the number of states of a custom probability profile set by loading an assembler program into a node or cloning a probability profile for it in simple or deferred mode. The maximum allowed number of states is also the default number of states for newly created nodes belonging to the node class.
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_INVALThe argument nstate is less than 2 or greater than QSMM_SIG_MAX.
QSMM_ERR_NOTFOUNDThe instruction class set node_class_name does not exist.
QSMM_ERR_TYPEAn entity named node_class_name is not an instruction class set. The entity is an instruction meta-class.
QSMM_ERR_UNTIMELYIncreasing the maximum allowed number of states requires increasing the number of output signals of an existing environment state identification engine represented by a large actor, and it has created a default output signal choice tree. See Number of Output Signals, for cases when a large actor creates a default output signal choice tree.
QSMM_ERR_VIOLNODEThe argument nstate is less than the number of states of an already created node belonging to the node class. This number of states specifies the number of states of a default probability profile for the node and does not restrict the number of states of a custom probability profile.
QSMM_ERR_NOMEMThere was not enough memory to perform the operation.