From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?iso-8859-1?B?Tm9yZGz2dw==?= Newsgroups: gmane.emacs.help Subject: Re: Getting Number of CPU(-core)s and giving it as the --jobs argument to GNU Make Date: Wed, 12 Sep 2007 01:20:52 -0700 Organization: http://groups.google.com Message-ID: <1189585252.489781.93740@22g2000hsm.googlegroups.com> References: <1189522398.029390.27390@50g2000hsm.googlegroups.com> <7C10B24D-B158-4C58-97DE-82441E1358AE@Web.DE> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Trace: sea.gmane.org 1189586484 10212 80.91.229.12 (12 Sep 2007 08:41:24 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 12 Sep 2007 08:41:24 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Sep 12 10:41:22 2007 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IVNmU-0004tY-Pw for geh-help-gnu-emacs@m.gmane.org; Wed, 12 Sep 2007 10:41:07 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IVNmT-0005mM-VA for geh-help-gnu-emacs@m.gmane.org; Wed, 12 Sep 2007 04:41:05 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews.google.com!22g2000hsm.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 58 Original-NNTP-Posting-Host: 150.227.15.253 Original-X-Trace: posting.google.com 1189585252 10115 127.0.0.1 (12 Sep 2007 08:20:52 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Wed, 12 Sep 2007 08:20:52 +0000 (UTC) In-Reply-To: User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.6) Gecko/20061201 Firefox/2.0.0.6 (Ubuntu-feisty),gzip(gfe),gzip(gfe) X-HTTP-Via: 1.1 netcache (NetCache NetApp/6.1.1RC1) Complaints-To: groups-abuse@google.com Injection-Info: 22g2000hsm.googlegroups.com; posting-host=150.227.15.253; posting-account=ps2QrAMAAAA6_jCuRt2JEIpn5Otqf_w0 Original-Xref: shelby.stanford.edu gnu.emacs.help:152012 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:47522 Archived-At: On 12 Sep, 08:30, Michael Trausch <"mike|s/\\x40/\\./g;s/|.*|/\\x40/g;| trausch"@us> wrote: > Dieter Wilhelm, on 09/11/2007 04:20 PM said: > > > > > That's a bit confusing, I thought I had *one* processor with *two* > > cores and the content in /proc/cpuinfo claims two processor, 0 and 1 > > with two cores, respectively, where am I wrong? > > That's the way it shows up - it's a dual core processor, and the > information is the same for them except for the core number. If you had > two dual core CPUs in your system, you would see four entires in > /proc/cpuinfo. This is normal, because a dual core system (mostly) > performs just as a dual processor system would. It's more or less like > having two CPUs. > > In fact, many utilities and programming languages will even say that you > have two CPUs when you really only have one dual-core CPU. > > That having been said, the only cross-platform method I know of for > finding the number of cores (processors) on a system would be in > .NET/Mono, since that works whereever there is an implmementation of > .NET. Other than that, the only way that I know is to look in the > /proc/cpuinfo file on Linux. In C on Linux and Mac OS X the following detects number of CPUs: #include #ifdef __APPLE__ #include #endif /*** * Detect the number of CPUs/Processors/Cores Online. * @return number of CPUs found. */ static inline int get_CPUmult(void) { int num =3D 1; /* default to one CPU */ #if defined(__APPLE__) size_t len =3D sizeof(num); int mib[2]; mib[0] =3D CTL_HW; mib[1] =3D HW_NCPU; if (sysctl(mib, 2, &num, &len, 0, 0) < 0 || len !=3D sizeof(num)) { num =3D 1; } #elif defined(_SC_NPROCESSORS_ONLN) num =3D sysconf(_SC_NPROCESSORS_ONLN); #endif return num; } /Nordl=F6w