Main Content

mapreducer

Define execution environment for mapreduce or tall arrays

Description

example

mapreducer, with no arguments, sets the global execution environment to be the default: a parallel pool if you have Parallel Computing Toolbox™ available, or else the local MATLAB®session.mapreduceris a configuration function that changes how MATLAB executesmapreducealgorithms and tall array calculations. Use this function to set, change, or store the execution environment to leverage Parallel Computing Toolbox,MATLAB Parallel Server™, orMATLAB Compiler™。If you have Parallel Computing Toolbox installed, then when you use thetallormapreducefunctions MATLAB automatically starts a parallel pool of workers (unless you have changed the default preferences).

Note

If no toolboxes are available, thenmapreducealgorithms and tall array calculations automatically run using the local MATLAB session, and it is unnecessary to specify configuration settings usingmapreducerto use these features. However, if you have Parallel Computing Toolbox,MATLAB Parallel Server, orMATLAB Compiler, then additionalmapreducerconfiguration options are available for running in parallel or deployed environments.

For more information, seemapreducer(Parallel Computing Toolbox)in the Parallel Computing Toolbox documentation, ormapreducer(MATLAB Compiler)in theMATLAB Compilerdocumentation.

mapreducer(0)sets the global execution environment to be the local MATLAB session.

mapreducer(mr)sets the global execution environment using a previously created MapReducer object,mr

mr= mapreducer(___)also returns a MapReducer object using any of the previous syntaxes. You can usemras a fourth input argument tomapreducewhen you want to explicitly specify the execution environment.

mr= mapreducer(___,'ObjectVisibility','Off')toggles the visibility of MapReducer objectmr。Use this syntax to create new MapReducer objects without affecting the global execution environment.

Examples

collapse all

The command

mapreducer

automatically starts a parallel pool if Parallel Computing Toolbox is available. Otherwise, the execution environment is set to be the local MATLAB session.

You can force MATLAB to use the local session with the command

mapreducer(0)

To query the current global execution environment, use the command

gcmr

Output Arguments

collapse all

Execution environment, returned as a MapReducer object.

If theObjectVisibilityproperty ofmris set to'On'(the default), thenmrdefines the execution environment for allmapreducealgorithms and tall array calculations. You can optionally passmrto themapreducefunction to explicitly specify the execution environment, even if itsObjectVisibilityproperty is set to'Off'

Tips

  • When working with tall arrays, usemapreducerto set the execution environment prior to creating the tall array withtall(ds)。Tall arrays are bound to the current global execution environment when they are constructed. If the global execution environment is subsequently changed, then the tall array becomes invalid and must be reconstructed.

Extended Capabilities

Version History

Introduced in R2014b