maxNumCompThreads returns the number of available CPU cores, works with Windows, Linux, OpenBSD and MAC-OS, using a c-coded mex-file.
N = maxNumCompThreads()
Replacement of the original "Matlab maxNumCompThreads" which will be removed in a future release.
We need to control the number of threads in a large multiprocessor multiuser system.
N = getenv('NUMBER_OF_PROCESSORS')
let's you see max number of threads, halve it if you are hyperthreading, min with 12 or 8 depending which matlab version you have for max allowable matlab poolsize
This is hardly a replacement, as the original maxNumCompThreads is capable of actually setting the number of threads.
The planned removal of this capability has been bugging me for quite some time. I am thinking about reviving a custom function, using omp_set_num_threads:
http://www.mathworks.com/matlabcentral/newsreader/view_thread/170152 (see comment 12). This should work at least for the BLAS subsystem.
How about the number of cores? If you are launching (single-threaded) processes then I think that's the number that's important.
Cool, I never saw this undocumented function before. But it is of course the question if it will be presented in future versions.
All features : usehg2, useGBT2, HGUsingMatlabClasses, JavaFigures, UseJava, ClearJava, SetPrecision, SetRound, NewPrintAPI, accel, GetOS, GetWinSys, GetPid, NumCores, MemStats, CheckMallocMemoryUsage, CheckMallocHeapWalk, ShowCommandWindow, LogDir, HotLinks, UseOldFileDialogs, timing, memtic, locale, DefaultCharacterSet, COM_SafeArraySingleDim, COM_ActxProgidCheck, FigureTools, TimeSeriesTools, launch_activation, EightyColumns, GetSharedLibExt, GetDefaultPrinter, GetPrinterInfo, GetPrinterColor, GetSpecifiedPrinterPort, ShowFigureWindows, SearchUDDClassesForHelp, AutomationServer, EnableDDE, GetUserWorkFolder, DirsAddedFreeze, DirsAddedUnfreeze, ToolboxFreeze, ToolboxUnfreeze, DirChangeHandleWarn, DirReloadMsg, RemoteCWDPolicy, RemotePathPolicy, GetPref, IsDebugMode, ForceFramesOnBottom, UseMesaSoftwareOpenGL, UseGenericOpengl, GetOpenglInfo, GetOpenglData, OpenGLVerbose
or you could simply use the following undocumented function:
Replaced "wrapping" code by more elegant version of James Tursa