


PARALLEL CONTEXT In a parallel context this function return the CPUs or cores numer avaiable on the computer used for run parallel code. INPUTS an array contained several fields that describe the hardaware software enviroments of a generic computer. OUTPUTS The CPUs or Cores numbers of computer. SPECIAL REQUIREMENTS none


0001 function [nCPU]= GiveCPUnumber (ComputerInformations) 0002 % PARALLEL CONTEXT 0003 % In a parallel context this function return the CPUs or cores numer avaiable 0004 % on the computer used for run parallel code. 0005 % 0006 % INPUTS 0007 % an array contained several fields that describe the hardaware 0008 % software enviroments of a generic computer. 0009 % 0010 % OUTPUTS 0011 % The CPUs or Cores numbers of computer. 0012 % 0013 % SPECIAL REQUIREMENTS 0014 % none 0015 0016 % Copyright (C) 2010-2011 Dynare Team 0017 % 0018 % This file is part of Dynare. 0019 % 0020 % Dynare is free software: you can redistribute it and/or modify 0021 % it under the terms of the GNU General Public License as published by 0022 % the Free Software Foundation, either version 3 of the License, or 0023 % (at your option) any later version. 0024 % 0025 % Dynare is distributed in the hope that it will be useful, 0026 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0027 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0028 % GNU General Public License for more details. 0029 % 0030 % You should have received a copy of the GNU General Public License 0031 % along with Dynare. If not, see <http://www.gnu.org/licenses/>. 0032 0033 0034 nCPU=''; 0035 0036 Enviroment=-1; 0037 0038 % Determine a specific operating system or software version when necessary 0039 % for different command (sintax, name, ...). 0040 Enviroment=~ispc; %isunix || (~matlab_ver_less_than('7.4') && ismac); 0041 0042 switch Enviroment 0043 case 0 %WINDOWS OPERATING SYSTEM 0044 0045 OffSet=27; 0046 0047 SringPosition=strfind(ComputerInformations, 'Processors:'); 0048 nCPU=ComputerInformations(SringPosition+OffSet); 0049 0050 % We check if there are Processors/Cores more than 9. 0051 0052 0053 t0=ComputerInformations(SringPosition+OffSet+1); 0054 t1=str2num(t0); 0055 t1=isempty(t1); 0056 0057 % if t1 is 0 the machine have more than 9 CPU. 0058 0059 if t1==0 0060 nCPU=strcat(nCPU,t0); 0061 end 0062 0063 nCPU=str2num(nCPU); 0064 0065 return 0066 case 1 %LIKE UNIX OPERATING SYSTEM 0067 0068 % Da generalizzare a un numero di CPu maggiore di 9!!! 0069 0070 nCPU=str2num(ComputerInformations(length(ComputerInformations)-1))+1; 0071 0072 end