Applying Multicore Simulation

You can apply multicore processing to a behavior execution to speed up the simulation. To have any significant speed-up, the model must be suited for parallelization.

Note: The following scenario describes the mulitprocessing aspect of simulation by simulate an example and analyzing it. For more information about simulations in general, see, for example, Simulating a Behavior.


Before you begin: Modelica Standard Library must be available.
See Also
About Multicore Execution
  1. From the Behavior Tools section of the action bar, click Modelica Scripting .

    Tip: You can also access this command from the Simulation section of the action bar.

    The Modelica Scripting window appears.
  2. In the lower line (command input line) of the Modelica Scripting window, type the following (each line to be followed by pressing Enter):
    1. Advanced.ParallelizeCode=true
    2. Advanced.NumberOfCores=4
    As a result:
    • The multicore processing option is activated.
    • The number of cores to be used for investigating the option is set to 4.
  3. From the Package Browser, open the model Modelica.Electrical.Spice3.Examples.Spice3BenchmarkFourBitBinaryAdder.
  4. To simulate the model, from the Behavior Authoring section of the action bar, click Simulate .

    Tip: You can also access this command from any of:
    • The Simulation section of the action bar.
    • The Action Pad panel. To access the Action Pad panel, from the Tools section of the action bar, click Action Pad , or right-click an empty area and select Display > Action Pad.

    The simulation starts.
  5. Open the Messages Reporting window.
  6. In the Messages Reporting window, you can analyze the result of the multicore processing example.

    The basic structure for the parallel part is a sequence of layers, where the layers have sections that can be simulated in parallel.

    1. In the Translation node of the tree, expand Parallelization > For OutputSelection.

      The log reports that the calculation of the derivatives includes 413717 operations. For the parallelization using 4 cores the longest path is 110030 operations. This means an estimated speed-up of 3.76.

      The critical path is estimated to have 26131 operations, that is, the Amdahl speed-up factor is 413717/26131 = 15.3. This indicates an upper limit of what could be obtained having many cores and neglecting overhead.

      The log then reports the structure of the parallelization obtained. (This structure is investigated in the following substeps.)

    2. Select Sequential 2 in the tree.
      The pane in the Messages Reporting window displays a sequential part calculating 119 unknowns.
    3. Inspect the nodes after Sequential 2.

      3 parallel layers, one sequential part, and finally a parallel layer are displayed.

    4. For example, expand Parallel 4.
      The layer contains 4 parallel sections corresponding to the 4 cores.