[SWDEV-493274/SWDEV-514998] Add AMD SMI partition tests + Add Guest amd-smi static --partition (#127)

* [SWDEV-493274/SWDEV-514998] Add AMD SMI partition tests + Add Guest amd-smi static --partition

Changes:
    - Added amd-smi static --partition for guest systems
    - Added C++ tests for memory and compute (accelerator) partitions
    - Added Python tests for amdsmi_get_gpu_vram_info(),
       amdsmi_get_gpu_accelerator_partition_profile_config()
    - Updated Python tests for
      amdsmi_get_gpu_accelerator_partition_profile()
      Now includes more profile and resource detail
    - Added amdsmi_get_gpu_xcd_counter();
      Tests provided for both C++/Python APIs
    - Added AmdSmiVramType & AmdSmiVramVendor: they were missing
      python testing required adding.

Change-Id: Ib6549d8ccc5fb68726f38745b87c78f890186022
Signed-off-by: Charis Poag <Charis.Poag@amd.com>
This commit is contained in:
Poag, Charis
2025-03-11 16:38:46 -05:00
کامیت شده توسط GitHub
والد d9fee767c3
کامیت 48cb5529d2
30فایلهای تغییر یافته به همراه3505 افزوده شده و 399 حذف شده
+11 -11
مشاهده پرونده
@@ -387,6 +387,8 @@ class AMDSMICommands():
args.cache = cache
if process_isolation:
args.process_isolation = process_isolation
if partition:
args.partition = partition
if clock:
args.clock = clock
# args.clock defaults to False so if it was overwritten to empty list, that indicates that it was given as an arguments but with an empty list
@@ -396,24 +398,22 @@ class AMDSMICommands():
# Store args that are applicable to the current platform
current_platform_args = ["asic", "bus", "vbios", "driver", "ras",
"vram", "cache", "board", "process_isolation",
"clock"]
"clock", "partition"]
current_platform_values = [args.asic, args.bus, args.vbios, args.driver, args.ras,
args.vram, args.cache, args.board, args.process_isolation,
args.clock]
args.clock, args.partition]
self.helpers.check_required_groups()
if self.helpers.is_linux() and self.helpers.is_baremetal():
if partition:
args.partition = partition
if limit:
args.limit = limit
if soc_pstate:
args.soc_pstate = soc_pstate
if xgmi_plpd:
args.xgmi_plpd = xgmi_plpd
current_platform_args += ["ras", "limit", "partition", "soc_pstate", "xgmi_plpd"]
current_platform_values += [args.ras, args.limit, args.partition, args.soc_pstate, args.xgmi_plpd]
current_platform_args += ["ras", "limit", "soc_pstate", "xgmi_plpd"]
current_platform_values += [args.ras, args.limit, args.soc_pstate, args.xgmi_plpd]
if self.helpers.is_linux() and not self.helpers.is_virtual_os():
if numa:
@@ -4240,7 +4240,7 @@ class AMDSMICommands():
if args.compute_partition in accelerator_profiles['profile_types']:
compute_partition = amdsmi_interface.AmdSmiComputePartitionType[args.compute_partition]
index = accelerator_profiles['profile_types'].index(args.compute_partition)
attempted_to_set = f"Attempted to set accelerator partition to {args.compute_partition} (profile #{accelerator_profiles['profile_indices'][int(index)]} on {gpu_string}"
attempted_to_set = f"Attempted to set accelerator partition to {args.compute_partition} (profile #{accelerator_profiles['profile_indices'][int(index)]}) on {gpu_string}"
amdsmi_interface.amdsmi_set_gpu_compute_partition(args.gpu, compute_partition)
self.logger.store_output(args.gpu, 'accelerator_partition', f"Successfully set accelerator partition to {args.compute_partition} (profile #{accelerator_profiles['profile_indices'][int(index)]})")
elif args.compute_partition in accelerator_profiles['profile_indices']:
@@ -4294,7 +4294,7 @@ class AMDSMICommands():
threads = []
k140secs = 140
string_out = f"Updating memory partition for gpu {gpu_id}"
string_out = f"Updating memory partition for GPU: {gpu_id}"
timesToRetryRestartErr = 1
self.helpers.increment_set_count()
@@ -4305,9 +4305,9 @@ class AMDSMICommands():
while timesToRetryRestartErr >= 0:
timesToRetryRestartErr -= 1
try:
if showProgressBar: # only show reload warning on 1st set
if showProgressBar: # we want to overwrite the previous progress bar
t1 = multiprocessing.Process(target=self.helpers.showProgressbar,
args=(string_out, k140secs,))
args=(string_out, k140secs, True,))
threads.append(t1)
t1.start()
memory_partition = amdsmi_interface.AmdSmiMemoryPartitionType[args.memory_partition]
@@ -4342,7 +4342,7 @@ class AMDSMICommands():
return
if e.get_error_code() == amdsmi_interface.amdsmi_wrapper.AMDSMI_STATUS_AMDGPU_RESTART_ERR:
# Try again on a failure -> work around for not being able to close libdrm
string_out = f"Trying again - Updating memory partition for gpu {gpu_id}"
string_out = f"Trying again - Updating memory partition for GPU: {gpu_id} "
for thread in threads:
thread.terminate()
thread.join()
+9 -5
مشاهده پرونده
@@ -969,11 +969,15 @@ class AMDSMIHelpers():
continue
return pci_devices
def progressbar(self, it, prefix="", size=60, out=sys.stdout):
def progressbar(self, it, prefix="", size=60, out=sys.stdout, add_newline=False):
count = len(it)
if (add_newline):
print("{}\n".format(prefix),end='\r', file=out, flush=False)
else:
print("{}".format(prefix),end='\r', file=out, flush=False)
def show(j):
x = int(size*j/count)
print("{}[{}{}] {}/{} secs remain".format(prefix, u""*x, "."*(size-x), j, count),
print("[{}{}] {}/{} secs remain".format(u""*x, "."*(size-x), j, count),
end='\r', file=out, flush=True)
show(0)
for i, item in enumerate(it):
@@ -981,10 +985,10 @@ class AMDSMIHelpers():
show(i+1)
print("\n\n", end='\r', flush=True, file=out)
def showProgressbar(self, title="", timeInSeconds=13):
def showProgressbar(self, title="", timeInSeconds=13, add_newline=False):
if title != "":
title += ": "
for i in self.progressbar(range(timeInSeconds), title, 40):
title += " "
for i in self.progressbar(range(timeInSeconds), title, 40, add_newline=add_newline):
time.sleep(1)
def check_required_groups(self):
+1 -1
مشاهده پرونده
@@ -695,10 +695,10 @@ class AMDSMIParser(argparse.ArgumentParser):
static_parser.add_argument('-R', '--process-isolation', action='store_true', required=False, help=process_isolation_help)
static_parser.add_argument('-r', '--ras', action='store_true', required=False, help=ras_help)
static_parser.add_argument('-C', '--clock', action='store', default=False, nargs='*', type=str, required=False, help=clock_help)
static_parser.add_argument('-p', '--partition', action='store_true', required=False, help=partition_help)
# Options to display on Hypervisors and Baremetal
if self.helpers.is_hypervisor() or self.helpers.is_baremetal():
static_parser.add_argument('-p', '--partition', action='store_true', required=False, help=partition_help)
static_parser.add_argument('-l', '--limit', action='store_true', required=False, help=limit_help)
static_parser.add_argument('-P', '--soc-pstate', action='store_true', required=False, help=soc_pstate_help)
static_parser.add_argument('-x', '--xgmi-plpd', action='store_true', required=False, help=xgmi_plpd_help)