CIRCT  20.0.0git
Cosim.h
Go to the documentation of this file.
1 //===- Cosim.h - ESI C++ cosimulation backend -------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This is a specialization of the ESI C++ API (backend) for connection into a
10 // simulation of an ESI system. Currently uses Cap'nProto RPC, but that could
11 // change. Requires Cap'nProto C++ library.
12 //
13 // DO NOT EDIT!
14 // This file is distributed as part of an ESI package. The source for this file
15 // should always be modified within CIRCT (lib/dialect/ESI/runtime/cpp).
16 //
17 //===----------------------------------------------------------------------===//
18 
19 // NOLINTNEXTLINE(llvm-header-guard)
20 #ifndef ESI_BACKENDS_COSIM_H
21 #define ESI_BACKENDS_COSIM_H
22 
23 #include "esi/Accelerator.h"
24 
25 #include <memory>
26 #include <set>
27 
28 namespace esi {
29 namespace cosim {
30 class ChannelDesc;
31 }
32 
33 namespace backends {
34 namespace cosim {
35 
36 /// Connect to an ESI simulation.
38 public:
39  CosimAccelerator(Context &, std::string hostname, uint16_t port);
41 
42  static std::unique_ptr<AcceleratorConnection>
43  connect(Context &, std::string connectionString);
44 
45  // Different ways to retrieve the manifest in Cosimulation.
47  Cosim, // Use the backdoor cosim interface. Default.
48  MMIO, // Use MMIO emulation.
49  };
50  // Set the way this connection will retrieve the manifest.
51  void setManifestMethod(ManifestMethod method);
52 
53  /// Request the host side channel ports for a particular instance (identified
54  /// by the AppID path). For convenience, provide the bundle type and direction
55  /// of the bundle port.
56  virtual std::map<std::string, ChannelPort &>
58  const ServiceTable &) override;
59 
60  // C++ doesn't have a mechanism to forward declare a nested class and we don't
61  // want to include the generated header here. So we have to wrap it in a
62  // forward-declared struct we write ourselves.
63  struct StubContainer;
64 
65 protected:
66  virtual Service *createService(Service::Type service, AppIDPath path,
67  std::string implName,
68  const ServiceImplDetails &details,
69  const HWClientDetails &clients) override;
70 
71 private:
73 
74  // We own all channels connected to rpcClient since their lifetime is tied to
75  // rpcClient.
76  std::set<std::unique_ptr<ChannelPort>> channels;
77  // Map from client path to channel assignments for that client.
78  std::map<AppIDPath, std::map<std::string, std::string>>
80 
82 };
83 
84 } // namespace cosim
85 } // namespace backends
86 } // namespace esi
87 
88 #endif // ESI_BACKENDS_COSIM_H
AcceleratorConnection::ServiceTable ServiceTable
Definition: Manifest.cpp:23
Abstract class representing a connection to an accelerator.
Definition: Accelerator.h:78
services::Service Service
Definition: Accelerator.h:107
Bundles represent a collection of channels.
Definition: Types.h:44
AcceleratorConnections, Accelerators, and Manifests must all share a context.
Definition: Context.h:31
Connect to an ESI simulation.
Definition: Cosim.h:37
std::map< AppIDPath, std::map< std::string, std::string > > clientChannelAssignments
Definition: Cosim.h:79
void setManifestMethod(ManifestMethod method)
Definition: Cosim.cpp:574
static std::unique_ptr< AcceleratorConnection > connect(Context &, std::string connectionString)
Parse the connection std::string and instantiate the accelerator.
Definition: Cosim.cpp:68
virtual Service * createService(Service::Type service, AppIDPath path, std::string implName, const ServiceImplDetails &details, const HWClientDetails &clients) override
Called by getServiceImpl exclusively.
Definition: Cosim.cpp:537
CosimAccelerator(Context &, std::string hostname, uint16_t port)
Construct and connect to a cosim server.
Definition: Cosim.cpp:120
std::set< std::unique_ptr< ChannelPort > > channels
Definition: Cosim.h:76
virtual std::map< std::string, ChannelPort & > requestChannelsFor(AppIDPath, const BundleType *, const ServiceTable &) override
Request the host side channel ports for a particular instance (identified by the AppID path).
Definition: Cosim.cpp:294
const std::type_info & Type
Definition: Services.h:47
Definition: esi.py:1
std::map< std::string, std::any > ServiceImplDetails
Definition: Common.h:98
std::vector< HWClientDetail > HWClientDetails
Definition: Common.h:97
Hack around C++ not having a way to forward declare a nested class.
Definition: Cosim.cpp:52