CIRCT  19.0.0git
Trace.h
Go to the documentation of this file.
1 //===- Trace.h - ESI trace 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 trace-based
10 // Accelerator interactions. This means that it will have the capability to read
11 // trace files recorded from interactions with an actual connection. It also has
12 // a mode wherein it will write to a file (for sends) and produce random data
13 // (for receives). Both modes are intended for debugging without a simulation.
14 //
15 // DO NOT EDIT!
16 // This file is distributed as part of an ESI package. The source for this file
17 // should always be modified within CIRCT (lib/dialect/ESI/runtime/cpp/).
18 //
19 //===----------------------------------------------------------------------===//
20 
21 // NOLINTNEXTLINE(llvm-header-guard)
22 #ifndef ESI_BACKENDS_COSIM_H
23 #define ESI_BACKENDS_COSIM_H
24 
25 #include "esi/Accelerator.h"
26 
27 #include <filesystem>
28 #include <memory>
29 
30 namespace esi {
31 namespace backends {
32 namespace trace {
33 
34 /// Connect to an ESI simulation.
36 public:
37  enum Mode {
38  // Write data sent to the accelerator to the trace file. Produce random
39  // garbage data for reads from the accelerator.
41 
42  // Sent data to the accelerator is compared against the trace file's record.
43  // Data read from the accelerator is read from the trace file.
44  // TODO: Full trace mode not yet supported.
45  // Read
46  };
47 
48  /// Create a trace-based accelerator backend.
49  /// \param mode The mode of operation. See Mode.
50  /// \param manifestJson The path to the manifest JSON file.
51  /// \param traceFile The path to the trace file. For 'Write' mode, this file
52  /// is opened for writing. For 'Read' mode, this file is opened for reading.
53  TraceAccelerator(Context &, Mode mode, std::filesystem::path manifestJson,
54  std::filesystem::path traceFile);
55 
56  /// Parse the connection string and instantiate the accelerator. Format is:
57  /// "<mode>:<manifest path>[:<traceFile>]".
58  static std::unique_ptr<AcceleratorConnection>
59  connect(Context &, std::string connectionString);
60 
61  /// Internal implementation.
62  struct Impl;
63 
64  /// Request the host side channel ports for a particular instance (identified
65  /// by the AppID path). For convenience, provide the bundle type.
66  std::map<std::string, ChannelPort &>
67  requestChannelsFor(AppIDPath, const BundleType *) override;
68 
69 protected:
70  virtual Service *createService(Service::Type service, AppIDPath idPath,
71  std::string implName,
72  const ServiceImplDetails &details,
73  const HWClientDetails &clients) override;
74 
75 private:
76  std::unique_ptr<Impl> impl;
77 };
78 
79 } // namespace trace
80 } // namespace backends
81 } // namespace esi
82 
83 #endif // ESI_BACKENDS_COSIM_H
Abstract class representing a connection to an accelerator.
Definition: Accelerator.h:75
services::Service Service
Definition: Accelerator.h:87
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: Trace.h:35
std::unique_ptr< Impl > impl
Definition: Trace.h:76
TraceAccelerator(Context &, Mode mode, std::filesystem::path manifestJson, std::filesystem::path traceFile)
Create a trace-based accelerator backend.
Definition: Trace.cpp:126
static std::unique_ptr< AcceleratorConnection > connect(Context &, std::string connectionString)
Parse the connection string and instantiate the accelerator.
Definition: Trace.cpp:96
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: Trace.cpp:242
virtual Service * createService(Service::Type service, AppIDPath idPath, std::string implName, const ServiceImplDetails &details, const HWClientDetails &clients) override
Called by getServiceImpl exclusively.
Definition: Trace.cpp:133
const std::type_info & Type
Definition: Services.h:44
Definition: esi.py:1
std::map< std::string, std::any > ServiceImplDetails
Definition: Common.h:80
std::vector< HWClientDetail > HWClientDetails
Definition: Common.h:79