LabVIEW Multicore Analysis and Sparse Matrix Toolkit API Reference

Set Number of Threads VI

  • Updated2023-02-21
  • 4 minute(s) read

Set Number of Threads VI

Owning Palette: Thread Management VIs

Requires: Multicore Analysis and Sparse Matrix Toolkit

Sets the maximum number of threads for parallelism.

LabVIEW does not guarantee that the number of threads you set is used in calculations. The actual number of threads that LabVIEW uses depends on the problem size, system resources, and other considerations. By default, the Multicore Analysis and Sparse Matrix VIs use the number of physical cores as the maximum number of threads unless you specify a smaller number.

This VI is not available on real-time operating systems.

Details  

function domain specifies the domain of functions for which to set the number of threads.

0Default (default)—Sets the default maximum number of threads that applies to all functions. This option does not apply to all functions if you previously specify Linear Algebra or Transform for function domain. Refer to the Details section for more details about this option.
1Linear Algebra—Sets the maximum number of threads that applies to linear algebra functions.
2Transform—Sets the maximum number of threads that applies to transform functions.
number of threads specifies the maximum number of threads for parallelism in function domain. The number of threads must range from 1 to the number of physical cores. The default is 1.
error in describes error conditions that occur before this node runs. This input provides standard error in functionality.
error out contains error information. This output provides standard error out functionality.

Set Number of Threads Details

The following table lists the support characteristics of this VI.

Supported on RT targets No

When you specify function domain, the Linear Algebra and Transform options take precedence over the Default option, as the following examples demonstrate.

Example 1

The following figure demonstrates how to specify two threads for linear algebra functions and one thread for all other functions except linear algebra functions. This figure supposes that the VI runs on a quad-core system.

By specifying the function domain as Linear Algebra and specifying the number of threads as 2 in the Set Number of Threads VI on the left, the number of threads to use for linear algebra functions is two. You can specify a different number of threads to use for all other functions except linear algebra functions by adding another instance of the Set Number of Threads VI to the block diagram. In the previous figure, the Set Number of Threads VI on the right specifies the function domain as Default and specifies the number of threads as 1. Therefore, the number of threads to use for all functions except linear algebra functions is one. You can use the Get Number of Threads VI to get the number of threads for each function domain, as the following table shows:

Function Domain Number of Threads
Default 1
Linear Algebra 2
Transform 1

Example 2

The following figure demonstrates how to specify one thread for linear algebra functions and two threads for transform functions. This figure supposes that the VI runs on a quad-core system.

By specifying the function domain as Linear Algebra and specifying the number of threads as 1 in the Set Number of Threads VI on the left, the number of threads for linear algebra functions is one. You can specify a different number of threads to use for all other functions except linear algebra functions by adding another instance of the Set Number of Threads VI to the block diagram. In the previous figure, the Set Number of Threads VI on the right specifies the function domain as Transform and specifies the number of threads as 2. Therefore, the number of threads to use for linear algebra functions is one and the number of threads for transform functions is two. The number of threads for all functions other than linear algebra and transform functions remains four. You can use the Get Number of Threads VI to get the number of threads for each function domain, as the following table shows:

Function Domain Number of Threads
Default 4
Linear Algebra 1
Transform 2

Log in to get a better experience