Share Code with Workers - MATLAB & Simulink (original) (raw)

Main Content

When you submit a job, the software evaluates the tasks of the job on different machines. Each machine must have access to all the files it needs to evaluate its tasks. The following sections explains the basic mechanisms for sharing code with the workers.

Workers Access Files Directly

If the workers all have access to the same drives on the network, they can access the necessary files that reside on these shared resources. This is the preferred method for sharing data, as it minimizes network traffic.

You must define each worker session's search path so that it looks for files in the right places. You can define the path:

Access to files among shared resources can depend upon permissions based on the user name. You can set the user name with which the MATLAB Job Scheduler and worker services of MATLAB Parallel Server™ software run by setting the MJSUSER value in themjs_def file before starting the services. For Microsoft Windows operating systems, there is also MJSPASS for providing the account password for the specified user. For an explanation of service default settings and the mjs_def file, see Modify mjs_def File (MATLAB Parallel Server) in the MATLAB Parallel Server System Administrator's Guide.

Pass Data to and from Worker Sessions

A number of properties on task and job objects are designed for passing code or data from client to scheduler to worker, and back. This information could include MATLAB code necessary for task evaluation, or the input data for processing or output data resulting from task evaluation. The following properties facilitate this communication:

Pass MATLAB Code for Startup and Finish

As a session of MATLAB, a worker session executes its startup.m file each time it starts. You can place the startup.m file in any folder on the worker's MATLAB search path, such as toolbox/parallel/user.

These additional files can initialize and clean up a worker session as it begins or completes evaluations of tasks for a job:

Empty versions of these files are provided in the folder:

matlabroot/toolbox/parallel/user

You can edit these files to include whatever MATLAB code you want the worker to execute at the indicated times.

Alternatively, you can create your own versions of these files and pass them to the job as part of the AttachedFiles property, or include the path names to their locations in the AdditionalPaths property.

The worker gives precedence to the versions provided in theAttachedFiles property, then to those pointed to in theAdditionalPaths property. If any of these files is not included in these properties, the worker uses the version of the file in thetoolbox/parallel/user folder of the worker's MATLAB installation.

See Also

jobStartup | taskStartup | poolStartup | taskFinish

Topics