On Wed, 7 Feb 2007, William Stein wrote: > > On Wed, 07 Feb 2007 14:44:08 -0700, Jason Martin <[EMAIL PROTECTED]> wrote: > >> >> On Linux, grep /proc/cpuinfo for lines beginning with "processor". >> Take the line with the biggest number and add one to it. Kinda >> kludgey, but that's the first thing that comes to mind. >> >> On OS X, the command "sysctl hw.ncpu" will give it to you. >> >> On Solaris, I believe that "procinfo" will give it to you, but I >> haven't worked on a Solaris box in a while, so that may be old. >> >> On Windows, I have no clue. >> >> I think that on some x86 platforms, you can actually get this >> information with the "cpuid" assembly instruction. I'll look that up >> and send you some C code to do it if it's possible. > > Perhaps somebody should write a function > > number_of_cpus() > > and put it in a file sage/misc/parallel.py and send me a patch. It would > default to 1 if it can't figure it out using heuristics as > above. Also, it would be customizable, i.e., there could be > a variable one could set in that file that would make number_of_cpus() > just return the value of the variable. > > > William >
Rather than num_cpus, I think at startup time a user should be able to specify a maximum number of parallel processes to span. For instance, if I wanted to run two dsage workers on a machine with 4 cpus, I might want to give each of them only two cpus to use. This could default do the number of cpus in the system. Perhaps this could be called available_cpus() or something like that. If we're using MPI to parallelize stuff, this would boil down to the number of "slave" sage processes started up listining for work over MPI. Also, the number of cpus doesn't take into account the number of parallel process already spawned. There needs to be some way of desciding whether or not parallelization has happened at a higher level. - Robert --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/ -~----------~----~----~----~------~----~------~--~---