How to get the number of logical cores - parallel computing toolbox
Show older comments
Is there a programmatic way to get the number of logical cores? The feature command shows me this in text, but I want a way to directly access the number. The code below returns the number of physical cores. Is there a similar way to do this for logical cores?
numcores = feature('numcores')
numcores =
2
feature('numcores')
MATLAB detected: 2 physical cores.
MATLAB detected: 4 logical cores.
MATLAB was assigned: 4 logical cores by the OS.
MATLAB is using: 2 logical cores.
MATLAB is not using all logical cores because hyper-threading is enabled.
ans =
2
Accepted Answer
More Answers (1)
Lutz Pegel
on 22 Jun 2020
4 votes
For logical cores this might be easier to use :
getenv('NUMBER_OF_PROCESSORS')
Categories
Find more on Mathematics and Optimization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!