matlabparfor

MATLAB Parfor is running much slower on a 18-core PC than a 10-core PC


I am currently running a compute-intensive financial trading test; the test has 503 independent loops. I have two PCs in my office, one has 10-core Intel i9-10900k @ 3.7GHz with 128GB DDR4; the other one has 18-core Intel i9-7980XE @ 3.4GHz with 128GB DDR4 as well.

In order to speed up the whole processing, the first 10-core PC runs loop 1-to-189 in parfor; the second 18-core PC runs loop 190-to-503 in parfor.

After one-day running, I found the 10-core PC finished 25 loops, the 18-core PC only finished 4 loops. I found very curious, can anyone know the reason of this problem?

P.S. 10-core PC running MATLAB 2020b with latest updates with MOSEK 9.2.35 18-core PC running MATLAB 2021a with latest updates with MOSEK 9.2.36

I also checked the taskmgr.exe, unlike the 10-core PC, I found in 18-core PC, 10 matlab tasks are in one group, the other 10 tasks are seperated....

18-core PC taskmgr

10-core PC taskmgr


Solution

  • Many thanks to Michal Adamaszek, When using the MOSEK (interior-point or integer programming) inside parfor loop, it is better to turn off the multi-threads in MOSEK, otherwise, by default, MOSEK will using all cores.

    param.MSK_IPAR_NUM_THREADS = 1;
    param.MSK_IPAR_INTPNT_MULTI_THREAD = 'MSK_OFF';