From bec9ae77e6c77edb1853c9943f274bcf6eb4402f Mon Sep 17 00:00:00 2001 From: Jason Lowe-Power Date: Thu, 31 Oct 2024 16:15:26 -0700 Subject: [PATCH] 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 --- src/python/gem5/prebuilt/viper/board.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/python/gem5/prebuilt/viper/board.py b/src/python/gem5/prebuilt/viper/board.py index a7958016ac..bb13e92ed1 100644 --- a/src/python/gem5/prebuilt/viper/board.py +++ b/src/python/gem5/prebuilt/viper/board.py @@ -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.