We are currently testing an experimental implementation of parallelization inside some MEX files using multiple thread. This parallelization effort should not be confused with the ParallelDynare project which uses different processes (instead of multiple threads) and possibly several hosts to achieve parallelization.

As of 2010-09-27, only the following MEX files implement the features described on this page:

The implementation of multithreading is done using OpenMP.

The MEX files distributed in official stable or unstable packages are not compiled with OpenMP support, since it is considered experimental at this time. You need to recompile the MEX files yourself, giving the --enable-openmp option to the configure script (see README.md).

You can then declare the number of threads that you want to use from your MOD file, using something like:

set_dynare_threads('A_times_B_kronecker_C',4);

The number of threads is specific to each mex file.

Note for Linux users

If you experience problems, you may try the following workaround which consists of adding the following lines to your .bashrc file:

export LD_PRELOAD=$LD_PRELOAD:/lib/libgcc_s.so.1
export LD_PRELOAD=$LD_PRELOAD:/usr/lib/libstdc++.so.6
export LD_PRELOAD=$LD_PRELOAD:/usr/lib/libgomp.so.1

This solves an incompatibility issue between the multithread library distributed with MATLAB (libguide.so) and the open source multithread library used by GCC (libgomp.so). This incompatibility only occurs if the version of GCC used to compile your version of MATLAB is too different from the version of GCC installed on your system.

Notes for Dynare developers

The --enable-openmp option activates the -fopenmp flag of GCC and defines the USE_OMP macro-processor define.

Note that there is an incompatibility issue between MATLAB's version of MKL (blas and lapack) and the GNU OpenMP library. So we cannot mix OpemMP programming with calls to blas or lapack (alternatively, of course, we may decide to use a basic version of blas or lapack routines, i.e. without multithreading). If my understanding is correct this problem is related of the version of MKL shipped with MATLAB.

DynareWiki: UsingMultithreadedDlls (last edited 2013-06-19 16:06:29 by HoutanBastani)