From: Gautham R Shenoy <ego@in.ibm.com>
To: Poornima Nayak <mpnayak@linux.vnet.ibm.com>
Cc: ltp-list@lists.sourceforge.net, svaidy@linux.vnet.ibm.com,
arun@linux.vnet.ibm.com
Subject: Re: [LTP] [Patch 3/4]Python functions modified to run on Power platform
Date: Mon, 11 Jan 2010 10:20:31 +0530 [thread overview]
Message-ID: <20100111045031.GB1428@in.ibm.com> (raw)
In-Reply-To: <20091224181551.12571.4910.sendpatchset@localhost.localdomain>
On Thu, Dec 24, 2009 at 11:45:51PM +0530, Poornima Nayak wrote:
> +def get_hyper_thread_count():
> + ''' Return number of threads in cpu0
> + '''
> + try:
> + file_cpuinfo = open("/sys/devices/system/cpu/cpu0/topology/thread_siblings", 'r')
> + threads_count = 0
> + for line in file_cpuinfo:
> + core_grps = line.split(",")
> + for i in range(0, len(core_grps)):
> + cpumask=int(core_grps[i])
> + while cpumask > 0:
> + threads_count = threads_count + 1
> + cpumask = cpumask >> 1
> + return threads_count
> + except Exception, details:
> + print "INFO: Failed to get threaded siblings count", details
> + sys.exit(1)
> +
> +def get_core_sibling_count():
> + ''' Return number of threads in cpu0
> + '''
> + try:
> + file_cpuinfo = open("/sys/devices/system/cpu/cpu0/topology/core_siblings", 'r')
> + cores_count = 0
> + for line in file_cpuinfo:
> + core_grps = line.split(",")
> + for i in range(0, len(core_grps)):
> + cpumask=int(core_grps[i])
> + while cpumask > 0:
> + cores_count = cores_count + 1
> + cpumask = cpumask >> 1
> + return cores_count
> + except Exception, details:
> + print "INFO: Failed to get core siblings count", details
> + sys.exit(1)
> +
We could avoid the code repetition above.
def get_entity_count(entity):
try:
file_cpuinfo =
open("/sys/devices/system/cpu/cpu0/topology/" + entity + "siblings", 'r)
.
.
.
except
.
.
.
def get_hyper_thread_count():
return get_entity_count("thread")
def get_core_sibling_count():
return get_entity_count("core")
--
Thanks and Regards
gautham
------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
next prev parent reply other threads:[~2010-01-11 4:50 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-24 18:15 [LTP] [Patch 1/4]Master script modified to enable testcases to run on Power Poornima Nayak
2009-12-24 18:15 ` [LTP] [Patch 2/4]Reusable functions modified to learn topology from sysfs Poornima Nayak
2009-12-24 20:11 ` Garrett Cooper
2010-01-11 4:25 ` Gautham R Shenoy
2009-12-24 18:15 ` [LTP] [Patch 3/4]Python functions modified to run on Power platform Poornima Nayak
2009-12-24 20:37 ` Garrett Cooper
2010-01-11 4:50 ` Gautham R Shenoy [this message]
2009-12-24 18:16 ` [LTP] [Patch 4/4]Readme modified based on review comments Poornima Nayak
2009-12-24 20:04 ` Garrett Cooper
2009-12-24 20:21 ` [LTP] [Patch 1/4]Master script modified to enable testcases to run on Power Garrett Cooper
2010-01-08 7:20 ` Poornima Nayak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100111045031.GB1428@in.ibm.com \
--to=ego@in.ibm.com \
--cc=arun@linux.vnet.ibm.com \
--cc=ltp-list@lists.sourceforge.net \
--cc=mpnayak@linux.vnet.ibm.com \
--cc=svaidy@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox