Home > freetb4matlab > multicore > startmulticoremaster.m

startmulticoremaster

PURPOSE ^

STARTMULTICOREMASTER Start multi-core processing master process.

SYNOPSIS ^

function resultCell = startmulticoremaster(functionHandleCell, parameterCell,multicoreDir, maxMasterEvaluations)

DESCRIPTION ^

STARTMULTICOREMASTER  Start multi-core processing master process.
   RESULTCELL = STARTMULTICOREMASTER(FHANDLE, PARAMETERCELL, DIRNAME)
   starts a multi-core processing master process. The function specified
   by the given function handle is evaluated with the parameters saved in
   each cell of PARAMETERCELL. Each cell may include parameters in any
   form or another cell array which is expanded to an argument list using
   the {:} notation to pass multiple input arguments. The outputs of the
   function are returned in cell array RESULTCELL of the same size as
   PARAMETERCELL. Only the first output argument of the function is
   returned. If you need to get multiple outputs, write a small adapter
   function which puts the outputs of your function into a cell array.

   To make use of multiple cores/machines, function STARTMULTICOREMASTER
   saves files with the function handle and the parameters to the given
   directory DIRNAME. These files are loaded by function
   STARTMULTICORESLAVE running on other Matlab processes which have access
   to the same directory. The slave processes evaluate the given function
   with the saved parameters and save the result in another file into the
   same directory. The results are later collected by the master process.

        RESULTCELL = STARTMULTICOREMASTER(FHANDLE, PARAMETERCELL, DIRNAME,
        MAXMASTEREVALUATIONS) restricts the number of function evaluations done
        by the master process to MAXMASTEREVALUATIONS. After the given number
        of evaluations is reached, the master process waits for other processes
        to complete instead of working down the list of parameter sets itself.
        Use this value if the overall number of function evaluations is quite
        small or the duration of a single evaluation is very long. However,
        note that if the slave process is interrupted, the master process will
        never terminate the computations~

   Note that you can make use of multiple cores on a single machine or on
   different machines with a commonly accessible directory/network share
   or a combination of both.

   RESULTCELL = STARTMULTICOREMASTER(FHANDLE, PARAMETERCELL) uses the
   directory <TEMPDIR2>/multicorefiles, where <TEMPDIR2> is the directory
   returned by function TEMPDIR2. Use this form if you are running on
   multiple cores on a single machine.

   RESULTCELL = STARTMULTICOREMASTER(FHANDLECELL, PARAMETERCELL, ...),
   with a cell array FHANDLECELL including function handles, allows to
   evaluate different functions.

   Example: If you have your parameters saved in parameter cell
   PARAMETERCELL, the for-loop

       for k=1:numel(PARAMETERCELL)
           RESULTCELL{k} = FHANDLE(PARAMETERCELL{k});
       end

   which you would run in a single process can be run in parallel on
   different cores/machines using STARTMULTICOREMASTER and
   STARTMULTICORESLAVE. Run

       RESULTCELL = STARTMULTICOREMASTER(FHANDLE, PARAMETERCELL, DIRNAME)

   in one Matlab process and

       STARTMULTICORESLAVE(DIRNAME)

   in other Matlab processes.

        Markus Buehren
        Last modified 13.11.2007

   See also STARTMULTICORESLAVE, FUNCTION_HANDLE.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:
Generated on Fri 22-May-2009 15:13:00 by m2html © 2003