CIRCT  19.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 &>
57  requestChannelsFor(AppIDPath, const BundleType *) override;
58 
59  // C++ doesn't have a mechanism to forward declare a nested class and we don't
60  // want to include the generated header here. So we have to wrap it in a
61  // forward-declared struct we write ourselves.
62  struct StubContainer;
63 
64 protected:
65  virtual Service *createService(Service::Type service, AppIDPath path,
66  std::string implName,
67  const ServiceImplDetails &details,
68  const HWClientDetails &clients) override;
69 
70 private:
72 
73  // We own all channels connected to rpcClient since their lifetime is tied to
74  // rpcClient.
75  std::set<std::unique_ptr<ChannelPort>> channels;
76  // Map from client path to channel assignments for that client.
77  std::map<AppIDPath, std::map<std::string, std::string>>
79 
81 };
82 
83 } // namespace cosim
84 } // namespace backends
85 } // namespace esi
86 
87 #endif // ESI_BACKENDS_COSIM_H
Abstract class representing a connection to an accelerator.
Definition: Accelerator.h:78
services::Service Service
Definition: Accelerator.h:94
Bundles represent a collection of channels.
Definition: Types.h:44
AcceleratorConnections, Accelerators, and Manifests must all share a context.
Definition: Context.h:30
Connect to an ESI simulation.
Definition: Cosim.h:37
std::map< AppIDPath, std::map< std::string, std::string > > clientChannelAssignments
Definition: Cosim.h:78
void setManifestMethod(ManifestMethod method)
Definition: Cosim.cpp:467
static std::unique_ptr< AcceleratorConnection > connect(Context &, std::string connectionString)
Parse the connection std::string and instantiate the accelerator.
Definition: Cosim.cpp:68
virtual std::map< std::string, ChannelPort & > requestChannelsFor(AppIDPath, const BundleType *) override
Request the host side channel ports for a particular instance (identified by the AppID path).
Definition: Cosim.cpp:289
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:428
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:75
const std::type_info & Type
Definition: Services.h:44
Definition: esi.py:1
std::map< std::string, std::any > ServiceImplDetails
Definition: Common.h:81
std::vector< HWClientDetail > HWClientDetails
Definition: Common.h:80
Hack around C++ not having a way to forward declare a nested class.
Definition: Cosim.cpp:52