[R] Programmaticly finding number of processors by R code

2010-10-03 Thread Ajay Ohri
Dear List

Sorry if this question seems very basic.

Is there a function to pro grammatically find number of processors in
my system _ I want to pass this as a parameter to snow in some serial
code to parallel code functions

Regards

Ajay



Websites-
http://decisionstats.com
http://dudeofdata.com


Linkedin- www.linkedin.com/in/ajayohri

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Programmaticly finding number of processors by R code

2010-10-03 Thread Prof Brian Ripley
Without knowing your OS, there is no way anyone can tell you.  And you 
probably want to know 'cores' rather than CPUs. And for some specific 
OSes, you will find answers in the archives.


Beware that this is not a well-defined question: are these 
physical or virtual cores?, and having them in the system and being 
allowed to use them are different questions.


Package 'multicore' is one that attempts to do this in its function 
detectCores (see the source code).  And on Sparc Solaris it is pretty 
useless as it gives virtual CPUs, 8x the number of real CPUs.


On Sun, 3 Oct 2010, Ajay Ohri wrote:


Dear List

Sorry if this question seems very basic.

Is there a function to pro grammatically find number of processors in
my system _ I want to pass this as a parameter to snow in some serial
code to parallel code functions

Regards

Ajay



Websites-
http://decisionstats.com
http://dudeofdata.com


Linkedin- www.linkedin.com/in/ajayohri

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Programmaticly finding number of processors by R code

2010-10-03 Thread Ajay Ohri
windows and ubuntu linux are my OS

intent is to use them in the snow makecluster statement so I am not sure
what I need cores,cpus,real,virtual

basically the max amount of clusters i can create on my machine

2) if I have a workgroup on windows - can i detect cores/cpus on the network
using the detectcore

Ajay

Websites-
http://decisionstats.com
http://dudeofdata.com


Linkedin- www.linkedin.com/in/ajayohri




On Mon, Oct 4, 2010 at 1:25 AM, Prof Brian Ripley rip...@stats.ox.ac.ukwrote:

 Without knowing your OS, there is no way anyone can tell you.  And you
 probably want to know 'cores' rather than CPUs. And for some specific OSes,
 you will find answers in the archives.

 Beware that this is not a well-defined question: are these physical or
 virtual cores?, and having them in the system and being allowed to use them
 are different questions.

 Package 'multicore' is one that attempts to do this in its function
 detectCores (see the source code).  And on Sparc Solaris it is pretty
 useless as it gives virtual CPUs, 8x the number of real CPUs.


 On Sun, 3 Oct 2010, Ajay Ohri wrote:

  Dear List

 Sorry if this question seems very basic.

 Is there a function to pro grammatically find number of processors in
 my system _ I want to pass this as a parameter to snow in some serial
 code to parallel code functions

 Regards

 Ajay



 Websites-
 http://decisionstats.com
 http://dudeofdata.com


 Linkedin- www.linkedin.com/in/ajayohri

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


 --
 Brian D. Ripley,  rip...@stats.ox.ac.uk
 Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
 University of Oxford, Tel:  +44 1865 272861 (self)
 1 South Parks Road, +44 1865 272866 (PA)
 Oxford OX1 3TG, UKFax:  +44 1865 272595


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Programmaticly finding number of processors by R code

2010-10-03 Thread Peter Langfelder
If no-one replies with a better way, here's a way: under
POSIX-compliant systems, you can write a small C function and wrap it
in an R function.

The C program would be something like

#include unistd.h
void nProcessors(int  n)
{
#ifdef _SC_NPROCESSORS_ONLN
  long nProcessorsOnline = sysconf(_SC_NPROCESSORS_ONLN);
#else
  long nProcessorsOnline = 2; // This is my guess - most computers
today have at least 2 cores
#endif
  n = (int) nProcessorsOnline;
}

You need to compile the function into a dynamic library (shared
object on linux) and load the dynamic library with dyn.load before
using it.

The R wrapper would be a function along the lines of

nProcessors = function()
{
   n = 0;
   res = .C(nProcessors, n = as.integer(n));
   res$n
}

I haven't actually tested the R function so please take this with a
grain of salt, but I do use the C function in my own C code. You may
also want to read this thread about potential pitfalls and
limitations, plus another (simpler) way that would work on linux:

http://forum.soft32.com/linux2/CPUs-machine-ftopict13343.html

AFAIK, this will not work on Windows because Windows is not POSIX
compliant, but I'm not sure.

Peter


On Sun, Oct 3, 2010 at 10:03 AM, Ajay Ohri ohri2...@gmail.com wrote:
 Dear List

 Sorry if this question seems very basic.

 Is there a function to pro grammatically find number of processors in
 my system _ I want to pass this as a parameter to snow in some serial
 code to parallel code functions

 Regards

 Ajay


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Programmaticly finding number of processors by R code

2010-10-03 Thread Henrique Dallazuanna
In windows try this:

 Sys.getenv('NUMBER_OF_PROCESSORS')

On Sun, Oct 3, 2010 at 2:03 PM, Ajay Ohri ohri2...@gmail.com wrote:

 Dear List

 Sorry if this question seems very basic.

 Is there a function to pro grammatically find number of processors in
 my system _ I want to pass this as a parameter to snow in some serial
 code to parallel code functions

 Regards

 Ajay



 Websites-
 http://decisionstats.com
 http://dudeofdata.com


 Linkedin- www.linkedin.com/in/ajayohri

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Programmaticly finding number of processors by R code

2010-10-03 Thread Abhijit Dasgupta, PhD
  If you have installed multicore (for unix/mac), you can find the 
number of cores by /*multicore:::detectCores()*/

On 10/3/10 1:03 PM, Ajay Ohri wrote:
 Dear List

 Sorry if this question seems very basic.

 Is there a function to pro grammatically find number of processors in
 my system _ I want to pass this as a parameter to snow in some serial
 code to parallel code functions

 Regards

 Ajay



 Websites-
 http://decisionstats.com
 http://dudeofdata.com


 Linkedin- www.linkedin.com/in/ajayohri

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


-- 

Abhijit Dasgupta, PhD
Director and Principal Statistician
ARAASTAT
Ph: 301.385.3067
E: adasgu...@araastat.com
W: http://www.araastat.com


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.