Matlab not using all physical cores on Intel CPU?
26 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I am running Matlab on different mobile Intel CPUs with different number of physical cores. I intend to compare execution speed of my scripts (numerical calculations, Curve Fitting Toolbox only). All laptops run under Windows 10, with 32GB RAM (DDR4), SSD HD and are fitted with the following CPU models:
- CPU1: i7-7600U, 2 cores / 4 threads (2 physical + 2 logical cores),
- CPU2: i7-6700HQ, 4 cores / 8 threads (4 physical + 4 logical cores),
- CPU3: i7-9850H, 6 cores / 12 threads (6 physical + 6 logical cores),
I have observed that Malab is not using all physical cores (NOT logical ones!), but its behaviour is different on these CPUs:
- CPU1: all 4 threads with +/- equal load, total load ~50% (which is clear - physical and logical cores share the same CPU resources)
- CPU2: all 8 threads with +/- equal load, total load ~50%
- CPU3: one (physical?) core with almost 100% load and the rest with minimal load, total load < 20%
Multithreading & co options are enabled in BIOS in all laptops.
I had hoped to speedup execution with the 6/12 core CPU, but so far I have not seen any significant "boost" effect.
Is there any reason behind this phenomenon / asymmetry? Could the thread distribution onto multiple cores depend on the Windows version (all three the same), Matlab version (I haven't noticed any significant difference between 2023a / 2024a / 2024b), or on CPU itselt?
Would switching to an 8/16 AMD Ryzen CPU, or an Intel CPU (with "clever" balance between P/E cores) improve performance?
By the way, I do understand that Matlab cannot (easily) use all available cores if code (script) cannot be parallelised (e.g. while loop) and has to be executed sequentially. However, why can the same code make all cores (apparently) "busy" on a 2+2 CPU, but not on a CPU with more physical cores?
Thank you in advance!
0 commentaires
Réponses (1)
Harald
le 19 Fév 2025
Modifié(e) : Harald
le 19 Fév 2025
Hi,
it sounds that your code can only benefit from "built-in multithreading" as described here: https://www.mathworks.com/discovery/matlab-multicore.html
If your goal is to efficiently use multiple cores for curve fitting, I would recommend looking into parallel gradient evaluation. A number of solvers in Optimization Toolbox and Global Optimization Toolbox let you set UseParallel to true via optimoptions.
It would be great if you could share more details about your problem (number of parameters, type of model you try to fit), ideally some reproducible code.
Best wishes,
Harald
4 commentaires
Harald
le 17 Mar 2025
Hi Marek,
if you have managed to do the subdividing, parfor (or parfeval) should be feasible and would have the benefit of being able to process the results in an automated way.
The question of P and E cores is a different one, and I can't say too much about that. You may find this and other answers on the topic helpful:
If the answers you find that way are not sufficient, I recommend asking a new question.
Best wishes,
Harald
Voir également
Catégories
En savoir plus sur Matrix Indexing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!