k_order_perturbation MEX: number of threads is now configurable
parent
5b6c3bb452
commit
4030169db9
|
@ -72,6 +72,7 @@ options_.huge_number = 1e7;
|
||||||
options_.threads.kronecker.sparse_hessian_times_B_kronecker_C = num_procs;
|
options_.threads.kronecker.sparse_hessian_times_B_kronecker_C = num_procs;
|
||||||
options_.threads.local_state_space_iteration_2 = 1;
|
options_.threads.local_state_space_iteration_2 = 1;
|
||||||
options_.threads.perfect_foresight_problem = num_procs;
|
options_.threads.perfect_foresight_problem = num_procs;
|
||||||
|
options_.threads.k_order_perturbation = max(1, num_procs/2);
|
||||||
|
|
||||||
% steady state
|
% steady state
|
||||||
options_.jacobian_flag = true;
|
options_.jacobian_flag = true;
|
||||||
|
|
|
@ -42,6 +42,8 @@ switch mexname
|
||||||
options_.threads.local_state_space_iteration_2 = n;
|
options_.threads.local_state_space_iteration_2 = n;
|
||||||
case 'perfect_foresight_problem'
|
case 'perfect_foresight_problem'
|
||||||
options_.threads.perfect_foresight_problem = n;
|
options_.threads.perfect_foresight_problem = n;
|
||||||
|
case 'k_order_perturbation'
|
||||||
|
options_.threads.k_order_perturbation = n;
|
||||||
otherwise
|
otherwise
|
||||||
message = [ mexname ' is not a known parallel mex file.' ];
|
message = [ mexname ' is not a known parallel mex file.' ];
|
||||||
message_id = 'Dynare:Threads:UnknownParallelMex';
|
message_id = 'Dynare:Threads:UnknownParallelMex';
|
||||||
|
|
|
@ -113,6 +113,14 @@ extern "C" {
|
||||||
if (qz_criterium_mx && mxIsScalar(qz_criterium_mx) && mxIsNumeric(qz_criterium_mx))
|
if (qz_criterium_mx && mxIsScalar(qz_criterium_mx) && mxIsNumeric(qz_criterium_mx))
|
||||||
qz_criterium = mxGetScalar(qz_criterium_mx);
|
qz_criterium = mxGetScalar(qz_criterium_mx);
|
||||||
|
|
||||||
|
const mxArray *threads_mx = mxGetField(options_mx, 0, "threads");
|
||||||
|
if (!threads_mx)
|
||||||
|
DYN_MEX_FUNC_ERR_MSG_TXT("Can't find field options_.threads");
|
||||||
|
const mxArray *num_threads_mx = mxGetField(threads_mx, 0, "k_order_perturbation");
|
||||||
|
if (!(num_threads_mx && mxIsScalar(num_threads_mx) && mxIsNumeric(num_threads_mx)))
|
||||||
|
DYN_MEX_FUNC_ERR_MSG_TXT("options_.threads.k_order_perturbation be a numeric scalar");
|
||||||
|
int num_threads = static_cast<int>(mxGetScalar(num_threads_mx));
|
||||||
|
|
||||||
// Extract various fields from M_
|
// Extract various fields from M_
|
||||||
const mxArray *fname_mx = mxGetField(M_mx, 0, "fname");
|
const mxArray *fname_mx = mxGetField(M_mx, 0, "fname");
|
||||||
if (!(fname_mx && mxIsChar(fname_mx) && mxGetM(fname_mx) == 1))
|
if (!(fname_mx && mxIsChar(fname_mx) && mxGetM(fname_mx) == 1))
|
||||||
|
@ -200,6 +208,9 @@ extern "C" {
|
||||||
// intiate tensor library
|
// intiate tensor library
|
||||||
TLStatic::init(kOrder, nStat+2*nPred+3*nBoth+2*nForw+nExog);
|
TLStatic::init(kOrder, nStat+2*nPred+3*nBoth+2*nForw+nExog);
|
||||||
|
|
||||||
|
// Set number of parallel threads
|
||||||
|
sthread::detach_thread_group::max_parallel_threads = num_threads;
|
||||||
|
|
||||||
// make KordpDynare object
|
// make KordpDynare object
|
||||||
KordpDynare dynare(endoNames, exoNames, nExog, nPar,
|
KordpDynare dynare(endoNames, exoNames, nExog, nPar,
|
||||||
ySteady, vCov, modParams, nStat, nPred, nForw, nBoth,
|
ySteady, vCov, modParams, nStat, nPred, nForw, nBoth,
|
||||||
|
|
Loading…
Reference in New Issue