Skip to content
Snippets Groups Projects
Select Git revision
  • 21996d79a8d1383acb48a0a09d00bb536eecdf3c
  • master default protected
  • julia protected
  • 6.x protected
  • python-codegen
  • llvm-15
  • 5.x protected
  • 4.6 protected
  • uop
  • rework_pac
  • aux_vars_fix
  • julia-7.0.0
  • julia-6.4.0
  • julia-6.3.0
  • julia-6.2.0
15 results

ExprNode.hh

Blame
  • masterParallel.m 41.99 KiB
    function [fOutVar,nBlockPerCPU, totCPU] = masterParallel(Parallel,fBlock,nBlock,NamFileInput,fname,fInputVar,fGlobalVar,Parallel_info,initialize)
    % PARALLEL CONTEXT
    % This is the most important function for the management of DYNARE parallel
    % computing.
    % It is the top-level function called on the master computer when parallelizing a task.
    %
    % This function has two main computational strategies for managing the
    % matlab worker (slave process):
    %
    % 0 Simple Close/Open Stategy:
    %   In this case the new Matlab instances (slave process) are open when
    %   necessary and then closed. This can happen many times during the
    %   simulation of a model.
    %
    % 1 Always Open Strategy:
    %   In this case we have a more sophisticated management of slave processes,
    %   which are no longer closed at the end of each job. The slave processes
    %   wait for a new job (if it exists). If a slave does not receive a new job after a
    %   fixed time it is destroyed. This solution removes the computational
    %   time necessary to Open/Close new Matlab instances.
    %
    % The first (point 0) is the default Strategy
    % i.e.(Parallel_info.leaveSlaveOpen=0). This value can be changed by the
    % user in xxx.mod file or it is changed by the programmer if it is necessary to
    % reduce the overall computational time. See for example the
    % prior_posterior_statistics.m.
    %
    % The number of parallelized threads will be equal to (nBlock-fBlock+1).
    %
    % Treatment of global variables:
    %   Global variables used within the called function are wrapped and passed by storing their
    %   values at the start of the parallel computation in a file via
    %   storeGlobalVars.m. This file is then loaded in the separate,
    %   independent slave Matlab sessions. By keeping them separate, no
    %   interaction via global variables can take place.
    %
    % INPUTS
    %  o Parallel [struct vector]   copy of options_.parallel
    %  o fBlock [int]               index number of the first thread
    %                               (between 1 and nBlock)
    %  o nBlock [int]               index number of the last thread
    %  o NamFileInput [cell array]  contains the list of input files to be
    %                               copied in the working directory of remote slaves
    %                               2 columns, as many lines as there are files
    %                               - first column contains directory paths
    %                               - second column contains filenames
    %  o fname [string]             name of the function to be parallelized, and
    %                               which will be run on the slaves
    %  o fInputVar [struct]         structure containing local variables to be used
    %                               by fName on the slaves
    %  o fGlobalVar [struct]        structure containing global variables to be used
    %                               by fName on the slaves
    %  o Parallel_info              []
    %  o initialize                 []
    %
    % OUTPUT
    %  o fOutVar [struct vector]   result of the parallel computation, one
    %                              struct per thread
    %  o nBlockPerCPU [int vector] for each CPU used, indicates the number of
    %                              threads run on that CPU
    %  o totCPU [int]              total number of CPUs used (can be lower than
    %                              the number of CPUs declared in "Parallel", if
    %                              the number of required threads is lower)
    
    % Copyright © 2009-2017 Dynare Team
    %
    % This file is part of Dynare.
    %
    % Dynare is free software: you can redistribute it and/or modify
    % it under the terms of the GNU General Public License as published by