bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Bruno Haible
Subject: Re: [PATCH] core-count: A new program to count the number of cpu cores
Date: Sun, 25 Oct 2009 22:41:00 +0100
User-agent: KMail/1.9.9

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 tool (like
"hwinfo --cpu")? Or is meant to be an auxiliary program for helping shell
scripts that want to dispatch tasks onto a maximum number of processors?

If it is meant to be a hardware inspection tool, then it should IMO try to
reflect current multiprocessing hardware architectures. I mean the fact that
a computer's central unit can have several thread execution units, combined
at three different levels:
  - Several CPU modules in a single computer,
  - Several CPU chips in a single package (multi-chip module [2]),
  - Several execution cores on a single chip (multi-core [3]),
  - Several thread execution units per CPU core (hyper-threading [4]).
See the first paragraph of [1].

If it is meant as a tool for helping the parallelization of tasks at the
shell script level, then it needs to take into account
  1) the fact that the current process may be limited to a certain subset
     of the available CPUs. See the Linux/NetBSD function
     pthread_setaffinity_np [5][6] and the IRIX notion of a CPU that is
     available only to root processes [7].
  2) the wish of users to not use all processors at once. Users may want to
     save 1 CPU for their GUI interactions. This can most comfortably be
     done through an environment variable, such as OMP_NUM_THREADS. [8]
An implementation that considers 1) and 2) can be found in OpenMP. So,
why not simply use the function omp_set_num_threads() that is provided
by GCC in its libgomp library (in a compiler agnostic way through the
AC_OPENMP macro of Autoconf)?

Bruno


[1] http://en.wikipedia.org/wiki/Multiprocessing
[2] http://en.wikipedia.org/wiki/Multi-chip_module
[3] http://en.wikipedia.org/wiki/Multi-core_(computing)
[4] http://en.wikipedia.org/wiki/Hyper-threading
[5] 
http://www.kernel.org/doc/man-pages/online/pages/man3/pthread_setaffinity_np.3.html
[6] http://www.daemon-systems.org/man/pthread_getaffinity_np.3.html
[7] 
http://techpubs.sgi.com/library/tpl/cgi-bin/getdoc.cgi?cmd=getdoc&coll=0650&db=man&fname=2%20sysmp
[8] http://gcc.gnu.org/onlinedocs/libgomp/OMP_005fNUM_005fTHREADS.html




reply via email to

[Prev in Thread] Current Thread [Next in Thread]