-
Notifications
You must be signed in to change notification settings - Fork 0
/
__init__.py
85 lines (69 loc) · 3.12 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# ----------------------------------------------------------------------------
# File: <__init__>.py
#
# Description:
# <gEMA init>.
#
# Contact:
# For inquiries, please contact Alex Manley ([email protected]).
#
# License:
# This project is licensed under the MIT License. See the LICENSE file
# in the repository root for more information.
# ----------------------------------------------------------------------------
"""gem5 External Modules API (gEMA)
This module provides the main interface for managing gem5 simulations through a
remote API. It coordinates configuration generation, option discovery,
simulation management, and remote procedure calls through a unified interface.
"""
__version__ = "1.0"
__all__ = ["Gema"]
from gem5.utils.gema.config import GemaConfigGenerator
from gem5.utils.gema.manager import GemaSimulationManager
from gem5.utils.gema.options import GemaOptionRetreiver
from gem5.utils.gema.rpc import GemaServer
class Gema:
"""Main application class for the gem5 External Modules API (gEMA).
This class serves as the central coordinator for all gEMA functionality,
integrating configuration management, option discovery, simulation control,
and RPC services. It provides a unified interface for managing gem5
simulations through its component classes.
Attributes:
configurator (GemaConfigGenerator): Handles creation and management of
simulation configurations.
retriever (GemaOptionRetreiver): Dynamically fetches available simulation options.
manager (GemaSimulationManager): Controls simulation execution and
lifecycle management.
server (GemaServer): Provides RPC interface for remote control and
monitoring.
sims (list): Maintains list of active simulation instances.
Note:
The Gema class follows a composition pattern, delegating specific
functionality to specialized component classes while maintaining
centralized coordination.
"""
def __init__(self, port: int):
"""Initialize a new gEMA instance.
Creates and initializes all component managers and controllers needed
for gem5 simulation management. Sets up the RPC server for remote
access on the specified port.
Args:
port (int): Network port number for the RPC server. This port
must be available for the server to start successfully.
"""
self.configurator = GemaConfigGenerator(self)
self.retriever = GemaOptionRetreiver(self)
self.manager = GemaSimulationManager(self)
self.server = GemaServer(self, port)
self.sims = []
def run(self):
"""Start the gEMA instance and begin serving requests.
This method initiates the RPC server and begins processing client
requests. It runs indefinitely until interrupted or explicitly
stopped.
Note:
This is a blocking call - the method will not return until the
server is shut down. The server can be interrupted with Ctrl+C
or by sending a termination signal to the process.
"""
self.server.run()