32int main(
int argc,
const char *argv[]) {
34 cli.description(
"Query an ESI system for information from the manifest.");
36 CLI::App *versionSub =
37 cli.add_subcommand(
"version",
"Print ESI system version");
38 bool infoDetails =
false;
40 cli.add_subcommand(
"info",
"Print ESI system information");
41 infoSub->add_flag(
"--details", infoDetails,
42 "Print detailed information about the system");
43 bool hierDetails =
false;
44 CLI::App *hierSub = cli.add_subcommand(
"hier",
"Print ESI system hierarchy");
45 hierSub->add_flag(
"--details", hierDetails,
46 "Print detailed information about the system");
47 CLI::App *telemetrySub =
48 cli.add_subcommand(
"telemetry",
"Print ESI system telemetry information");
50 if (
int rc = cli.
esiParse(argc, argv))
52 if (!cli.get_help_ptr()->empty())
57 std::unique_ptr<AcceleratorConnection> acc = cli.
connect();
61 std::cout << info.getEsiVersion() << std::endl;
66 else if (*telemetrySub)
69 }
catch (std::exception &e) {
70 ctxt.getLogger().error(
"esiquery", e.what());
76 std::string jsonManifest =
79 os <<
"API version: " << m.
getApiVersion() << std::endl << std::endl;
80 os <<
"********************************" << std::endl;
81 os <<
"* Module information" << std::endl;
82 os <<
"********************************" << std::endl;
91 os <<
"********************************" << std::endl;
92 os <<
"* Type table" << std::endl;
93 os <<
"********************************" << std::endl;
97 os <<
" " << i++ <<
": " << t->getID() << std::endl;
109 os << indent <<
" " << port.
getID() <<
":";
111 if (
auto svcPortStr = svcPort->toString()) {
112 os <<
" " << *svcPortStr << std::endl;
116 for (
const auto &[name, chan] : port.
getChannels())
117 os << indent <<
" " << name <<
": " << chan.getType()->getID()
125 [&](
const std::pair<const AppID, BundlePort &> port) {
126 return showPort(port.second, details);
128 if (!details && !hasPorts && d->
getChildren().empty())
130 os << indent <<
"* Instance: ";
131 if (
auto inst =
dynamic_cast<const Instance *
>(d)) {
132 os << inst->getID() << std::endl;
133 if (inst->getInfo() && inst->getInfo()->name)
134 os << indent <<
"* Module: " << *inst->getInfo()->name << std::endl;
136 os <<
"top" << std::endl;
139 os << indent <<
"* Ports:" << std::endl;
141 printPort(os, port, indent +
" ", details);
143 if (!children.empty()) {
144 os << indent <<
"* Children:" << std::endl;
155 os <<
"********************************" << std::endl;
156 os <<
"* Design hierarchy" << std::endl;
157 os <<
"********************************" << std::endl;
170 os <<
"No telemetry service found" << std::endl;
173 os <<
"********************************" << std::endl;
174 os <<
"* Telemetry" << std::endl;
175 os <<
"********************************" << std::endl;
178 const std::map<AppIDPath, services::TelemetryService::Telemetry *>
180 for (
const auto &[
id, port] : telemetryPorts) {
184 uint64_t value = *port->read().get().as<uint64_t>();
185 os << value << std::endl;
Abstract class representing a connection to an accelerator.
ServiceClass * getService(AppIDPath id={}, std::string implName={}, ServiceImplDetails details={}, HWClientDetails clients={})
Get a typed reference to a particular service type.
Context & getCtxt() const
AcceleratorServiceThread * getServiceThread()
Return a pointer to the accelerator 'service' thread (or threads).
void addPoll(HWModule &module)
Poll this module.
Top level accelerator class.
Services provide connections to 'bundles' – collections of named, unidirectional communication channe...
const PortMap & getChannels() const
AppID getID() const
Get the ID of the port.
Common options and code for ESI runtime tools.
Context & getContext()
Get the context.
std::unique_ptr< AcceleratorConnection > connect()
Connect to the accelerator using the specified backend and connection.
int esiParse(int argc, const char **argv)
Run the parser.
AcceleratorConnections, Accelerators, and Manifests must all share a context.
Represents either the top level or an instance of a hardware module.
std::vector< std::reference_wrapper< BundlePort > > getPortsOrdered() const
Get the module's ports in a deterministic order.
std::vector< const Instance * > getChildrenOrdered() const
Get a vector of the module's children in a deterministic order.
const std::map< AppID, BundlePort & > & getPorts() const
Access the module's ports by ID.
const std::map< AppID, Instance * > & getChildren() const
Access the module's children by ID.
Subclass of HWModule which represents a submodule instance.
Class to parse a manifest.
uint32_t getApiVersion() const
Accelerator * buildAccelerator(AcceleratorConnection &acc) const
const std::vector< const Type * > & getTypeTable() const
The Type Table is an ordered list of types.
std::vector< ModuleInfo > getModuleInfos() const
Root class of the ESI type system.
Add a custom interface to a service client at a particular point in the design hierarchy.
Information about the Accelerator system.
virtual std::string getJsonManifest() const
Return the JSON-formatted system manifest.
Service for retrieving telemetry data from the accelerator.
const std::map< AppIDPath, Telemetry * > & getTelemetryPorts()
void printHier(std::ostream &os, AcceleratorConnection &acc, bool details)
void printInstance(std::ostream &os, const HWModule *d, std::string indent, bool details)
void printPort(std::ostream &os, const BundlePort &port, std::string indent, bool details)
void printInfo(std::ostream &os, AcceleratorConnection &acc, bool details)
void printTelemetry(std::ostream &os, AcceleratorConnection &acc)
static bool showPort(const BundlePort &port, bool details)
int main(int argc, const char *argv[])