How to determine the number of processor cores on a PC?

How to determine the number of PC core processors using code? Is there any way to do this in SAS. I want to determine the number of cores, and then set how many threads I have to execute.

+3
source share
3 answers

In SAS:

%put &sysncpu;

In java, one could do:

Runtime runtime = Runtime.getRuntime();
int nrOfProcessors = runtime.availableProcessors();

In C #:

System.Environment.ProcessorCount

But these are only environment variables that are set by the operating system and can probably be changed by programming. I do not know if you can really get real information about the equipment.

+4
source

There is an automatic macro variable SYSNCPU, which gives you the number of processors; not sure if this is the indicator you are after?

+3
source

Delphi

function TSpinLockPerProcReaderWriterLock.NumberProcessors: Integer;
var
    systemInfo: SYSTEM_INFO;
begin
    GetSystemInfo({var}systemInfo);
    Result := systemInfo.dwNumberOfProcessors;
end;   

#:

int NumberProcessors()
{
   SYSTEM_INFO systemInfo;

   GetSystemInfo(ref systemInfo);
   return systemInfo.dwNumberOfProcessors;
}

. , . .

+1

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


All Articles