A number of functions in this implementation of the toolbox have been
parallelized using OpenMP to allow them to exploit multiple cores. This should deliver
improved performance for moderate or large datasets when run on a multicore system.
Parallelism has been implemented in many key functions in the areas of:
Other NAG functions may also benefit to some extent because they internally
call one or more of the parallelized functions. The complete list is
- Dense and Sparse Linear Algebra
- Random Number Generators
- Partial Differential Equations
- Curve and Surface Fitting
- Correlation and Regression Analysis
- Multivariate Methods
- Time Series Analysis
- Financial Option Pricing
The parallelism within the NAG Toolbox is implemented using OpenMP and so the environment
variable OMP_NUM_THREADS should be set to a number greater
than 1 to enable this. The number chosen will be the maximum number of
processor cores which the toolbox can use. As a rule of thumb this
should be the number of available (idle) processor cores on the computer
running MATLAB. However:
Users are also advised to turn off any power saving OS features, such as
facilities that reduce the clock speed of idle cores, if they wish to achieve
the best performance.
- Performance improvements depend on many factors, including the nature of
each algorithm, the problem size(s) and other parameters, and the characteristics
of the computer running MATLAB. Users who frequently run very similar problems are
encouraged to experiment with different values of OMP_NUM_THREADS, to see
which value gives the best performance on their code and data.
- Most Intel processors support hyper-threading, which allows each
physical core to appear to the operating system as two logical cores. Thus it may be
advantageous when running parallelized NAG functions to try values of
OMP_NUM_THREADS up to twice the number of physical cores present.
Note that the number of processors or cores reported by the operating
system will be the number of logical cores.
Note that other applications use OpenMP so it is possible that the
OMP_NUM_THREADS environment variable has already been defined
on your system. To check this, type
in MATLAB. If the answer is an integer then the variable has been set.
If it is an empty string ('') then it has not.
To set an environment variable on Windows do the following:
- Click the Start button, go to the Settings menu,
and select Control Panel.
- On the Control Panel menu, select System.
- In the System Properties dialog box, click the
- On the Advanced panel, click the Environment
- In the Environment Variables dialog box, click the
New button in the User Variables section.
- In the New User Variable dialog box, enter the name of the
variable as OMP_NUM_THREADS and set the value of the variable as
On Linux the precise syntax for setting environment variables depends on
the user's shell.
Resetting the value of the environment variable OMP_NUM_THREADS
within MATLAB using the setenv command will not change the
value used by multi-threaded NAG functions.
Thus NAG Toolbox also includes functions that can be used within your MATLAB program to get and set the number of threads to be used in subsequent calls to multi-threaded NAG functions. See Chapter X06 for details.