diff --git a/m4/ax_mexopts.m4 b/m4/ax_mexopts.m4
index 7606cf731..8ef72d5e3 100644
--- a/m4/ax_mexopts.m4
+++ b/m4/ax_mexopts.m4
@@ -27,7 +27,6 @@ AC_MSG_CHECKING([for options to compile MEX for MATLAB])
MATLAB_CPPFLAGS="-I$MATLAB/extern/include"
MATLAB_CC="$CC"
MATLAB_CXX="$CXX"
-MATLAB_DEFS="-DNO_OPENMP" # Don't use OpenMP (flag used by S. Adjemian in some DLLs)
case ${MATLAB_ARCH} in
glnx86 | glnxa64)
diff --git a/mex/build/mkoctfile.am b/mex/build/mkoctfile.am
index a73bdba78..74a32385a 100644
--- a/mex/build/mkoctfile.am
+++ b/mex/build/mkoctfile.am
@@ -2,7 +2,7 @@ EXEEXT = .mex
CPPFLAGS = $(shell $(MKOCTFILE) -p CPPFLAGS)
-DEFS = -DNO_BLAS_H -DNO_LAPACK_H -DOCTAVE -DNO_OPENMP
+DEFS = -DNO_BLAS_H -DNO_LAPACK_H -DOCTAVE
CC = $(shell $(MKOCTFILE) -p CC)
CFLAGS = $(shell $(MKOCTFILE) -p CPICFLAG)
diff --git a/mex/sources/build_matlab.m b/mex/sources/build_matlab.m
index 71fc39495..db3d09dc3 100644
--- a/mex/sources/build_matlab.m
+++ b/mex/sources/build_matlab.m
@@ -1,6 +1,6 @@
% Build file for Dynare MEX Librairies under Matlab
-% Copyright (C) 2007-2008 Dynare Team
+% Copyright (C) 2007-2009 Dynare Team
%
% This file is part of Dynare.
%
@@ -89,9 +89,6 @@ else
end
disp(' ')
-COMPILE_OPTIONS = [ COMPILE_OPTIONS ' -DNO_OPENMP' ]; % Single thread version. To compile multithreaded versions of the mex file
- % use build_matlab_multithread.m instead.
- % Read http://www.dynare.org/DynareWiki/UsingMultithreadedDlls.
% Set Optimization and Debug flags
CXXOPTIMFLAGS = ' CXXOPTIMFLAGS=-O3 ';
COPTIMFLAGS = ' COPTIMFLAGS=-O3 ';
diff --git a/mex/sources/build_matlab_multithread.m b/mex/sources/build_matlab_multithread.m
index 95d1555bf..9f8d6a408 100644
--- a/mex/sources/build_matlab_multithread.m
+++ b/mex/sources/build_matlab_multithread.m
@@ -1,6 +1,7 @@
-% Build file for Dynare MEX Librairies under Matlab
+% Build file for Dynare MEX Librairies under Matlab with multithreading
+% Read http://www.dynare.org/DynareWiki/UsingMultithreadedDlls
-% Copyright (C) 2007-2008 Dynare Team
+% Copyright (C) 2007-2009 Dynare Team
%
% This file is part of Dynare.
%
@@ -110,16 +111,15 @@ LDFLAGS = ' LDFLAGS="\$LDFLAGS -fopenmp" ';
disp('Compiling isopenmp...')
try
- eval([ 'mex ' COMPILE_OPTIONS CFLAGS CXXFLAGS LDFLAGS ' -outdir ' OUTPUT_DIR ' threads/isopenmp.cc ' ]);
+ eval([ 'mex ' COMPILE_OPTIONS ' -DUSE_OMP ' CFLAGS CXXFLAGS LDFLAGS ' -outdir ' OUTPUT_DIR ' threads/isopenmp.cc ' ]);
disp(' ')
disp('|------------------------------------------------|')
disp('| OpenMp is used (multithreaded mex files) for: |')
disp('| * sparse_hessian_times_B_kronecker_C.cc |')
disp('| * A_times_B_kronecker_C.cc |')
- disp('| * bytecode (SparseMatrix.cc) |')
disp('|------------------------------------------------|')
disp(' ')
- COMPILE_OPTIONS_OMP = [ COMPILE_OPTIONS CFLAGS CXXFLAGS LDFLAGS ];
+ COMPILE_OPTIONS_OMP = [ COMPILE_OPTIONS ' -DUSE_OMP ' CFLAGS CXXFLAGS LDFLAGS ];
catch
disp(' ')
disp('|------------------------------------------------|')
@@ -127,7 +127,7 @@ catch
disp('|------------------------------------------------|')
disp(' ')
CFLAGS = []; CXXFLAGS = []; LDFLAGS = [];
- COMPILE_OPTIONS_OMP = [ COMPILE_OPTIONS ' -DNO_OPENMP' ];
+ COMPILE_OPTIONS_OMP = COMPILE_OPTIONS;
end
COMPILE_COMMAND_OMP = [ 'mex ' COMPILE_OPTIONS_OMP ' -outdir ' OUTPUT_DIR ];
diff --git a/mex/sources/build_octave.m b/mex/sources/build_octave.m
index 5a092044d..ee25357bf 100644
--- a/mex/sources/build_octave.m
+++ b/mex/sources/build_octave.m
@@ -17,7 +17,7 @@
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see .
-COMPILE_OPTIONS = '-DNO_BLAS_H -DNO_LAPACK_H -DOCTAVE -DNO_OPENMP';
+COMPILE_OPTIONS = '-DNO_BLAS_H -DNO_LAPACK_H -DOCTAVE';
% Comment next line to suppress compilation debugging info
COMPILE_OPTIONS = [ COMPILE_OPTIONS ' -v' ];
diff --git a/mex/sources/bytecode/SparseMatrix.hh b/mex/sources/bytecode/SparseMatrix.hh
index 066f4ad18..732bc5628 100644
--- a/mex/sources/bytecode/SparseMatrix.hh
+++ b/mex/sources/bytecode/SparseMatrix.hh
@@ -26,11 +26,6 @@
#include