MATLAB: control the number of cores / threads

Suppose I have a program that should run on a Linux machine with 32 cores (64 threads), of which I am allowed to use only 10 cores (20 threads). Therefore, I would like to indicate this before starting the program.

I googled and found maxNumCompThreads, but it does not work when I test it on a machine with MATLAB 2016a, i5 core ( 2 cores, 4 threads ). That is, I get the same conclusion for feature('numCores')when I do any of the following

maxNumCompThreads(1)
maxNumCompThreads(2)
maxNumCompThreads(4)
maxNumCompThreads('Automatic')

Then I tried parpool(every time I closed the current parpool session with delete(gcp('nocreate'))). I received an error message at startup parpool(4)(I think I understand why: it parpoolaccepts the number of cores, and hyperthreading is turned on automatically, and the test machine has only 2 physical cores). Therefore, I tested with parpool(1)and parpool(2). Again, the output for notfeature('numCores') changed .

Question : so this is the right tool to work for the situation described in the first paragraph above? And is there a feature('numCores')proper monitoring tool to find out if the relevant specification is valid?


The same conclusion feature('numCores')that I talk about above:

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.

Edit : when I run parpool(10)on a Linux machine, I got the following error

Starting parallel pool (parpool) using the 'local' profile ... Error using parpo              ol (line 103)
Couldn't interpret output from psname.sh: ""

Error in parpool_test_2016_10_03 (line 3)
parpool(10);
+4
1

, . feature('numthreads'):

>> feature('numcores')
MATLAB detected: 4 physical cores.
MATLAB detected: 8 logical cores.
MATLAB was assigned: 8 logical cores by the OS.
MATLAB is using: 4 logical cores.
MATLAB is not using all logical cores because hyper-threading is enabled.

ans =    
     4

>> feature('numthreads')    
ans =    
     4

>> maxNumCompThreads(1)    
ans =    
     4

>> feature('numcores')
MATLAB detected: 4 physical cores.
MATLAB detected: 8 logical cores.
MATLAB was assigned: 8 logical cores by the OS.
MATLAB is using: 4 logical cores.
MATLAB is not using all logical cores because hyper-threading is enabled.

ans =    
     4

>> feature('numthreads')    
ans =    
     1

, feature, . fooobar.com/questions/392056/... feature.

0

Source: https://habr.com/ru/post/1656588/


All Articles