Re: [PATCH] core-count: A new program to count the number of cpu cores

2009-11-05 Thread Giuseppe Scrivano
Hi Pádraig, Pádraig Brady p...@draigbrady.com writes: Well --available and --all are mutually exclusive and related. That fact is obvious if they're parameters to a single option. But I do take your point that --count is a bit redundant, and I don't see nproc getting many other options, so

Re: [PATCH] core-count: A new program to count the number of cpu cores

2009-11-05 Thread Giuseppe Scrivano
Hello, Erik Auerswald auers...@unix-ag.uni-kl.de writes: Why have an option for the default operation at all? If --available is the same as specifying no option and the only other mode of operation is --all, only the --all option should be recognised. There is no need for --available. it is

Re: [PATCH] core-count: A new program to count the number of cpu cores

2009-11-04 Thread Bruno Haible
There were no further comments except Pádraig's one, so I committed the change: 2009-11-04 Bruno Haible br...@clisp.org Make num_processors more flexible and consistent. * lib/nproc.h (enum nproc_query): New type. (num_processors): Add a 'query' argument. *

Re: [PATCH] core-count: A new program to count the number of cpu cores

2009-11-04 Thread Pádraig Brady
Paolo Bonzini wrote: On 11/04/2009 01:24 AM, Pádraig Brady wrote: BTW, it wouldn't be ambiguous to the program, nor would it be different than the existing meaning, but as you say, users could mistakenly do -P0 when they meant -0P. So I'll make the arg mandatory, but what to choose? n is all

Re: [PATCH] core-count: A new program to count the number of cpu cores

2009-11-04 Thread Giuseppe Scrivano
Bruno Haible br...@clisp.org writes: There were no further comments except Pádraig's one, so I committed the change: 2009-11-04 Bruno Haible br...@clisp.org Make num_processors more flexible and consistent. * lib/nproc.h (enum nproc_query): New type. (num_processors):

Re: [PATCH] core-count: A new program to count the number of cpu cores

2009-11-04 Thread Paolo Bonzini
I have updated the new nproc program to use this change in gnulib. Thanks to Bruno, now nproc has not any logic inside but it is a mere wrapper around the gnulib module. I used as arguments to the new program the same names used by the `nproc_query' enum, except using --overridable instead of

Re: [PATCH] core-count: A new program to count the number of cpu cores

2009-11-03 Thread Pádraig Brady
Paolo Bonzini wrote: I was thinking of an additional option that would automatically decrease -n so that the requested number of processes is started (then of course the load may not be well balanced). So you mean, rather than the current situation of: $ yes . | head -n13 | xargs -n4 -P2 .

Re: [PATCH] core-count: A new program to count the number of cpu cores

2009-11-03 Thread Pádraig Brady
Pádraig Brady wrote: Paolo Bonzini wrote: Maybe we want a --parallel option (too bad -p is taken) for xargs that forces the creation of the number of processes passed with -P or taken from nproc (for example by starting md5sum $1 $5 $9 ..., md5sum $2 $6 $10 ..., etc.)? That would be an

Re: [PATCH] core-count: A new program to count the number of cpu cores

2009-11-03 Thread Paolo Bonzini
seq 1 13 | xargs --parallel -P4 1 5 9 13 2 6 10 3 7 11 4 8 12 (Note there's no -n). Same for seq 1 13 | xargs --parallel on a 4-core machine. This is _by design_ rearranging files, so it requires an option. Right, you're not auto decreasing -n, but when we read all args and we pass

Re: [PATCH] core-count: A new program to count the number of cpu cores

2009-11-03 Thread Pádraig Brady
Ralf Wildenhues wrote: * Pádraig Brady wrote on Tue, Nov 03, 2009 at 12:35:05PM CET: --- a/doc/find.texi +++ b/doc/find.texi @@ -3521,6 +3521,15 @@ Use at most @var{max-args} arguments per command line. Fewer than option) is exceeded, unless the @samp{-x} option is given, in which case

Re: [PATCH] core-count: A new program to count the number of cpu cores

2009-11-03 Thread Ralf Wildenhues
* Pádraig Brady wrote on Tue, Nov 03, 2009 at 12:35:05PM CET: --- a/doc/find.texi +++ b/doc/find.texi @@ -3521,6 +3521,15 @@ Use at most @var{max-args} arguments per command line. Fewer than option) is exceeded, unless the @samp{-x} option is given, in which case @code{xargs} will exit.

Re: [PATCH] core-count: A new program to count the number of cpu cores

2009-11-03 Thread Paolo Bonzini
On 11/04/2009 01:24 AM, Pádraig Brady wrote: BTW, it wouldn't be ambiguous to the program, nor would it be different than the existing meaning, but as you say, users could mistakenly do -P0 when they meant -0P. So I'll make the arg mandatory, but what to choose? n is all I can come up with in my

Re: [PATCH] core-count: A new program to count the number of cpu cores

2009-11-01 Thread Pádraig Brady
Giuseppe Scrivano wrote: Hi Pádraig, Pádraig Brady p...@draigbrady.com writes: I do wonder though whether it would be better to have num_processors() try to return this by default? num_processors is going to be used by programs as nproc will be used by scripts; all considerations we

Re: [PATCH] core-count: A new program to count the number of cpu cores

2009-11-01 Thread Bruno Haible
Pádraig Brady wrote: num_processors() already uses _NPROCESSORS_ONLN (online processors) so I then wondered how this be different to that returned by pthread_getaffinity_np() ? A quick google for cpuset shows: http://www.kernel.org/doc/man-pages/online/pages/man7/cpuset.7.html Also this

Re: [PATCH] core-count: A new program to count the number of cpu cores

2009-11-01 Thread Pádraig Brady
Bruno Haible wrote: Here is a proposed change to the gnulib 'nproc' module. It will require changes (simplification) on Giuseppe's side, of course. Wow, this is great stuff Bruno, thanks! *** lib/nproc.c.orig 2009-11-01 14:55:37.0 +0100 --- lib/nproc.c 2009-11-01

Re: [PATCH] core-count: A new program to count the number of cpu cores

2009-10-31 Thread Giuseppe Scrivano
Hi, I included what we have discussed into my patch. I renamed the new program to `nproc', now it accepts two options: --available and --installed. By default --available is used, if --available is not know then --installed is used. I added another test to ensure nproc --available = nproc

Re: [PATCH] core-count: A new program to count the number of cpu cores

2009-10-31 Thread Jim Meyering
Giuseppe Scrivano wrote: I included what we have discussed into my patch. I renamed the new program to `nproc', now it accepts two options: --available and --installed. By default --available is used, if --available is not know then --installed is used. I added another test to ensure nproc

Re: [PATCH] core-count: A new program to count the number of cpu cores

2009-10-31 Thread Giuseppe Scrivano
Hi Jim, thanks for your quick review. Jim Meyering j...@meyering.net writes: Giuseppe Scrivano wrote: I included what we have discussed into my patch. I renamed the new program to `nproc', now it accepts two options: --available and --installed. By default --available is used, if

Re: [PATCH] core-count: A new program to count the number of cpu cores

2009-10-31 Thread Jim Meyering
Giuseppe Scrivano wrote: ... From d1dd83a6a4130ee8b8be47d5d5db461fc60e166a Mon Sep 17 00:00:00 2001 ... diff --git a/NEWS b/NEWS index 0760775..6b8f6b3 100644 --- a/NEWS +++ b/NEWS @@ -60,6 +60,10 @@ GNU coreutils NEWS-*- outline -*- touch now accepts

Re: [PATCH] core-count: A new program to count the number of cpu cores

2009-10-31 Thread Pádraig Brady
Thanks for continuing with this. I'm not sure we agreed on the name but I like nproc at least :) Giuseppe Scrivano wrote: +...@item --available +...@opindex --available +Print the number of processors available to the current process. It +may be less than the number of installed processors.

Re: [PATCH] core-count: A new program to count the number of cpu cores

2009-10-31 Thread Giuseppe Scrivano
Hi Pádraig, Pádraig Brady p...@draigbrady.com writes: I do wonder though whether it would be better to have num_processors() try to return this by default? num_processors is going to be used by programs as nproc will be used by scripts; all considerations we made for nproc can be applied to

Re: [PATCH] core-count: A new program to count the number of cpu cores

2009-10-27 Thread Giuseppe Scrivano
Hi Bruno, Bruno Haible br...@clisp.org writes: No, it should not be a hardware inspection tool but a portable tool to help shell scripts to have an idea of how many processes can be executed at the same time. If we get too much into details then we loose portability Good. This is

Re: [PATCH] core-count: A new program to count the number of cpu cores

2009-10-27 Thread Paolo Bonzini
Some programs, like 'msgmerge' from GNU gettext, already pay attention to the OMP_NUM_THREADS variable - a convention shared by all programs that rely on OpenMP. Can you make the 'sort' program use the same convention? I am not working on the multi-threaded sort, but if somebody asks I can

Re: [PATCH] core-count: A new program to count the number of cpu cores

2009-10-27 Thread Pádraig Brady
Paolo Bonzini wrote: Some programs, like 'msgmerge' from GNU gettext, already pay attention to the OMP_NUM_THREADS variable - a convention shared by all programs that rely on OpenMP. Can you make the 'sort' program use the same convention? I am not working on the multi-threaded sort, but

Re: [PATCH] core-count: A new program to count the number of cpu cores

2009-10-27 Thread Pádraig Brady
Pádraig Brady wrote: Paolo Bonzini wrote: Of course this should only apply if its effect is not externally observable; if I have a very small file B and a very large file A, and I can get $ md5sum --threads A B abcdabcdabcdabcdabcdabcdabcdabcd B

Re: [PATCH] core-count: A new program to count the number of cpu cores

2009-10-27 Thread Pádraig Brady
Paolo Bonzini wrote: Maybe we want a --parallel option (too bad -p is taken) for xargs that forces the creation of the number of processes passed with -P or taken from nproc (for example by starting md5sum $1 $5 $9 ..., md5sum $2 $6 $10 ..., etc.)? That would be an interesting alternative to

Re: [PATCH] core-count: A new program to count the number of cpu cores

2009-10-27 Thread Paolo Bonzini
On 10/27/2009 01:16 PM, Pádraig Brady wrote: I already suggested to the xargs maintainer that `xargs -P` should be equivalent to xargs -P$(nproc). I was thinking of an additional option that would automatically decrease -n so that the requested number of processes is started (then of course

Re: [PATCH] core-count: A new program to count the number of cpu cores

2009-10-27 Thread Pádraig Brady
Paolo Bonzini wrote: On 10/27/2009 01:16 PM, Pádraig Brady wrote: I already suggested to the xargs maintainer that `xargs -P` should be equivalent to xargs -P$(nproc). I was thinking of an additional option that would automatically decrease -n so that the requested number of processes is

Re: [PATCH] core-count: A new program to count the number of cpu cores

2009-10-27 Thread Paolo Bonzini
I was thinking of an additional option that would automatically decrease -n so that the requested number of processes is started (then of course the load may not be well balanced). So you mean, rather than the current situation of: $ yes . | head -n13 | xargs -n4 -P2 . . . . . . . . . . . . .

Re: [PATCH] core-count: A new program to count the number of cpu cores

2009-10-27 Thread Bruno Haible
Pádraig Brady wrote: Of course this should only apply if its effect is not externally observable; if I have a very small file B and a very large file A, and I can get $ md5sum --threads A B abcdabcdabcdabcdabcdabcdabcdabcd B 12341234123412341234123412341234 A Then the

Re: [PATCH] core-count: A new program to count the number of cpu cores

2009-10-27 Thread Giuseppe Scrivano
Bruno Haible br...@clisp.org writes: Pádraig Brady wrote: Of course this should only apply if its effect is not externally observable; if I have a very small file B and a very large file A, and I can get $ md5sum --threads A B abcdabcdabcdabcdabcdabcdabcdabcd B

Re: [PATCH] core-count: A new program to count the number of cpu cores

2009-10-26 Thread Bruno Haible
Hi Giuseppe, No, it should not be a hardware inspection tool but a portable tool to help shell scripts to have an idea of how many processes can be executed at the same time. If we get too much into details then we loose portability Good. This is important info; IMO it belongs in the

[PATCH] core-count: A new program to count the number of cpu cores (was: [PATCH] md5: accepts a new --threads option)

2009-10-25 Thread Giuseppe Scrivano
Jim Meyering j...@meyering.net writes: If nobody is already working on it, I can start doing it. What about the name? ncores or ncpus are fine? Here are some longer candidates: count-cores count-cpus cpu-count core-count Actually, cpu seems too ambiguous, so let's rule those

Re: [PATCH] core-count: A new program to count the number of cpu cores (was: [PATCH] md5: accepts a new --threads option)

2009-10-25 Thread Pádraig Brady
Giuseppe Scrivano wrote: Jim Meyering j...@meyering.net writes: If nobody is already working on it, I can start doing it. What about the name? ncores or ncpus are fine? Here are some longer candidates: count-cores count-cpus cpu-count core-count Actually, cpu seems too

Re: [PATCH] core-count: A new program to count the number of cpu cores

2009-10-25 Thread Bruno Haible
Giuseppe Scrivano wrote: I went for `core-count'. This is the first version of the new program, it is a simple wrapper around the gnulib nproc module This program (and the underlying gnulib 'nproc' module) is IMO too simplistic. First of all, is the program meant to be a hardware inspection

Re: [PATCH] core-count: A new program to count the number of cpu cores

2009-10-25 Thread Giuseppe Scrivano
Bruno Haible br...@clisp.org writes: This program (and the underlying gnulib 'nproc' module) is IMO too simplistic. First of all, is the program meant to be a hardware inspection tool (like hwinfo --cpu)? Or is meant to be an auxiliary program for helping shell scripts that want to dispatch