# fevalDistr

## PURPOSE

Run simple jobs locally or in distributed fashion using queue.

## SYNOPSIS

function [out,res] = fevalDistr( funNm, jobs, varargin )

## DESCRIPTION

     Run simple jobs locally or in distributed fashion using queue.

     Runs "r=feval(funNm,jobs{i}{:})" for each job either locally or across
     cluster. Distributed queuing system must be installed separately. If
     queuing system is not installed, this function can still be called with
     either the 'local' or 'parfor' options. jobs should be a cell array of
     length nJob. Each job should be a cell array of parameters to pass to
     funNm. funNm must be a function in the path and must return a single
     value (which may be a dummy value if funNm writes its results to disk).

     If using type='local', jobs are executed using simple for loop. If using
     type='parfor', the for loop is a parfor loop, make sure to setup matlab
     workers first using "matlabpool open nWorkers". If type='distr' attempts
     to use the distributed cluster code (must be installed separately);
     defaults to 'local' if cluster code not found.

     USAGE
      [out,res] = fevalDistr( funNm, jobs, [varargin] )

     INPUTS
      funNm      - name of function that will process jobs
      jobs       - [1xnJob] cell array of parameters for each job
      varargin   - additional params (struct or name/value pairs)
       .type       - ['local'], 'parfor' or 'distr'
       .pLaunch    - [] parameter to controller('launchQueue',pLaunch{:})
       .group      - [1] send jobs in batches (only relevant if type='distr')

     OUTPUTS
      out        - 1 if jobs completed successfully
      res        - [1xnJob] cell array containing results of each job

     EXAMPLE
      n=16; jobs=cell(1,n); for i=1:n, jobs{i}={rand(500),ones(25)}; end
      tic, [out,J] = fevalDistr('conv2',jobs,'type','local'); toc,
      tic, [out,J] = fevalDistr('conv2',jobs,'type','parfor'); toc,
      pDistr={'type','distr','pLaunch',{48,401:408}};
      tic, [out,J] = fevalDistr('conv2',jobs,pDistr{:}); toc
      figure(1); montage2(cell2array(J))

     See also controller, queue

     Piotr's Image&Video Toolbox      Version 2.50
     Copyright 2010 Piotr Dollar.  [pdollar-at-caltech.edu]
     Please email me if you find bugs, or have suggestions or questions!
     Licensed under the Lesser GPL [see external/lgpl.txt]

## CROSS-REFERENCE INFORMATION

This function calls:

- getPrmDflt Helper to set default values (if not already set) of parameter struct.
- ticStatus Used to display the progress of a long process.
- tocStatus Used to display the progress of a long process.

This function is called by: