gem5  [DEVELOP-FOR-23.0]
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
fastmodel.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 ARM Limited
3  * All rights reserved
4  *
5  * The license below extends only to copyright in the software and shall
6  * not be construed as granting a license to any other intellectual
7  * property including but not limited to intellectual property relating
8  * to a hardware implementation of the functionality of the software
9  * licensed hereunder. You may use the software subject to the license
10  * terms below provided that you ensure that this notice is replicated
11  * unmodified and in its entirety in all distributions of the software,
12  * modified or unmodified, in source code or in binary form.
13  *
14  * Copyright 2019 Google, Inc.
15  *
16  * Redistribution and use in source and binary forms, with or without
17  * modification, are permitted provided that the following conditions are
18  * met: redistributions of source code must retain the above copyright
19  * notice, this list of conditions and the following disclaimer;
20  * redistributions in binary form must reproduce the above copyright
21  * notice, this list of conditions and the following disclaimer in the
22  * documentation and/or other materials provided with the distribution;
23  * neither the name of the copyright holders nor the names of its
24  * contributors may be used to endorse or promote products derived from
25  * this software without specific prior written permission.
26  *
27  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38  */
39 
40 #include "base/logging.hh"
42 #include "scx/scx.h"
43 #include "sim/init.hh"
44 #include "systemc/utils/report.hh"
45 
46 namespace gem5
47 {
48 
49 namespace
50 {
51 
52 void
53 fastmodel_sc_report_handler(
54  const sc_core::sc_report &report, const sc_core::sc_actions &actions)
55 {
56  const char *msg = report.get_msg();
57  if (!msg)
58  return;
59 
60  panic_if(
61  strstr(msg, "Simulation code-translation cache failed to gain DMI") ||
62  strstr(msg, "I-side given unusable DMI"),
63  "DMI warning from fastmodel, "
64  "aborting simulation instead of running slowly.");
65 }
66 
67 void
68 arm_fast_model_pybind(pybind11::module_ &m_internal)
69 {
70  auto arm_fast_model = m_internal.def_submodule("arm_fast_model");
71  arm_fast_model
72  .def("scx_initialize", [](std::string id) {
73  scx::scx_initialize(id);
74  })
75 
76  // Loading of applications or raw data.
77  .def("scx_load_application", &scx::scx_load_application)
78  .def("scx_load_application_all", &scx::scx_load_application_all)
79  .def("scx_load_data", &scx::scx_load_data)
80  .def("scx_load_data_all", &scx::scx_load_data_all)
81 
82  // Only expose the string based versions of these functions. Exposing
83  // specializations of the templated versions is likely overkill,
84  // especially since there are other preferred methods for setting up
85  // the parameters of a component.
86  .def("scx_set_parameter",
87  static_cast<bool (*)(const std::string &, const std::string &)>(
88  &scx::scx_set_parameter))
89  .def("scx_get_parameter",
90  static_cast<bool (*)(const std::string &, std::string &)>(
91  &scx::scx_get_parameter))
92  .def("scx_get_parameter_list", &scx::scx_get_parameter_list)
93 
94  .def("scx_set_cpi_file", &scx::scx_set_cpi_file)
95 
96  // These might be used internally by the gem5 fast model wrapper, and
97  // may not be worth exposing.
98  .def("scx_cpulimit", &scx::scx_cpulimit)
99  .def("scx_timelimit", &scx::scx_timelimit)
100  .def("scx_simlimit", &scx::scx_simlimit)
101 
102  .def("scx_parse_and_configure",
103  [](int argc, std::vector<char *> argv,
104  const char *trailer=NULL, bool sig_handler=true) {
105  scx::scx_parse_and_configure(argc, argv.data(),
106  trailer, sig_handler);
107  },
108  pybind11::arg("argc"),
109  pybind11::arg("argv"),
110  pybind11::arg("trailer") = NULL,
111  pybind11::arg("sig_handler") = true)
112 
113  // CADI stuff.
114  .def("scx_start_cadi_server", &scx::scx_start_cadi_server,
115  pybind11::arg("start") = true,
116  pybind11::arg("run") = true,
117  pybind11::arg("debug") = false)
118  .def("scx_enable_cadi_log", &scx::scx_enable_cadi_log,
119  pybind11::arg("log") = true)
120  .def("scx_print_port_number", &scx::scx_print_port_number,
121  pybind11::arg("print") = true)
122 
123  .def("scx_print_statistics", &scx::scx_print_statistics,
124  pybind11::arg("print") = true)
125  .def("scx_load_plugin", &scx::scx_load_plugin)
126  .def("scx_sync", &scx::scx_sync)
127  .def("scx_set_min_sync_latency",
128  static_cast<void (*)(double)>(&scx::scx_set_min_sync_latency))
129  .def("scx_set_min_sync_latency",
130  static_cast<void (*)(sg::ticks_t)>(
131  &scx::scx_set_min_sync_latency))
132  .def("scx_get_min_sync_latency",
133  static_cast<double (*)()>(&scx::scx_get_min_sync_latency))
134  .def("scx_get_min_sync_latency",
135  static_cast<sg::ticks_t (*)(sg::Tag<sg::ticks_t> *)>(
136  &scx::scx_get_min_sync_latency))
137  ;
138 
139  // submodule for gem5-specific functions
140  auto gem5 = arm_fast_model.def_submodule("gem5");
141  gem5.def("enable_exit_on_dmi_warning_handler", []() {
142  sc_gem5::addExtraSystemCReportHandler(fastmodel_sc_report_handler);
143  });
144 }
145 EmbeddedPyBind embed_("arm_fast_model", &arm_fast_model_pybind);
146 
147 } // anonymous namespace
148 } // namespace gem5
sc_core::sc_actions
unsigned sc_actions
Definition: sc_report_handler.hh:39
report.hh
std::vector< char * >
sc_core::sc_report::get_msg
const char * get_msg() const
Definition: sc_report.hh:69
pybind.hh
sc_gem5::addExtraSystemCReportHandler
void addExtraSystemCReportHandler(sc_core::sc_report_handler_proc proc)
Definition: report.cc:85
sc_core::sc_report
Definition: sc_report.hh:60
panic_if
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
Definition: logging.hh:214
logging.hh
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: gpu_translation_state.hh:37
init.hh

Generated on Sun Jul 30 2023 01:56:47 for gem5 by doxygen 1.8.17