This tutorial provides an example of using the Composite block parallelization feature.


This tutorial requires the workflow from Workflow as a Block.

Before You Begin

This tutorial requires an existing prjTutorials project. If you have not created this project yet, see Tutorial Project first.

  • Open the prjTutorials project.
  • Open wfToySolverBlock (ToySolverBlock.p7wf).
  • Select File ‣ Save Workflow As... to create a copy of the workflow. Save the workflow as wfTestParallelization.
  • Verify that you are editing wfTestParallelization and continue with the tutorial.


As noted before, the original Toy Solver integration workflow cannot process batch input — that is, it does not allow you to specify a list of input vectors and calculate all outputs in one run.

The task is to create a Toy Solver sampling workflow. It shall generate some input sample, process it automatically, and collect output values for analysis.


Creating a sampling workflow in this example can be divided into the following general steps:

  • Generate an input sample.
  • Reconfigure the Toy Solver integration block to process the input batch in parallel.
  • Collect results to get an output sample.

Input Sample Generation

To simplify the example, let us use a simple random data sample (alternatively, you can use a DoE block as described in the Model Evaluation tutorial, section Test Sample Generation).


If you have already completed the Sampling Loop tutorial, you can copy the GenerateInputs block from there to skip this step.

  • Add a Random block. Name it GenerateInputs.

Configure the block to output a random matrix with a set number of columns (input dimension) and the number of rows as a workflow parameter.

  • Open GenerateInputs configuration. On the Configuration tab, change output mode to matrix. Leave other settings default.
  • Switch to the Ports tab.
  • Assign a value to GenerateInputs.cols, 2.
  • Select GenerateInputs.rows as a parameter.
  • Click b_ok in the configuration dialog to save settings and close the window.

The block will generate a random data sample and output it to GenerateInputs.value. Sample size should be set in Run (the number of matrix rows is a parameter).

Sample Processing

In contrast with the Sampling Loop tutorial, the current example does not process the input sample sequentially but uses block parallelization, a special feature available in Composite blocks (like Model).

  • Open Model configuration.
  • On the Configuration tab, select “Enable Parallel Execution”.
  • Select the x port from the drop-down list. You can also change the parallelization ratio or leave it default (4).

Note that once you enable parallelization, Model.x and Model.f change their type.


Both ports now allow List in addition to RealVector. As a result, the output of GenerateInputs.value can now be sent directly to Model.x: pSeven converts the generated RealMatrix to a List of RealVector values, and they are automatically processed by Model.

Note that in order to save results from this workflow you need to monitor Model input and output.

  • Enable monitoring for Model.x and Model.f.

Finally, link GenerateInputs.value to Model.x.


Final workflow with a parallel Model block enables processing the generated input sample without using a calculation loop.


It can be said that when this workflow starts, pSeven creates several virtual copies of the Model block and automatically distributes input points among them. Once any of these virtual blocks finishes calculation, it receives a next point from the sample, so there is no specific processing order.


It is also possible to set the parallelization ratio to 1. It means that only one instance of Toy Solver will run actually, but Model.x will still support the List data type.


To get a Toy Solver response sample, specify the sample size in Run (for example, 500) and run the workflow.

Input and output values are stored to the Model.x and Model.f records respectively.


With these results, you can plot response surfaces for Toy Solver outputs, for example:

  • Create a new report.
  • Add Model.x and Model.f to data series.
  • Add a 3D surface plot with two datasets.
  • First dataset: “Model.x[0]” as X, “Model.x[1]” as Y, “Model.f[0]” as Z.
  • Second dataset: “Model.x[0]” as X, “Model.x[1]” as Y, “Model.f[1]” as Z.