tags:

views:

78

answers:

2

How do I determine the number of CPU cores the PC using code? Is there a way to do it in SAS. I want to determine the number of cores and then set how many threads I should run.

+3  A: 

There is an automatic macro variable called SYSNCPU that gives you the number of CPUs; not sure if this is the figure you're after?

sasfrog
+4  A: 

In SAS:

%put &sysncpu;

In java one would do:

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

In C#:

System.Environment.ProcessorCount

But these are just environment variables which are set by the operating system and can probably be modified through programming. I don't know if you can actually get real hardware information.

lalli
xiaodai
lalli