CIRCT 21.0.0git
Loading...
Searching...
No Matches
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
30namespace esi {
31namespace backends {
32namespace trace {
33
34/// Connect to an ESI simulation.
36public:
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 Impl &getImpl();
68
69protected:
70 void createEngine(const std::string &engineTypeName, AppIDPath idPath,
71 const ServiceImplDetails &details,
72 const HWClientDetails &clients) override;
73
74 virtual Service *createService(Service::Type service, AppIDPath idPath,
75 std::string implName,
76 const ServiceImplDetails &details,
77 const HWClientDetails &clients) override;
78
79private:
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:79
services::Service Service
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
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 Trace.cpp:250
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:335
static std::unique_ptr< AcceleratorConnection > connect(Context &, std::string connectionString)
Parse the connection string and instantiate the accelerator.
Definition Trace.cpp:106
const std::type_info & Type
Definition Services.h:48
Definition esi.py:1
std::map< std::string, std::any > ServiceImplDetails
Definition Common.h:98
std::vector< HWClientDetail > HWClientDetails
Definition Common.h:97