Next: pararrayfun, Up: Local execution [Index]
Evaluates a function for multiple argument sets using multiple processes. nproc should specify the number of processes. A maximum recommended value is equal to number of CPUs on your machine or one less. fun is a function handle pointing to the requested evaluating function. a1, a2 etc. should be cell arrays of equal size. o1, o2 etc. will be set to corresponding output arguments.
The UniformOutput and ErrorHandler options are supported with meaning identical to cellfun. A VerboseLevel option controlling the level output is supported. A value of 0 is quiet, 1 is normal, and 2 or more enables debugging output. The ChunksPerProc option control the number of chunks which contains elementary jobs. This option particularly useful when time execution of function is small. Setting this option to 100 is a good choice in most cases.
Instead of returning a result for each argument, parcellfun returns only one cumulative result if "CumFunc" is non-empty. cumfunc must be a function which performs an operation on two sets of outputs of fun and returnes as many outputs as fun. If nout is the number of outputs of fun, cumfunc gets a previous output set of fun or of cumfunc as first nout arguments and the current output of fun as last nout arguments. The performed operation must be mathematically commutative and associative. If the operation is e.g. addition, the result will be the sum(s) of the outputs of fun over all calls of fun. Since floating point addition and multiplication are only approximately associative, the cumulative result will not be exactly reproducible.
Notice that jobs are served from a single first-come first-served queue, so the number of jobs executed by each process is generally unpredictable. This means, for example, that when using this function to perform Monte-Carlo simulations one cannot expect results to be exactly reproducible. The pseudo random number generators of each process are initialised with a unique state. This currently works only for new style generators.
NOTE: this function is implemented using "fork" and a number of pipes for IPC. Suitable for systems with an efficient "fork" implementation (such as GNU/Linux), on other systems (Windows) it should be used with caution. Also, if you use a multithreaded BLAS, it may be wise to turn off multi-threading when using this function.
CAUTION: This function should be regarded as experimental. Although all subprocesses should be cleared in theory, there is always a danger of a subprocess hanging up, especially if unhandled errors occur. Under GNU and compatible systems, the following shell command may be used to display orphaned Octave processes: ps –ppid 1 | grep octave
Next: pararrayfun, Up: Local execution [Index]