필터 지우기
필터 지우기

Do I need to initiate the parallel computing toolbox for my code to run on multiple cores?

조회 수: 5 (최근 30일)
I have a function that I minimize using fmincon. I am exploring the possibility of making my code run faster. I got rid of all for loops and replaced them with vectorised code. I further wanted to try the parallel computing toolbox. Yet before doing so, I checked how many cores MATLAB is using because if it is using already multiple cores, why would I need the parallel computing toolbox? Though I am not sure and this is a first question I would like to ask. I noticed that MATLAB actually does use all the cores when I inititate fmincon. How is it possible that multiple cores are used while I did not initiate the parallel comuting toolbox?

채택된 답변

Bruno Luong
Bruno Luong 2022년 3월 21일
편집: Bruno Luong 2022년 3월 21일
MATLAB has many low level functions are multi-thread coded and potentially use all the CPU core.
In this case parallel tbx will not bring you any speed up on the same computer. You can however use GPU, that can speed up in some specific cases.
  댓글 수: 4
Walter Roberson
Walter Roberson 2022년 3월 21일
편집: Walter Roberson 2022년 3월 21일
Most of fmincon does not use multi-threaded core. However:
  • when executing the objective function, any mathematical calculations there are potentially executed in multi-threaded code.
  • However, automatic multi-threading is only done if MATLAB estimates that it would save time to do that, so it tends to restrict it to "expensive" calculations that can be carried out in parallel, or to operations that work on large arrays. For example adding two arrays can potentially be done with multiple threads -- for example each column could potentially be done independently.... but for small arrays it is faster to do them in a single thread.
  • iterative work can only be effectively run in parallel if it is working on sufficiently large arrays; for the most part, the automatic multi-core algorithms cannot make decisions in parallel.
  • There is a UseParallel option, when enables using the Parallel Computing Toolbox to estimate gradients in parallel.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with Optimization Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by