CIRCT 22.0.0git
Loading...
Searching...
No Matches
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 gRPC, but that could change.
11// Requires gRPC 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
28namespace esi {
29namespace backends {
30namespace cosim {
31
32class CosimEngine;
33class RpcClient;
34
35/// Connect to an ESI simulation.
37 friend class CosimEngine;
38
39public:
40 CosimAccelerator(Context &, std::string hostname, uint16_t port);
42
43 static std::unique_ptr<AcceleratorConnection>
44 connect(Context &, std::string connectionString);
45
46 // Different ways to retrieve the manifest in Cosimulation.
48 Cosim, // Use the backdoor cosim interface. Default.
49 MMIO, // Use MMIO emulation.
50 };
51 // Set the way this connection will retrieve the manifest.
53
54 void createEngine(const std::string &engineTypeName, AppIDPath idPath,
55 const ServiceImplDetails &details,
56 const HWClientDetails &clients) override;
57
58protected:
59 virtual Service *createService(Service::Type service, AppIDPath path,
60 std::string implName,
61 const ServiceImplDetails &details,
62 const HWClientDetails &clients) override;
63
64private:
65 std::unique_ptr<RpcClient> rpcClient;
66
67 // We own all channels connected to rpcClient since their lifetime is tied to
68 // rpcClient.
69 std::set<std::unique_ptr<ChannelPort>> channels;
70
72};
73
74} // namespace cosim
75} // namespace backends
76} // namespace esi
77
78#endif // ESI_BACKENDS_COSIM_H
Abstract class representing a connection to an accelerator.
Definition Accelerator.h:79
services::Service Service
Definition Accelerator.h:96
AcceleratorConnections, Accelerators, and Manifests must all share a context.
Definition Context.h:34
Connect to an ESI simulation.
Definition Cosim.h:36
void createEngine(const std::string &engineTypeName, AppIDPath idPath, const ServiceImplDetails &details, const HWClientDetails &clients) override
Create a new engine for channel communication with the accelerator.
Definition Cosim.cpp:595
std::unique_ptr< RpcClient > rpcClient
Definition Cosim.h:65
void setManifestMethod(ManifestMethod method)
Definition Cosim.cpp:627
static std::unique_ptr< AcceleratorConnection > connect(Context &, std::string connectionString)
Parse the connection std::string and instantiate the accelerator.
Definition Cosim.cpp:166
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:608
std::set< std::unique_ptr< ChannelPort > > channels
Definition Cosim.h:69
Implement the magic cosim channel communication.
Definition Cosim.cpp:529
A gRPC client for communicating with the cosimulation server.
Definition RpcClient.h:36
const std::type_info & Type
Definition Services.h:61
Definition esi.py:1
std::map< std::string, std::any > ServiceImplDetails
Definition Common.h:108
std::vector< HWClientDetail > HWClientDetails
Definition Common.h:107