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
2010-08-30 04:18:36
+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
2010-08-30 04:18:40
xiaodai
2010-08-30 10:42:08
lalli
2010-08-30 12:49:23