Optimization of code for port connections

Rational® Rhapsody® includes an option to optimize the code generated for port connections. In many scenarios, this can result in improved performance of your application.
Note: This feature is only available for C++ code.

When ports are used in models, there are often situations where a chain of non-behavioral ports are connected to each other, with calls being delegated from one end to the other. This results in poorer runtime performance and also makes debugging the application more difficult.

To prevent this kind of problem, you can use the port connection optimization feature. When you use this code generation option, the generated code is designed to connect the ports at either end of this sort of chain at run time.

When deciding whether to use the connection optimization feature for ports, take into account that there is a trade-off. The optimized code results in improved performance, but also uses more memory temporarily when the application starts and the ports are initialized.

When using this optimization feature, code is not optimized for connections involving the following types of ports:

Use of port connection optimization is controlled by the following properties:

Controlling generation of port connection optimization code

The port connection optimization code consists of:

The OptimizePortConnectors property controls the generation of this code, providing the following possible values:

The ActivateInComponent value is appropriate for executables. For libraries, it is appropriate in situations where the components that use the library do not have to know whether port connector optimization is used or not.

The ActivateExternally value should be used in situations where cross-component connections must be optimized. It is also appropriate in situations where port connections are also initialized manually.

Note: If there are no links between ports in a component, then even if you select the ActivateInComponent property value, the code generated is the same as the code generated when the ActivateExternally property value is used. This means that the required infrastructure code is generated but the generated code does not include a call to the OM_OPTIMIZE_PORT_CONNECTORS macro. In such cases, the extra memory that was used during port initialization is only freed if you include your own call to the macro.

Controlling which port connections are optimized

If you have set the value of the OptimizePortConnectors property to use optimization, you can control which port connections are optimized by setting the value of the Boolean property CPP_CG::Port::IncludeInConnectorOptimization.

If a chain of ports includes a port for which the value of the property is set to False, that port will not be included in the optimization, but optimization will still be used for the other port connections in the chain.

Customizing the port connection optimization code

The following properties can be used to customize the port connection optimization code, for example the names of the macros used and the header files included:


Feedback