Differences between revisions 9 and 10
Revision 9 as of 2009-09-18 10:30:31
Size: 1229
Comment:
Revision 10 as of 2010-09-27 14:19:40
Size: 2269
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
If the mex files are compiled with build_matlab_multithread.m (instead of build_matlab.m), some of the mex files use parallel programming with [[http://openmp.org/wp/|OpenMp]]: 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:
 * A_times_B_kronecker_C
Line 3: Line 6:
 * A_times_B_kronecker_C
Line 5: Line 7:
Under linux an environment variable has to be defined to get the thing working because there is an incompatibility issue between the multithread library distributed with matlab (libguide.so) and the open source multithread library used by the gnu compiler (libgomp.so). The simplest workaround is to add the folowwing lines in your .bashrc file: The implementation of multithreading is done using [[http://openmp.org/wp/|OpenMP]].
Line 7: Line 9:
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 BuildingDynareFromSource).

You can then declare the number of threads that you want to use from your MOD file, using something like:
{{{
set_dynare_threads(4);
}}}

= 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:
Line 12: Line 24:
   The first two lines are necessary even without parallel programming.
Line 15: Line 25:
There is also an incompatibility issue between matlab's version of MKL (blas and lapack) and the gnu multithread library. So we cannot mix parallel programming and calls to blas or lapack (of course we may decide to use a basic version of blas or lapack routines, ie without multithreading). If my understanding is correct this problem is related of the version of MKL shipped with matlab. 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.

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:

  • A_times_B_kronecker_C
  • sparse_hessian_times_B_kronecker_C

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 BuildingDynareFromSource).

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

set_dynare_threads(4);

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)