stdlib,tests,configs: Create 'SEBinaryWorkload' class
This enables an SE mode execution of binary if added a Board's superclass. This has been abstracted from the SimpleBoard. The 'set_workload' function has been renamed 'set_se_binary_workload'. This is clearer on its purpose and doesn't overlap with other 'set_workload' functions. Change-Id: I714425a3b6b98b91e762ad076eba583bc5953ddd Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/52186 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Bobby R. Bruce <bbruce@ucdavis.edu> Maintainer: Bobby R. Bruce <bbruce@ucdavis.edu>
This commit is contained in:
@@ -79,7 +79,7 @@ board = SimpleBoard(
|
||||
# program compiled to the ARM ISA. The `Resource` class will automatically
|
||||
# download the binary from the gem5 Resources cloud bucket if it's not already
|
||||
# present.
|
||||
board.set_workload(
|
||||
board.set_se_binary_workload(
|
||||
# The `Resource` class reads the `resources.json` file from the gem5
|
||||
# resources repository:
|
||||
# https://gem5.googlesource.com/public/gem5-resource.
|
||||
|
||||
@@ -42,6 +42,8 @@ PySource('gem5.components.boards', 'gem5/components/boards/test_board.py')
|
||||
PySource('gem5.components.boards', 'gem5/components/boards/x86_board.py')
|
||||
PySource('gem5.components.boards',
|
||||
"gem5/components/boards/kernel_disk_workload.py")
|
||||
PySource('gem5.components.boards',
|
||||
"gem5/components/boards/se_binary_workload.py")
|
||||
PySource('gem5.components.cachehierarchies',
|
||||
'gem5/components/cachehierarchies/__init__.py')
|
||||
PySource('gem5.components.cachehierarchies',
|
||||
|
||||
56
src/python/gem5/components/boards/se_binary_workload.py
Normal file
56
src/python/gem5/components/boards/se_binary_workload.py
Normal file
@@ -0,0 +1,56 @@
|
||||
# Copyright (c) 2021 The Regents of the University of California
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are
|
||||
# met: redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer;
|
||||
# redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution;
|
||||
# neither the name of the copyright holders nor the names of its
|
||||
# contributors may be used to endorse or promote products derived from
|
||||
# this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
from ...resources.resource import AbstractResource
|
||||
|
||||
from m5.objects import SEWorkload, Process
|
||||
|
||||
class SEBinaryWorkload:
|
||||
"""
|
||||
This class is used to enable simple Syscall-Execution (SE) mode execution
|
||||
of a binary.
|
||||
|
||||
For this to function correctly the SEBinaryWorkload class should be added
|
||||
as a superclass to a board (i.e., something that inherits from
|
||||
AbstractBoard).
|
||||
"""
|
||||
|
||||
def set_se_binary_workload(self, binary: AbstractResource) -> None:
|
||||
"""Set up the system to run a specific binary.
|
||||
|
||||
**Limitations**
|
||||
* Only supports single threaded applications
|
||||
* Dynamically linked executables are partially supported when the host
|
||||
ISA and the simulated ISA are the same.
|
||||
|
||||
:param binary: The resource encapsulating the binary to be run.
|
||||
"""
|
||||
|
||||
self.workload = SEWorkload.init_compatible(binary.get_local_path())
|
||||
|
||||
process = Process()
|
||||
process.cmd = [binary.get_local_path()]
|
||||
self.get_processor().get_cores()[0].set_workload(process)
|
||||
@@ -24,19 +24,17 @@
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
from ...resources.resource import AbstractResource
|
||||
from m5.objects import (
|
||||
AddrRange,
|
||||
SrcClockDomain,
|
||||
VoltageDomain,
|
||||
Process,
|
||||
SEWorkload,
|
||||
IOXBar,
|
||||
Port,
|
||||
ClockDomain,
|
||||
)
|
||||
|
||||
from .abstract_board import AbstractBoard
|
||||
from .se_binary_workload import SEBinaryWorkload
|
||||
from ..processors.abstract_processor import AbstractProcessor
|
||||
from ..memory.abstract_memory_system import AbstractMemorySystem
|
||||
from ..cachehierarchies.abstract_cache_hierarchy import AbstractCacheHierarchy
|
||||
@@ -45,7 +43,7 @@ from ...utils.override import overrides
|
||||
from typing import List
|
||||
|
||||
|
||||
class SimpleBoard(AbstractBoard):
|
||||
class SimpleBoard(AbstractBoard, SEBinaryWorkload):
|
||||
"""
|
||||
This is an incredibly simple system. It contains no I/O, and will work only
|
||||
with a classic cache hierarchy setup.
|
||||
@@ -53,7 +51,7 @@ class SimpleBoard(AbstractBoard):
|
||||
**Limitations**
|
||||
* Only supports SE mode
|
||||
|
||||
You can run a binary executable via the `set_workload` function.
|
||||
You can run a binary executable via the `set_se_binary_workload` function.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
@@ -117,21 +115,4 @@ class SimpleBoard(AbstractBoard):
|
||||
# The simple board just has one memory range that is the size of the
|
||||
# memory.
|
||||
self.mem_ranges = [AddrRange(memory.get_size())]
|
||||
memory.set_memory_range(self.mem_ranges)
|
||||
|
||||
def set_workload(self, binary: AbstractResource) -> None:
|
||||
"""Set up the system to run a specific binary.
|
||||
|
||||
**Limitations**
|
||||
* Only supports single threaded applications
|
||||
* Dynamically linked executables are partially supported when the host
|
||||
ISA and the simulated ISA are the same.
|
||||
|
||||
:param binary: The resource encapsulating the binary to be run.
|
||||
"""
|
||||
|
||||
self.workload = SEWorkload.init_compatible(binary.get_local_path())
|
||||
|
||||
process = Process()
|
||||
process.cmd = [binary.get_local_path()]
|
||||
self.get_processor().get_cores()[0].set_workload(process)
|
||||
memory.set_memory_range(self.mem_ranges)
|
||||
@@ -96,7 +96,7 @@ motherboard = SimpleBoard(
|
||||
# Set the workload
|
||||
binary = Resource(args.resource,
|
||||
resource_directory=args.resource_directory)
|
||||
motherboard.set_workload(binary)
|
||||
motherboard.set_se_binary_workload(binary)
|
||||
|
||||
root = Root(full_system=False, system=motherboard)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user