1. distributed jobDistributed job is a simple parallel task. Assume that you need to complete a group of jobs. Each computing job is independent and data communication is not required between them. This means that the execution sequence of each job does not affect the final execution result. In this case, you can use distributed job to complete this type of job. Distributed jobs can be executed through job manager (Cluster scheduler), local scheduler (standalone scheduler), or a third-party scheduler (pbs.
To create a distributed job, follow these steps: 1. Create a scheduler object 2. Create job3, tasks4, submit a job to scheduler5, and obtain the execution result of the job.
Sample code of distributed job:
Clear all; % search for resources. Jm = findResource ('schedning', 'type', 'jobmanager', 'name', 'mu01', 'lookupurl', '123. 168.100.100 '); % use the resource you just found to create a distributed jobjob = createJob (jm); % set the file association for the job so that all workers can find the original program file, you need to set a shared folder on the Client. Set (job, 'pathdependencies', {'\ 192.168.0.101 \ MATLAB _code \', '/mnt/'}) % another method, pass the original program file used to all workers. % Set (job, 'filedependencies', {'Hm. m'}); N = 5; m = 4; % Create 4 tasks, each task is counted as hp (M, N ). CreateTask (job, @ hp, 1, {M, N}, {M, N }}); % submit work to jobmanager. Submit (job) % wait until all workers finish the job. WaitForState (job, 'finished') % retrieves the calculation result. Results = getAllOutputArguments (job); % destroy the Job and release the resource destroy (job );
2. parallel jobA parallel job contains only one task and must be executed simultaneously in multiple work units. Data communication can be performed between tasks. In the matlab parallel program, the communication unit that can execute parallel job for data communication is called lab, and the lab can be considered as a special type of worker. Parallel jobs run identical parallel programs in different units of work, but different functions can be completed. In parallel job parallel programs, you can obtain the number of worker units executed by the parallel program and the total number of worker units. You can assign different computing tasks to different work units based on the number of work units.
Steps for creating a parallel job: 1. Create or search for scheduler2, create parallel job3, create task4, submit a job, wait for job manager to execute job5, view the job execution status, and return the execution result
Parallel operations of matlab in two different modes