[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
number of processors
From: |
Philipp Gortan |
Subject: |
number of processors |
Date: |
Tue, 27 Aug 2002 15:59:20 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.1) Gecko/20020826 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
hi community,
I am working on 3 machines simultaneously:
- - a linux box, 1 processor
- - a sun machine, 2 processors
- - and a sun machine, 4 processors
I'd like to have a script that guesses/reads out the number of
processors each machine has and uses this as a parameter for the make
command, e.g. make -j 1, make -j 2 and make -j 4, respectively.
under linux, i find the information in the proc device, whereas solaris
features a uname -X with NumCPU. So I built the following script:
<code>
AC_MSG_CHECKING([number of processors])
PROC_NR=""
case "$MACHTYPE" in
~ i686-*-linux) test -f /proc/cpuinfo && \
PROC_NR=`grep processor /proc/cpuinfo | \
wc -l | awk '{print $1}'`
;;
~ sparc-*-solaris*) PROC_NR=`uname -X | grep NumCPU | \
awk '{print $3}'`
;;
~ *)
AC_MSG_ERROR([Sorry, we don't support $MACHTYPE])
;;
esac
AC_SUBST([MAKE], ["make -j $PROC_NR"])
AC_MSG_RESULT([$PROC_NR])
</code>
the script works fine on all machines, but i'm not especially satisfied,
as for each new machine added, the script has to be manually modified.
so, my question is:
is there a more sophisticated way to figure out the number of processors
of the host machine?
thanks for you wisdom ;-)
cu, philipp
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQE9a4W06My5N1RlryQRAiPdAJ0fuctF9UGv7XmbGyasURcapADQUQCdHIMz
eVy6bxo9ppUZHQJ8FWTGDWY=
=cuCV
-----END PGP SIGNATURE-----
- number of processors,
Philipp Gortan <=