Reputation: 7188
I'm currently writing some code in MATLAB that uses the parfor
loop to speed up some tedious calculations.
My issue is that the code will be run on a remote cluster, and could be run on 4-core, 8-core or 12-core machines (I won't know which one in advance)...
I basically need a code snippet that will allow MATLAB to determine the maximum number of cores that can be used in matlabpool. If we call this variable maxcores
, I can then go ahead and use
matlabpool('open',maxcores)
.
so that I can make sure that I am using all the cores that are available to me.
Upvotes: 3
Views: 6768
Reputation: 21
Beyond Dougal's response, I found getenv('NUMBER_OF_PROCESSORS')
returns the number of threads on my Windows systems.
Upvotes: 2