CIRCT  20.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  // Discard all data sent to the accelerator. Disable trace file generation.
49  };
50 
51  /// Create a trace-based accelerator backend.
52  /// \param mode The mode of operation. See Mode.
53  /// \param manifestJson The path to the manifest JSON file.
54  /// \param traceFile The path to the trace file. For 'Write' mode, this file
55  /// is opened for writing. For 'Read' mode, this file is opened for reading.
56  TraceAccelerator(Context &, Mode mode, std::filesystem::path manifestJson,
57  std::filesystem::path traceFile);
58  ~TraceAccelerator() override;
59 
60  /// Parse the connection string and instantiate the accelerator. Format is:
61  /// "<mode>:<manifest path>[:<traceFile>]".
62  static std::unique_ptr<AcceleratorConnection>
63  connect(Context &, std::string connectionString);
64 
65  /// Internal implementation.
66  struct Impl;
67 
68  /// Request the host side channel ports for a particular instance (identified
69  /// by the AppID path). For convenience, provide the bundle type.
70  std::map<std::string, ChannelPort &>
71  requestChannelsFor(AppIDPath, const BundleType *) override;
72 
73 protected:
74  virtual Service *createService(Service::Type service, AppIDPath idPath,
75  std::string implName,
76  const ServiceImplDetails &details,
77  const HWClientDetails &clients) override;
78 
79 private:
80  std::unique_ptr<Impl> impl;
81 };
82 
83 } // namespace trace
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:100
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: Trace.h:35
std::unique_ptr< Impl > impl
Definition: Trace.h:80
TraceAccelerator(Context &, Mode mode, std::filesystem::path manifestJson, std::filesystem::path traceFile)
Create a trace-based accelerator backend.
Definition: Trace.cpp:141
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:149
static std::unique_ptr< AcceleratorConnection > connect(Context &, std::string connectionString)
Parse the connection string and instantiate the accelerator.
Definition: Trace.cpp:108
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:261
const std::type_info & Type
Definition: Services.h:47
Definition: esi.py:1
std::map< std::string, std::any > ServiceImplDetails
Definition: Common.h:87
std::vector< HWClientDetail > HWClientDetails
Definition: Common.h:86