Jie Wei
Jie Wei

Reputation: 191

number of workers to use in Matlab parallel computing

My current computer has 16 cores and 32 Logical processors. I am using Matlab 2014a. The upper limit for number of workers to use is 512. In my case, what is the optimal number to use?

If it takes, say 20 minutes, to finish a job under

    matlabpool open 16

for the same job how long would it under 32 workers? 10 minutes or more?

Upvotes: 1

Views: 1997

Answers (2)

Daniel
Daniel

Reputation: 36720

The number of workers depends on multiple factors.

First of all, how many cores can a worker use. Let's assume a typical computation intense task where your workers get large chunks of work. In such a scenario you can assume each worker to occupy at least one physical core. Don't use more workers than physical cores available.

Further, when your code is heavily based on multithreading enabled functions, each worker can use more than one core. Especially when using one of the mentioned functions with large images or matrices, you can expect the best performance with much fewer workers. With an octacore system, I ended up not using the parallel computing toolbox at all because a single matlab thread already used the full CPU capacity, only adding unnecessary communication overhead for the parallel computing toolbox. I assume such scenarios have lead to the recommendation of at most 1 worker per CPU in clusters.

Besides your CPU capacity, take a close look on the memory usage. Regardless of the CPU capacity, as soon as your system starts swapping, the performance dies. I recommend to reduce the number of workers as soon as you observe peak memory usage with leaves less than 1GB free memory.

When your workers load or write data to the HDD, also take a look at it. The best metric for HDD usage is the queue length, as soon as it never reaches zero, you can assume your HDD to be in full usage. More workers won't speed up anything.

If I would have to make a blind guess, I would try it without using the parallel computing toolbox and with 8 workers.

Upvotes: 2

crowdedComputeeer
crowdedComputeeer

Reputation: 469

the short answer is that it is highly variable, dependent on your hardware, your code implementation and the nature of the problem itself.

in general however, a linear speed (ie, ten minutes reduces to five by doubling number of processors) up is the very best case scenario. in reality there is some of amount of overhead associated with parallelism.

your question is open ended. I suggest reading matlab documentation on efficient parallelism strategies

Upvotes: 0

Related Questions