stdlib: Add warning message for set_workload being called twice (#1571)
This commit adds a warning message for when set_workload is called twice, as users typically do not mean to do this.
This commit is contained in:
committed by
GitHub
parent
c10feed524
commit
d5dfe03eb1
@@ -110,6 +110,7 @@ class AbstractBoard:
|
||||
# is defined. Whether or not the board is to be run in FS mode is
|
||||
# determined by which kind of workload is set.
|
||||
self._is_fs = None
|
||||
self._is_workload_set = False
|
||||
|
||||
# This variable is used to record the checkpoint directory which is
|
||||
# set when declaring the board's workload and then used by the
|
||||
@@ -211,6 +212,12 @@ class AbstractBoard:
|
||||
)
|
||||
return self._is_fs
|
||||
|
||||
def set_is_workload_set(self, is_set: bool) -> None:
|
||||
self._is_workload_set = is_set
|
||||
|
||||
def is_workload_set(self) -> bool:
|
||||
return self._is_workload_set
|
||||
|
||||
def set_workload(self, workload: WorkloadResource) -> None:
|
||||
"""
|
||||
Set the workload for this board to run.
|
||||
|
||||
@@ -34,6 +34,7 @@ from typing import (
|
||||
)
|
||||
|
||||
import m5
|
||||
from m5.util import warn
|
||||
|
||||
from ...resources.resource import (
|
||||
BootloaderResource,
|
||||
@@ -180,6 +181,10 @@ class KernelDiskWorkload:
|
||||
# Abstract board. This function will not work otherwise.
|
||||
assert isinstance(self, AbstractBoard)
|
||||
|
||||
if self.is_workload_set():
|
||||
warn("Workload has been set more than once!")
|
||||
self.set_is_workload_set(True)
|
||||
|
||||
# Set the disk device
|
||||
self._disk_device = disk_device
|
||||
|
||||
|
||||
@@ -101,6 +101,10 @@ class SEBinaryWorkload:
|
||||
# Abstract board. This function will not work otherwise.
|
||||
assert isinstance(self, AbstractBoard)
|
||||
|
||||
if self.is_workload_set():
|
||||
warn("Workload has been set more than once!")
|
||||
self.set_is_workload_set(True)
|
||||
|
||||
# If we are setting a workload of this type, we need to run as a
|
||||
# SE-mode simulation.
|
||||
self._set_fullsystem(False)
|
||||
|
||||
Reference in New Issue
Block a user