stdlib: Override the readfile contents in GPU board

This prepends loading the GPU drivers to anything passed in via the
readfile_contents. Note that if the user sets a specific readfile via a
file they will be responsible for loading the driver

Signed-off-by: Jason Lowe-Power <jason@lowepower.com>
This commit is contained in:
Jason Lowe-Power
2024-10-31 16:15:26 -07:00
committed by Bobby R. Bruce
parent 2fca39cec7
commit bec9ae77e6

View File

@@ -149,6 +149,23 @@ class ViperBoard(X86Board):
"modprobe.blacklist=psmouse",
]
@overrides(KernelDiskWorkload)
def _set_readfile_contents(self, readfile_contents):
"""In the case of a GPU workload, we need to load the GPU driver first.
This method will prepend the driver load command to the
readfile_contents. Note that this assumes that all of the gpus are the
same, if there's more that one GPU.
"""
if self.get_devices() is None:
warn("No GPU devices. Not loading GPU driver.")
return super()._set_readfile_contents(readfile_contents)
driver_load_command = self.get_devices()[0].get_driver_command()
contents = driver_load_command + "\n" + readfile_contents
return super()._set_readfile_contents(contents)
# Replicate the capability of the old GPUFS config, which embed a binary
# application or script into a bash script setting up the environment and
# loading the GPU driver.