MATLAB: How MATLAB scheduler is doing the parallelization between the workers in one computer

Parallel Computing Toolbox

Dear all,
Please, I have a question: I read about the parallel toolbox in MATLAB and how to use some functions and iteration loops like parfor and spmd. I implement some examples from the documents which are very useful and let me understand how to use these tools.
My question is: How MATLAB scheduler is doing the parallelisation for us ? in other words, when we write our parallel code (this code contain parfor or spmd) how MATLAB divide and copy the code and send it to all workers ?
Kind regards Ammar

Best Answer

For spmd, the model is simple: each worker executes the body of the block simultaneously.
For parfor, the iterations of the loop are split up into "intervals", and these are sent out to workers. The aim of the parfor scheduler is to divide the work in such a way as to minimise overheads, while minimising "stragglers". There is no way as a user of parfor to influence the way the work is divided.
Related Question