X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=usertools%2Fcpu_layout.py;h=d3c8eba770b4cd43b82551986fa19c4b262c9781;hb=59c796c889c7b1a001b1e3354750baa2ca9bdba9;hp=57358913484b47263e2b07a76a37ed8592985f05;hpb=deb87e6777c0d1cdf10fdc4e1bcef0000a66d6a8;p=dpdk.git diff --git a/usertools/cpu_layout.py b/usertools/cpu_layout.py index 5735891348..d3c8eba770 100755 --- a/usertools/cpu_layout.py +++ b/usertools/cpu_layout.py @@ -4,7 +4,7 @@ # BSD LICENSE # # Copyright(c) 2010-2014 Intel Corporation. All rights reserved. -# Copyright(c) 2017 Cavium Networks Ltd. All rights reserved. +# Copyright(c) 2017 Cavium, Inc. All rights reserved. # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -35,6 +35,10 @@ # from __future__ import print_function import sys +try: + xrange # Python 2 +except NameError: + xrange = range # Python 3 sockets = [] cores = [] @@ -46,6 +50,8 @@ fd.close() for cpu in xrange(max_cpus + 1): try: fd = open("{}/cpu{}/topology/core_id".format(base_path, cpu)) + except IOError: + continue except: break core = int(fd.read()) @@ -70,7 +76,10 @@ print("sockets = ", sockets) print("") max_processor_len = len(str(len(cores) * len(sockets) * 2 - 1)) -max_core_map_len = max_processor_len * 2 + len('[, ]') + len('Socket ') +max_thread_count = len(list(core_map.values())[0]) +max_core_map_len = (max_processor_len * max_thread_count) \ + + len(", ") * (max_thread_count - 1) \ + + len('[]') + len('Socket ') max_core_id_len = len(str(max(cores))) output = " ".ljust(max_core_id_len + len('Core ')) @@ -87,5 +96,8 @@ print(output) for c in cores: output = "Core %s" % str(c).ljust(max_core_id_len) for s in sockets: - output += " " + str(core_map[(s, c)]).ljust(max_core_map_len) + if (s,c) in core_map: + output += " " + str(core_map[(s, c)]).ljust(max_core_map_len) + else: + output += " " * (max_core_map_len + 1) print(output)