[sage-devel] Re: platform independent way of getting the number of processors

2009-03-30 Thread Peter Jeremy
On 2009-Mar-29 11:55:48 -0700, Ondrej Certik wrote: >I think I will just add more targets to the makefile in the top >directory, e.g. something like > >make # use 1 processor >make parallel # use all processors >JOBS=3 make # use 3 processors FWIW, FreeBSD has just implemented something simila

[sage-devel] Re: platform independent way of getting the number of processors

2009-03-29 Thread Roman Pearce
On Mar 29, 12:49 am, Ondrej Certik wrote: > I just tried the following code on several linuxes (Debian, Ubuntu, > Gentoo, Red Hat, OpenSUSE) and on OS X 10.5 Intel and it seems to just > work everywhere: > > #include "unistd.h" > #include "stdio.h" > > int main() > { >     int ncpus; >     ncpus

[sage-devel] Re: platform independent way of getting the number of processors

2009-03-29 Thread William Stein
On Sun, Mar 29, 2009 at 11:34 AM, Peter Jeremy wrote: > On 2009-Mar-28 14:53:46 -0700, Ondrej Certik wrote: >>I am trying to figure out the best way to automatically determine the >>number of processors and used that information to speed up Sage build. > > Note that this should be able to be ove

[sage-devel] Re: platform independent way of getting the number of processors

2009-03-29 Thread Ondrej Certik
On Sun, Mar 29, 2009 at 11:34 AM, Peter Jeremy wrote: > On 2009-Mar-28 14:53:46 -0700, Ondrej Certik wrote: >>I am trying to figure out the best way to automatically determine the >>number of processors and used that information to speed up Sage build. > > Note that this should be able to be ove

[sage-devel] Re: platform independent way of getting the number of processors

2009-03-29 Thread Peter Jeremy
On 2009-Mar-28 14:53:46 -0700, Ondrej Certik wrote: >I am trying to figure out the best way to automatically determine the >number of processors and used that information to speed up Sage build. Note that this should be able to be over-ridden by the operator - just because a system has (say) 8 co

[sage-devel] Re: platform independent way of getting the number of processors

2009-03-29 Thread Ondrej Certik
Hi Elliott, On Sat, Mar 28, 2009 at 3:59 PM, Elliott wrote: > > If the user has Java installed, you could execute a .class file to get > this information; for example: > > public class NumProcessors { >  public static void main(String[] args) { >    System.out.println(Runtime.getRuntime().availa

[sage-devel] Re: platform independent way of getting the number of processors

2009-03-29 Thread Ondrej Certik
Hi Roman, On Sat, Mar 28, 2009 at 4:40 PM, Roman Pearce wrote: > > /* Linux */ > #include > int sched_getaffinity(pid_t pid, unsigned int cpusetsize, cpu_set_t > *mask); > > static inline int num_processors() > { >        unsigned int bit; >        int np; >        cpu_set_t aff; >        memse

[sage-devel] Re: platform independent way of getting the number of processors

2009-03-28 Thread Roman Pearce
/* Linux */ #include int sched_getaffinity(pid_t pid, unsigned int cpusetsize, cpu_set_t *mask); static inline int num_processors() { unsigned int bit; int np; cpu_set_t aff; memset(&aff, 0, sizeof(aff) ); sched_getaffinity(0, sizeof(aff), &aff );

[sage-devel] Re: platform independent way of getting the number of processors

2009-03-28 Thread Elliott
If the user has Java installed, you could execute a .class file to get this information; for example: public class NumProcessors { public static void main(String[] args) { System.out.println(Runtime.getRuntime().availableProcessors()); } } If you compiled this and put the resulting .clas

[sage-devel] Re: platform independent way of getting the number of processors

2009-03-28 Thread Ondrej Certik
> 3) if it doesn't build, we are on Mac probably, so run sysctl -n > hw.ncpu     (I don't have any Mac to test it on, but I guess there > might be a way to actually write the C program in a portable way to > work both on linux and Mac) So according to this thread: http://www.nabble.com/-patch--l