


This function sets the number of threads used by some MEX files when compiled with OpenMP support (i.e with --enable-openmp is given to configure) or any other parallel library. INPUTS o mexname [string] Name of the mex file. o n [integer] scalar specifying the number of threads to be used. OUTPUTS none.


0001 function set_dynare_threads(mexname,n) 0002 % This function sets the number of threads used by some MEX files when compiled 0003 % with OpenMP support (i.e with --enable-openmp is given to configure) or any 0004 % other parallel library. 0005 % 0006 % INPUTS 0007 % o mexname [string] Name of the mex file. 0008 % o n [integer] scalar specifying the number of threads to be used. 0009 % 0010 % OUTPUTS 0011 % none. 0012 0013 % Copyright (C) 2009-2010 Dynare Team 0014 % 0015 % This file is part of Dynare. 0016 % 0017 % Dynare is free software: you can redistribute it and/or modify 0018 % it under the terms of the GNU General Public License as published by 0019 % the Free Software Foundation, either version 3 of the License, or 0020 % (at your option) any later version. 0021 % 0022 % Dynare is distributed in the hope that it will be useful, 0023 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0024 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0025 % GNU General Public License for more details. 0026 % 0027 % You should have received a copy of the GNU General Public License 0028 % along with Dynare. If not, see <http://www.gnu.org/licenses/>. 0029 global options_ 0030 0031 if ~ischar(mexname) 0032 error('set_dynare_threads:: First argument has to be a string!') 0033 end 0034 0035 if ~isint(n) 0036 error('set_dynare_threads:: Second argument has to be an integer!') 0037 end 0038 0039 switch mexname 0040 case 'A_times_B_kronecker_C' 0041 options_.threads.kronecker.A_times_B_kronecker_C = n; 0042 case 'sparse_hessian_times_B_kronecker_C' 0043 options_.threads.kronecker.sparse_hessian_times_B_kronecker_C = n; 0044 case 'local_state_space_iteration_2' 0045 options_.threads.local_state_space_iteration_2 = n; 0046 otherwise 0047 message = [ mexname ' is not a known parallel mex file.' ]; 0048 message_id = 'Dynare:Threads:UnknownParallelMex'; 0049 warning(message_id,message); 0050 end