From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [119.145.14.64]) by dpdk.org (Postfix) with ESMTP id 38CDC5932 for ; Wed, 28 May 2014 05:02:40 +0200 (CEST) Received: from 172.24.2.119 (EHLO szxeml205-edg.china.huawei.com) ([172.24.2.119]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id BWB85792; Wed, 28 May 2014 11:02:42 +0800 (CST) Received: from SZXEML452-HUB.china.huawei.com (10.82.67.195) by szxeml205-edg.china.huawei.com (172.24.2.58) with Microsoft SMTP Server (TLS) id 14.3.158.1; Wed, 28 May 2014 11:02:40 +0800 Received: from [127.0.0.1] (10.177.16.142) by szxeml452-hub.china.huawei.com (10.82.67.195) with Microsoft SMTP Server id 14.3.158.1; Wed, 28 May 2014 11:02:37 +0800 Message-ID: <538551CC.3000108@huawei.com> Date: Wed, 28 May 2014 11:02:36 +0800 From: Shannon Zhao User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: Thomas Monjalon References: <53845DC5.3000400@huawei.com> <2531802.9vWkcExQfx@xps13> In-Reply-To: <2531802.9vWkcExQfx@xps13> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.16.142] X-CFilter-Loop: Reflected Cc: dev@dpdk.org Subject: Re: [dpdk-dev] [PATCH] cpu_layout.py: adjust output format to align X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 May 2014 03:02:42 -0000 Hi Thomas, Thanks for your reply. I have checked my patch. It doesn't apply correctly when "core id" is greater than 2 characters. Following is my revised patch. It's based on the maximum length of the "core id" and "processor" to adjust the alignment length. Bug: when "core id" is greater than 9, the cpu_layout.py output doesn't align. Socket 0 Socket 1 --------- --------- Core 9 [4, 16] [10, 22] Core 10 [5, 17] [11, 23] Solution: adjust output format to align Socket 0 Socket 1 --------- --------- Core 9 [4, 16] [10, 22] Core 10 [5, 17] [11, 23] Signed-off-by: Shannon Zhao --- tools/cpu_layout.py | 16 ++++++++++++---- 1 files changed, 12 insertions(+), 4 deletions(-) diff --git a/tools/cpu_layout.py b/tools/cpu_layout.py index 9eff9d7..eeda17e 100755 --- a/tools/cpu_layout.py +++ b/tools/cpu_layout.py @@ -75,15 +75,23 @@ print "cores = ",cores print "sockets = ", sockets print "" +max_processor_len=len(str(len(cores)*len(sockets)*2-1)) +max_core_map_len = max_processor_len*2+4 +if max_core_map_len < 12: + max_core_map_len = 12 +max_core_id_len=len(str(max(cores))) + +print " ".ljust(max_core_id_len+5), for s in sockets: - print "\tSocket %s" % s, + print "Socket %s" % str(s).ljust(max_core_map_len-7), print "" +print " ".ljust(max_core_id_len+5), for s in sockets: - print "\t---------", + print "---------".ljust(max_core_map_len), print "" for c in cores: - print "Core %s" % c, + print "Core %s" % str(c).ljust(max_core_id_len), for s in sockets: - print "\t", core_map[(s,c)], + print str(core_map[(s,c)]).ljust(max_core_map_len), print "\n" -- 1.7.1 On 2014/5/27 18:30, Thomas Monjalon wrote: > Hi, > > Your patch doesn't apply correctly. > Could you check it, please? > > I have also a comment inlined: > > 2014-05-27 17:41, Shannon Zhao: >> - print "\t", core_map[(s,c)], >> + print core_map[(s,c)],"\t", > > Is it possible to fix a minimum alignment of 2 characters? > It could prevent from such alignment problem: > > Core 11 [9, 33] [21, 45] > Core 12 [10, 34] [22, 46] > > Thanks >