From 2ac1194d39aeb0bed3ad16851fb3b220c8214e16 Mon Sep 17 00:00:00 2001 From: sebastien Date: Fri, 18 Sep 2009 10:34:04 +0000 Subject: [PATCH] Build system: change the flag used for OpenMP compilation git-svn-id: https://www.dynare.org/svn/dynare/trunk@2950 ac1d8469-bf42-47a9-8791-bf33cf982152 --- m4/ax_mexopts.m4 | 1 - mex/build/mkoctfile.am | 2 +- mex/sources/build_matlab.m | 5 +---- mex/sources/build_matlab_multithread.m | 12 ++++++------ mex/sources/build_octave.m | 2 +- mex/sources/bytecode/SparseMatrix.hh | 5 ----- mex/sources/kronecker/A_times_B_kronecker_C.cc | 8 ++------ .../kronecker/sparse_hessian_times_B_kronecker_C.cc | 9 ++------- 8 files changed, 13 insertions(+), 31 deletions(-) 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 #include #include "Mem_Mngr.hh" -/*#ifdef NO_OPENMP -// Nothing to single thread version. -#else - #include -#endif*/ #ifdef _MSC_VER #include #endif diff --git a/mex/sources/kronecker/A_times_B_kronecker_C.cc b/mex/sources/kronecker/A_times_B_kronecker_C.cc index 307dab258..74def7ee5 100644 --- a/mex/sources/kronecker/A_times_B_kronecker_C.cc +++ b/mex/sources/kronecker/A_times_B_kronecker_C.cc @@ -26,9 +26,6 @@ #include "mex.h" #include "../matlab_versions_compatibility.h" -#ifdef NO_OPENMP - #define USE_OMP 0 - #define DEBUG_OMP 0 #ifdef NO_BLAS_H #if defined(__linux__) || defined(OCTAVE) #define dgemm dgemm_ @@ -39,9 +36,8 @@ #else /* NO_BLAS_H */ #include "blas.h" #endif /* NO_BLAS_H */ -#else - #define USE_OMP 1 - #define DEBUG_OMP 0 + +#ifdef USE_OMP #include #endif diff --git a/mex/sources/kronecker/sparse_hessian_times_B_kronecker_C.cc b/mex/sources/kronecker/sparse_hessian_times_B_kronecker_C.cc index e0ce0a254..84d600234 100644 --- a/mex/sources/kronecker/sparse_hessian_times_B_kronecker_C.cc +++ b/mex/sources/kronecker/sparse_hessian_times_B_kronecker_C.cc @@ -26,13 +26,8 @@ #include #include "mex.h" -#ifdef NO_OPENMP - #define USE_OMP 0 - #define DEBUG_OMP 0 -#else - #define USE_OMP 1 - #define DEBUG_OMP 0 - #include +#ifdef USE_OMP +# include #endif #ifdef MWTYPES_NOT_DEFINED