Questions about the parfor function

2 views (last 30 days)
Hi all,
Is there a way to make the parfor function faster here? My cpu has six physical cores, but it is 12 threads, every parallel calculation matlab shows is connected to 6 works, is there any way to make it connected to 12 works?I want the program to become faster.

Accepted Answer

Rik
Rik on 4 Jul 2022
You can change your settings as described on this doc page. You can also explicitly call the parpool function.
Note that it might not actually speed up your code, as each worker increases overhead and hyperthreaded cores are not always 'complete' cores (so the actual circuitry required for the calculation might be shared by two threads).
It is also not a guarantee that your code will actually be faster with a parfor loop. For more about this point, see this doc page.
  2 Comments
ma Jack
ma Jack on 5 Jul 2022
Thank you sir, I will verify it after a while
Walter Roberson
Walter Roberson on 5 Jul 2022
hyperthreads work well when a process needs to do I/O: when a process volunteers to give up the CPU then another process is immediately ready to take over.
However, except in very limited circumstances, only one of the two hyperthreads per core can compute anything at a time, and the process executing has to volunteer to give up the core for the other hyperthread to proceed. In compute-heavy cases such as MATLAB computation, hyperthreads can end up slowing down computation.

Sign in to comment.

More Answers (0)

Categories

Find more on Parallel Computing Fundamentals in Help Center and File Exchange

Tags

Products


Release

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!