Setting the degree of parallelism

You can specify the number of channels for parallel regions within an application or as a submission time value.

About this task

The degree of parallelism, also known as the parallel width, is the number of channels in a parallel region. Higher degrees of parallelism can potentially result in higher performance, but will also use more resources. You should experiment with different parallel widths to find the amount that yields the best performance for your application.

Procedure

You can use any of the following methods to set the degree of parallelism:
  • Use a constant value for the width parameter in the @parallel annotation.
    For example, the following example specifies a parallel width of 5:
        @parallel(width=5)
        stream<Type> Output = Op(Input) {
            // ...
        }
  • Use a composite operator parameter in the @parallel annotation.
    For example:
        composite Sample1(input In; output Out) {
            param expression<int32> $parWidth;      
            graph               
                @parallel(width=$parWidth)
                stream<Type> Out = Op(In) {
                    // ...          
                }       
        }
    When you invoke the Sample1 composite operator in an application, you must supply a value for the parWidth parameter. Alternatively, you can provide a submission-time value for the parameter.
  • Use a submission-time value for the width parameter in the @parallel annotation.
    For example:
        @parallel(width=(int32)getSubmissionTimeValue("parWidth"))
        stream<Type> Output = Op(Input1, Input2) {
            // ...          
        }

What to do next

If you chose to specify the degree of parallelism at submission time, you must specify the parameter value when you submit the job. For example:
streamtool submitjob -P parWidth=6 Sample.sab