Updated display format of cpu & socket affinities
Signed-off-by: Deepak Mewar <deepak.mewar@amd.com>
Este cometimento está contido em:
cometido por
Arif, Maisam
ascendente
6fbda16098
cometimento
7571eb014f
@@ -828,22 +828,32 @@ class AMDSMICommands():
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
cpu_set = amdsmi_interface.amdsmi_get_cpu_affinity_with_scope(args.gpu, amdsmi_interface.AmdSmiAffinityScope.NUMA_SCOPE)
|
cpu_set = amdsmi_interface.amdsmi_get_cpu_affinity_with_scope(args.gpu, amdsmi_interface.AmdSmiAffinityScope.NUMA_SCOPE)
|
||||||
|
cpu_set = [f"{cpus:016X}" for cpus in cpu_set]
|
||||||
|
cpu_set = {f'cpu_list_{i}': f"{cpus}" for i, cpus in enumerate(cpu_set)}
|
||||||
|
bitmask_ranges = self.helpers.get_bitmask_ranges(cpu_set)
|
||||||
|
cpu_affinity = {}
|
||||||
|
|
||||||
|
for key in cpu_set:
|
||||||
|
cpu_affinity[key] = {
|
||||||
|
"bitmask": cpu_set[key],
|
||||||
|
"cpu_cores_affinity" : bitmask_ranges[key]
|
||||||
|
}
|
||||||
|
|
||||||
except amdsmi_exception.AmdSmiLibraryException as e:
|
except amdsmi_exception.AmdSmiLibraryException as e:
|
||||||
cpu_set = []
|
cpu_affinity = "N/A"
|
||||||
cpu_set.append(-1)
|
|
||||||
logging.debug("Failed to get cpu affinity for gpu %s | %s", gpu_id, e.get_error_info())
|
logging.debug("Failed to get cpu affinity for gpu %s | %s", gpu_id, e.get_error_info())
|
||||||
|
|
||||||
try:
|
try:
|
||||||
cpusockets = amdsmi_interface.amdsmi_get_cpu_affinity_with_scope(args.gpu, amdsmi_interface.AmdSmiAffinityScope.SOCKET_SCOPE)
|
cpusockets = amdsmi_interface.amdsmi_get_cpu_affinity_with_scope(args.gpu, amdsmi_interface.AmdSmiAffinityScope.SOCKET_SCOPE)
|
||||||
|
cpusockets = {f'socket_{i}': socket for i, socket in enumerate(set(cpusockets))}
|
||||||
except amdsmi_exception.AmdSmiLibraryException as e:
|
except amdsmi_exception.AmdSmiLibraryException as e:
|
||||||
cpusockets = []
|
cpusockets = {}
|
||||||
cpusockets.append(-1)
|
|
||||||
logging.debug("Failed to get socket affinity for gpu %s | %s", gpu_id, e.get_error_info())
|
logging.debug("Failed to get socket affinity for gpu %s | %s", gpu_id, e.get_error_info())
|
||||||
|
|
||||||
static_dict['numa'] = {'node' : numa_node_number,
|
static_dict['numa'] = { 'node' : numa_node_number,
|
||||||
'affinity' : numa_affinity,
|
'affinity' : numa_affinity,
|
||||||
'CPU affinity' : [hex(cpus) for cpus in cpu_set],
|
'cpu_affinity' : cpu_affinity,
|
||||||
'Socket affinity' : [socket for socket in set(cpusockets)]}
|
'socket_affinity' : cpusockets if cpusockets else "N/A"}
|
||||||
if args.vram:
|
if args.vram:
|
||||||
vram_info_dict = {"type" : "N/A",
|
vram_info_dict = {"type" : "N/A",
|
||||||
"vendor" : "N/A",
|
"vendor" : "N/A",
|
||||||
|
|||||||
@@ -1396,3 +1396,36 @@ class AMDSMIHelpers():
|
|||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
self.display_cper_files_generated(entries, device_handle, args.folder)
|
self.display_cper_files_generated(entries, device_handle, args.folder)
|
||||||
|
|
||||||
|
def get_bitmask_ranges(self, bitmask_dict):
|
||||||
|
ranges = {}
|
||||||
|
#start index of the first bitmask
|
||||||
|
current_start = 0
|
||||||
|
|
||||||
|
for cpu, bitmask in bitmask_dict.items():
|
||||||
|
# Convert the bitmask to a binary string
|
||||||
|
binary_str = bin(int(bitmask, 16))[2:].zfill(64)
|
||||||
|
|
||||||
|
binary_str = binary_str[::-1]
|
||||||
|
start = 0
|
||||||
|
end = len(binary_str) - 1
|
||||||
|
# Find the range of set bits
|
||||||
|
start_b = binary_str.find('1')
|
||||||
|
end_b = binary_str.rfind('1')
|
||||||
|
|
||||||
|
start_setbit = start_b + current_start
|
||||||
|
end_setbit = end_b + current_start
|
||||||
|
|
||||||
|
# Calculate the actual bit positions
|
||||||
|
end_bit = current_start + end
|
||||||
|
|
||||||
|
# Update the start index for the next bitmask
|
||||||
|
current_start = end_bit + 1
|
||||||
|
|
||||||
|
# Store the range in the dictionary
|
||||||
|
if start_b == -1 and end_b == -1:
|
||||||
|
ranges[cpu] = "N/A"
|
||||||
|
else:
|
||||||
|
ranges[cpu] = f"{start_setbit}-{end_setbit}"
|
||||||
|
|
||||||
|
return ranges
|
||||||
|
|||||||
Criar uma nova questão referindo esta
Bloquear um utilizador