View previous topic :: View next topic |
Author |
Message |
concord Apprentice
Joined: 02 Oct 2005 Posts: 193
|
Posted: Fri Jun 06, 2008 2:41 pm Post subject: how to know how many cpu core? |
|
|
Dear friends:
I have installed a gentoo on usb hard disk and I have used it on PIII, P4, amd and multi-cpu/core computer. When compile system or program, I aways re-nano MAKEOPTS in make.conf. So, I want to know, how can I compose the make.conf to adjust the "-j*" automatically? I mean let gentoo know the cpu # and change "-j*" itself. Thanks in advance! _________________ AMD64 Desktop
Pentium4 Laptop
Pentium3 Server |
|
Back to top |
|
|
NeddySeagoon Administrator
Joined: 05 Jul 2003 Posts: 54317 Location: 56N 3W
|
Posted: Fri Jun 06, 2008 3:30 pm Post subject: |
|
|
concord,
Have a file say /etc/make.template with no MAKEOPTS which you copy to /etc/make.conf every boot
Parse /proc/cpuinfo in a script to discover how many CPUs you seem to have (they count from 0)
based on that, add a suitable MAKEOPTS to /etc/make.conf
Put the script into /etc/conf.d/local.start, or call it from there.
Your kernel needs SMP support for the maximum number of cores you will ever want to use. _________________ Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail. |
|
Back to top |
|
|
HyperQuantum Tux's lil' helper
Joined: 27 Sep 2005 Posts: 88
|
Posted: Fri Jun 06, 2008 3:34 pm Post subject: |
|
|
NeddySeagoon wrote: |
Parse /proc/cpuinfo in a script to discover how many CPUs you seem to have (they count from 0)
|
Something like this?
Code: | cat /proc/cpuinfo | grep '^processor' | wc -l |
Correctly returns the number 2 on my laptop. |
|
Back to top |
|
|
eccerr0r Watchman
Joined: 01 Jul 2004 Posts: 9691 Location: almost Mile High in the USA
|
Posted: Fri Jun 06, 2008 8:42 pm Post subject: |
|
|
The script will need to carefully parse /proc/cpuinfo, a simple grep won't work to separate multithread processors properly.
A simple grep for "processor" will report that my hyperthread P4 to have two cores, which is not the case - it can run two threads but only has one core (hyperthreading).
It'd be even worse for multisocket machines that have asymmetric parts in the machine (what if it were possible to put a P4-multithread and a Q6600 in the same machine?) /proc/cpuinfo would be really weird... _________________ Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching? |
|
Back to top |
|
|
Naib Watchman
Joined: 21 May 2004 Posts: 6051 Location: Removed by Neddy
|
Posted: Fri Jun 06, 2008 8:52 pm Post subject: |
|
|
HyperQuantum wrote: | NeddySeagoon wrote: |
Parse /proc/cpuinfo in a script to discover how many CPUs you seem to have (they count from 0)
|
Something like this?
Code: | cat /proc/cpuinfo | grep '^processor' | wc -l |
Correctly returns the number 2 on my laptop. |
1) don't use cat like that, cat is for joining files
2) don't use grep like that, grep can accept a file as an input: Code: | cat /proc/cpuinfo | grep '^processor' | wc -l |
and as stated false-positive occur
Code: | grep "Initializing CPU" <(dmesg) | wc -l |
should be better _________________
Quote: | Removed by Chiitoo |
|
|
Back to top |
|
|
think4urs11 Bodhisattva
Joined: 25 Jun 2003 Posts: 6659 Location: above the cloud
|
Posted: Fri Jun 06, 2008 11:09 pm Post subject: |
|
|
Naib wrote: | Code: | grep "Initializing CPU" <(dmesg) | wc -l |
|
the wc -l is dispensable, better use Code: | grep -c "Initializing CPU" <(dmesg) |
_________________ Nothing is secure / Security is always a trade-off with usability / Do not assume anything / Trust no-one, nothing / Paranoia is your friend / Think for yourself |
|
Back to top |
|
|
concord Apprentice
Joined: 02 Oct 2005 Posts: 193
|
Posted: Sat Jun 07, 2008 6:23 pm Post subject: |
|
|
Thanks very much for your help. parse dmesg is a good idea. _________________ AMD64 Desktop
Pentium4 Laptop
Pentium3 Server |
|
Back to top |
|
|
|