stdlib: Allow set_se_binary_workload to take input parameters
This commit added two paramaters in the set_se_binary_workload to pass input parameters for the binary. The "arguments" object allows users to pass in arugments in a list. The "stdin_file" object allows users to pass in input file as a Resource. This commit also created a local variable "binary_path" to save the return object of "binary.get_local_path()". Note: These new parameters were tested and passed in 4 cases: 1. only passing in (Resource/CustomResource) binary 2. passing in (CustomResource) binary and input_file 3. passing in (CustomResource) binary and argument(no input file directory included) 4. passing in (CustomResource) binary and argument(with input file directory included) Jira Issue: https://gem5.atlassian.net/browse/GEM5-1242 Change-Id: I6433a349f7ecb5d630c7cdbe7268ff18915bf23f Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/61609 Reviewed-by: Jason Lowe-Power <power.jg@gmail.com> Tested-by: kokoro <noreply+kokoro@google.com> Maintainer: Jason Lowe-Power <power.jg@gmail.com> Reviewed-by: Bobby Bruce <bbruce@ucdavis.edu>
This commit is contained in:
@@ -29,6 +29,8 @@ from ...resources.resource import AbstractResource
|
||||
|
||||
from m5.objects import SEWorkload, Process
|
||||
|
||||
from typing import Optional, List
|
||||
|
||||
class SEBinaryWorkload:
|
||||
"""
|
||||
This class is used to enable simple Syscall-Execution (SE) mode execution
|
||||
@@ -42,7 +44,9 @@ class SEBinaryWorkload:
|
||||
def set_se_binary_workload(
|
||||
self,
|
||||
binary: AbstractResource,
|
||||
exit_on_work_items: bool = True
|
||||
exit_on_work_items: bool = True,
|
||||
stdin_file: Optional[AbstractResource] = None,
|
||||
arguments: List[str] = [],
|
||||
) -> None:
|
||||
"""Set up the system to run a specific binary.
|
||||
|
||||
@@ -54,6 +58,8 @@ class SEBinaryWorkload:
|
||||
:param binary: The resource encapsulating the binary to be run.
|
||||
:param exit_on_work_items: Whether the simulation should exit on work
|
||||
items. True by default.
|
||||
:param stdin_file: The input file for the binary
|
||||
:param arguments: The input arguments for the binary
|
||||
"""
|
||||
|
||||
# We assume this this is in a multiple-inheritance setup with an
|
||||
@@ -64,10 +70,15 @@ class SEBinaryWorkload:
|
||||
# SE-mode simulation.
|
||||
self._set_fullsystem(False)
|
||||
|
||||
self.workload = SEWorkload.init_compatible(binary.get_local_path())
|
||||
binary_path = binary.get_local_path()
|
||||
self.workload = SEWorkload.init_compatible(binary_path)
|
||||
|
||||
process = Process()
|
||||
process.cmd = [binary.get_local_path()]
|
||||
process.executable = binary_path
|
||||
process.cmd = [binary_path] + arguments
|
||||
if stdin_file is not None:
|
||||
process.input = stdin_file.get_local_path()
|
||||
|
||||
self.get_processor().get_cores()[0].set_workload(process)
|
||||
|
||||
# Set whether to exit on work items for the se_workload
|
||||
|
||||
Reference in New Issue
Block a user