fix finding CPU's number when larger than 9

time-shift
MichelJuillard 2019-05-20 09:57:10 +00:00 committed by Sébastien Villemot
parent a2ce1a5607
commit 2977c9336e
2 changed files with 6 additions and 8 deletions

View File

@ -522,7 +522,7 @@ for Node=1:length(DataInput) % To obtain a recoursive function remove the 'for'
if (DataInput(Node).Local == 1) if (DataInput(Node).Local == 1)
if Environment if Environment
if ~ismac if ~ismac
[si0, de0] = system('grep processor /proc/cpuinfo'); [si0, de0] = system('nproc');
else else
[si0, de0] = system('sysctl -n hw.ncpu'); [si0, de0] = system('sysctl -n hw.ncpu');
Environment1 = 2; Environment1 = 2;
@ -539,7 +539,8 @@ for Node=1:length(DataInput) % To obtain a recoursive function remove the 'for'
end end
if OStargetUnix if OStargetUnix
if RemoteEnvironment ==1 if RemoteEnvironment ==1
command_string = ['ssh ',ssh_token,' ',DataInput(Node).UserName,'@',DataInput(Node).ComputerName,' grep processor /proc/cpuinfo']; command_string = ['ssh ',ssh_token,' ', ...
DataInput(Node).UserName,'@',DataInput(Node).ComputerName,' nproc'];
else % it is MAC else % it is MAC
command_string = ['ssh ',ssh_token,' ',DataInput(Node).UserName,'@',DataInput(Node).ComputerName,' sysctl -n hw.ncpu']; command_string = ['ssh ',ssh_token,' ',DataInput(Node).UserName,'@',DataInput(Node).ComputerName,' sysctl -n hw.ncpu'];
Environment1 = 2; Environment1 = 2;
@ -562,7 +563,6 @@ for Node=1:length(DataInput) % To obtain a recoursive function remove the 'for'
end end
RealCPUnbr=''; RealCPUnbr='';
% keyboard;
RealCPUnbr=GiveCPUnumber(de0,Environment1); RealCPUnbr=GiveCPUnumber(de0,Environment1);
% Questo controllo penso che si possa MIGLIORARE!!!!! % Questo controllo penso che si possa MIGLIORARE!!!!!
@ -574,12 +574,12 @@ for Node=1:length(DataInput) % To obtain a recoursive function remove the 'for'
if isempty (RealCPUnbr) if isempty (RealCPUnbr)
% An error occurred when we try to know the Cpu/Cores % An error occurred when we try to know the Cpu/Cores
% numbers. % numbers.
disp('It is impossible determine the number of Cpu/Processor avaiable on this machine!') disp('It is impossible determine the number of Cpu/Processor available on this machine!')
skipline() skipline()
disp('ErrorCode 2.') disp('ErrorCode 2.')
skipline() skipline()
if Environment if Environment
disp('Check the command "$less /proc/cpuinfo" ... !') disp('Check the command "$grep - /proc/cpuinfo" ... !')
else else
disp('Check if the pstools are installed and are in machine path! And check the command "psinfo \\"') disp('Check if the pstools are installed and are in machine path! And check the command "psinfo \\"')
end end

View File

@ -65,9 +65,7 @@ switch Environment
return return
case 1 %LIKE UNIX OPERATING SYSTEM case 1 %LIKE UNIX OPERATING SYSTEM
% Da generalizzare a un numero di CPu maggiore di 9!!! nCPU=str2num(ComputerInformations);
nCPU=str2num(ComputerInformations(length(ComputerInformations)-1))+1;
case 2 %MAC-OS OPERATING SYSTEM case 2 %MAC-OS OPERATING SYSTEM