esiaccel 0.1.5.dev254__cp311-cp311-win_amd64.whl → 0.2.3.dev47__cp311-cp311-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. esiaccel/CosimBackend.dll +0 -0
  2. esiaccel/CosimBackend.lib +0 -0
  3. esiaccel/CosimRpc.dll +0 -0
  4. esiaccel/CosimRpc.lib +0 -0
  5. esiaccel/ESICppRuntime.dll +0 -0
  6. esiaccel/ESICppRuntime.lib +0 -0
  7. esiaccel/EsiCosimDpiServer.dll +0 -0
  8. esiaccel/EsiCosimDpiServer.lib +0 -0
  9. esiaccel/MtiPli.dll +0 -0
  10. esiaccel/MtiPli.lib +0 -0
  11. esiaccel/__init__.py +12 -3
  12. esiaccel/abseil_dll.dll +0 -0
  13. esiaccel/accelerator.py +37 -5
  14. esiaccel/cares.dll +0 -0
  15. esiaccel/cmake/esiaccelConfig.cmake +34 -0
  16. esiaccel/codegen.py +3 -3
  17. esiaccel/esiCppAccel.cp312-win_amd64.pyd +0 -0
  18. esiaccel/esiquery.exe +0 -0
  19. esiaccel/include/esi/Accelerator.h +3 -16
  20. esiaccel/include/esi/CLI.h +5 -5
  21. esiaccel/include/esi/Common.h +11 -1
  22. esiaccel/include/esi/Context.h +17 -9
  23. esiaccel/include/esi/Design.h +9 -4
  24. esiaccel/include/esi/Manifest.h +0 -2
  25. esiaccel/include/esi/Ports.h +230 -23
  26. esiaccel/include/esi/Services.h +50 -18
  27. esiaccel/include/esi/Types.h +108 -31
  28. esiaccel/include/esi/Values.h +313 -0
  29. esiaccel/include/esi/backends/Cosim.h +5 -12
  30. esiaccel/include/esi/backends/RpcClient.h +97 -0
  31. esiaccel/include/esi/backends/RpcServer.h +21 -3
  32. esiaccel/libcrypto-3-x64.dll +0 -0
  33. esiaccel/libprotobuf.dll +0 -0
  34. esiaccel/libssl-3-x64.dll +0 -0
  35. esiaccel/re2.dll +0 -0
  36. esiaccel/types.py +6 -4
  37. esiaccel/zlib1.dll +0 -0
  38. {esiaccel-0.1.5.dev254.dist-info → esiaccel-0.2.3.dev47.dist-info}/METADATA +1 -1
  39. esiaccel-0.2.3.dev47.dist-info/RECORD +57 -0
  40. esiaccel/esiCppAccel.cp311-win_amd64.pyd +0 -0
  41. esiaccel-0.1.5.dev254.dist-info/RECORD +0 -53
  42. {esiaccel-0.1.5.dev254.dist-info → esiaccel-0.2.3.dev47.dist-info}/WHEEL +0 -0
  43. {esiaccel-0.1.5.dev254.dist-info → esiaccel-0.2.3.dev47.dist-info}/entry_points.txt +0 -0
  44. {esiaccel-0.1.5.dev254.dist-info → esiaccel-0.2.3.dev47.dist-info}/licenses/LICENSE +0 -0
  45. {esiaccel-0.1.5.dev254.dist-info → esiaccel-0.2.3.dev47.dist-info}/top_level.txt +0 -0
esiaccel/CosimBackend.dll CHANGED
Binary file
esiaccel/CosimBackend.lib CHANGED
Binary file
esiaccel/CosimRpc.dll ADDED
Binary file
esiaccel/CosimRpc.lib ADDED
Binary file
Binary file
Binary file
Binary file
Binary file
esiaccel/MtiPli.dll CHANGED
Binary file
esiaccel/MtiPli.lib CHANGED
Binary file
esiaccel/__init__.py CHANGED
@@ -3,14 +3,15 @@
3
3
  # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4
4
  import sys
5
5
  import os
6
- from .accelerator import AcceleratorConnection
6
+ from .accelerator import AcceleratorConnection, Context, LogLevel
7
7
 
8
8
  from .esiCppAccel import (AppID, Type, BundleType, ChannelType, ArrayType,
9
9
  StructType, BitsType, UIntType, SIntType)
10
10
 
11
11
  __all__ = [
12
- "AcceleratorConnection", "AppID", "Type", "BundleType", "ChannelType",
13
- "ArrayType", "StructType", "BitsType", "UIntType", "SIntType"
12
+ "AcceleratorConnection", "AppID", "Context", "LogLevel", "Type",
13
+ "BundleType", "ChannelType", "ArrayType", "StructType", "BitsType",
14
+ "UIntType", "SIntType"
14
15
  ]
15
16
 
16
17
  if sys.platform == "win32":
@@ -20,3 +21,11 @@ if sys.platform == "win32":
20
21
  """
21
22
  from .utils import get_dll_dir
22
23
  os.add_dll_directory(str(get_dll_dir()))
24
+
25
+
26
+ def connect(platform: str, connection_str: str) -> "AcceleratorConnection":
27
+ """Connect to an accelerator using the specified platform and connection
28
+ string."""
29
+ ctxt = Context.default()
30
+ return AcceleratorConnection(ctxt,
31
+ ctxt.cpp_ctxt.connect(platform, connection_str))
esiaccel/abseil_dll.dll CHANGED
Binary file
esiaccel/accelerator.py CHANGED
@@ -15,19 +15,51 @@ from typing import Dict, List, Optional
15
15
  from .types import BundlePort
16
16
  from . import esiCppAccel as cpp
17
17
 
18
- # Global context for the C++ side.
19
- ctxt = cpp.Context()
18
+ LogLevel = cpp.LogLevel
19
+
20
+
21
+ class Context:
22
+ """A context for ESI accelerator connections. The underlying C++ context owns
23
+ everything assocated with it including types, accelerator connections, and
24
+ the accelerator facade/interface (aka Accelerator) itself. It must not be
25
+ garbage collected while any accelerators or connections that it owns are still
26
+ in use as they will be disconnected and destroyed when the context is
27
+ destroyed."""
28
+
29
+ _default: Optional["Context"] = None
30
+
31
+ def __init__(self, log_level: cpp.LogLevel = cpp.LogLevel.Warning):
32
+ self.cpp_ctxt = cpp.Context()
33
+ self.set_stdio_logger(log_level)
34
+
35
+ @staticmethod
36
+ def default() -> "Context":
37
+ if Context._default is None:
38
+ Context._default = Context()
39
+ return Context._default
40
+
41
+ def set_stdio_logger(self, level: cpp.LogLevel):
42
+ self.cpp_ctxt.set_stdio_logger(level)
43
+
44
+ def connect(self, platform: str,
45
+ connection_str: str) -> "AcceleratorConnection":
46
+ return AcceleratorConnection(
47
+ self, self.cpp_ctxt.connect(platform, connection_str))
20
48
 
21
49
 
22
50
  class AcceleratorConnection:
23
51
  """A connection to an ESI accelerator."""
24
52
 
25
- def __init__(self, platform: str, connection_str: str):
26
- self.cpp_accel = cpp.AcceleratorConnection(ctxt, platform, connection_str)
53
+ def __init__(self, ctxt: Context, cpp_accel: cpp.AcceleratorConnection):
54
+ if not isinstance(ctxt, Context):
55
+ raise TypeError("ctxt must be a Context")
56
+ self.ctxt = ctxt
57
+ self.cpp_accel = cpp_accel
27
58
 
28
59
  def manifest(self) -> cpp.Manifest:
29
60
  """Get and parse the accelerator manifest."""
30
- return cpp.Manifest(ctxt, self.cpp_accel.sysinfo().json_manifest())
61
+ return cpp.Manifest(self.ctxt.cpp_ctxt,
62
+ self.cpp_accel.sysinfo().json_manifest())
31
63
 
32
64
  def sysinfo(self) -> cpp.SysInfo:
33
65
  return self.cpp_accel.sysinfo()
esiaccel/cares.dll CHANGED
Binary file
@@ -13,3 +13,37 @@ else()
13
13
  IMPORTED_LOCATION "${CMAKE_CURRENT_LIST_DIR}/.././libESICppRuntime.so"
14
14
  )
15
15
  endif()
16
+
17
+ add_library(esiaccel::CosimRpc SHARED IMPORTED)
18
+ set_target_properties(esiaccel::CosimRpc PROPERTIES
19
+ INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_LIST_DIR}/../include"
20
+ INTERFACE_LINK_LIBRARIES esiaccel::ESICppRuntime
21
+ )
22
+
23
+ if(WIN32)
24
+ set_target_properties(esiaccel::CosimRpc PROPERTIES
25
+ IMPORTED_LOCATION "${CMAKE_CURRENT_LIST_DIR}/../CosimRpc.dll"
26
+ IMPORTED_IMPLIB "${CMAKE_CURRENT_LIST_DIR}/../CosimRpc.lib"
27
+ )
28
+ else()
29
+ set_target_properties(esiaccel::CosimRpc PROPERTIES
30
+ IMPORTED_LOCATION "${CMAKE_CURRENT_LIST_DIR}/.././libCosimRpc.so"
31
+ )
32
+ endif()
33
+
34
+ add_library(esiaccel::CosimBackend SHARED IMPORTED)
35
+ set_target_properties(esiaccel::CosimBackend PROPERTIES
36
+ INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_LIST_DIR}/../include"
37
+ INTERFACE_LINK_LIBRARIES "esiaccel::ESICppRuntime;esiaccel::CosimRpc"
38
+ )
39
+
40
+ if(WIN32)
41
+ set_target_properties(esiaccel::CosimBackend PROPERTIES
42
+ IMPORTED_LOCATION "${CMAKE_CURRENT_LIST_DIR}/../CosimBackend.dll"
43
+ IMPORTED_IMPLIB "${CMAKE_CURRENT_LIST_DIR}/../CosimBackend.lib"
44
+ )
45
+ else()
46
+ set_target_properties(esiaccel::CosimBackend PROPERTIES
47
+ IMPORTED_LOCATION "${CMAKE_CURRENT_LIST_DIR}/.././libCosimBackend.so"
48
+ )
49
+ endif()
esiaccel/codegen.py CHANGED
@@ -6,7 +6,7 @@
6
6
  # with the runtime, though it is intended to be extensible for other languages.
7
7
 
8
8
  from typing import List, TextIO, Type, Optional
9
- from .accelerator import AcceleratorConnection
9
+ from .accelerator import AcceleratorConnection, Context
10
10
  from .esiCppAccel import ModuleInfo
11
11
  from . import types
12
12
 
@@ -171,12 +171,12 @@ def run(generator: Type[Generator] = CppGenerator,
171
171
 
172
172
  conn: AcceleratorConnection
173
173
  if args.file is not None:
174
- conn = AcceleratorConnection("trace", f"-:{args.file}")
174
+ conn = Context.default().connect("trace", f"-:{args.file}")
175
175
  elif args.platform is not None:
176
176
  if args.connection is None:
177
177
  print("Must specify --connection with --platform")
178
178
  return 1
179
- conn = AcceleratorConnection(args.platform, args.connection)
179
+ conn = Context.default().connect(args.platform, args.connection)
180
180
  else:
181
181
  print("Must specify either --file or --platform")
182
182
  return 1
Binary file
esiaccel/esiquery.exe CHANGED
Binary file
@@ -65,8 +65,8 @@ public:
65
65
  Accelerator(std::optional<ModuleInfo> info,
66
66
  std::vector<std::unique_ptr<Instance>> children,
67
67
  std::vector<services::Service *> services,
68
- std::vector<std::unique_ptr<BundlePort>> &ports)
69
- : HWModule(info, std::move(children), services, ports) {}
68
+ std::vector<std::unique_ptr<BundlePort>> &&ports)
69
+ : HWModule(info, std::move(children), services, std::move(ports)) {}
70
70
  };
71
71
 
72
72
  //===----------------------------------------------------------------------===//
@@ -86,13 +86,6 @@ public:
86
86
  /// Disconnect from the accelerator cleanly.
87
87
  virtual void disconnect();
88
88
 
89
- // While building the design, keep around a std::map of active services
90
- // indexed by the service name. When a new service is encountered during
91
- // descent, add it to the table (perhaps overwriting one). Modifications to
92
- // the table only apply to the current branch, so copy this and update it at
93
- // each level of the tree.
94
- using ServiceTable = std::map<std::string, services::Service *>;
95
-
96
89
  /// Return a pointer to the accelerator 'service' thread (or threads). If the
97
90
  /// thread(s) are not running, they will be started when this method is
98
91
  /// called. `std::thread` is used. If users don't want the runtime to spin up
@@ -165,7 +158,7 @@ private:
165
158
 
166
159
  /// Cache services via a unique_ptr so they get free'd automatically when
167
160
  /// Accelerator objects get deconstructed.
168
- using ServiceCacheKey = std::tuple<const std::type_info *, AppIDPath>;
161
+ using ServiceCacheKey = std::tuple<std::string, AppIDPath>;
169
162
  std::map<ServiceCacheKey, std::unique_ptr<Service>> serviceCache;
170
163
 
171
164
  std::unique_ptr<AcceleratorServiceThread> serviceThread;
@@ -176,12 +169,6 @@ private:
176
169
 
177
170
  namespace registry {
178
171
 
179
- // Connect to an ESI accelerator given a backend name and connection specifier.
180
- // Alternatively, instantiate the backend directly (if you're using C++).
181
- std::unique_ptr<AcceleratorConnection> connect(Context &ctxt,
182
- const std::string &backend,
183
- const std::string &connection);
184
-
185
172
  namespace internal {
186
173
 
187
174
  /// Backends can register themselves to be connected via a connection string.
@@ -51,19 +51,19 @@ public:
51
51
  ctxt = Context::withLogger<ConsoleLogger>(Logger::Level::Debug);
52
52
  else if (verbose)
53
53
  ctxt = Context::withLogger<ConsoleLogger>(Logger::Level::Info);
54
+ else
55
+ ctxt = Context::withLogger<ConsoleLogger>(Logger::Level::Warning);
54
56
  return 0;
55
57
  }
56
58
 
57
59
  /// Connect to the accelerator using the specified backend and connection.
58
- std::unique_ptr<AcceleratorConnection> connect() {
59
- return ctxt.connect(backend, connStr);
60
- }
60
+ AcceleratorConnection *connect() { return ctxt->connect(backend, connStr); }
61
61
 
62
62
  /// Get the context.
63
- Context &getContext() { return ctxt; }
63
+ Context &getContext() { return *ctxt; }
64
64
 
65
65
  protected:
66
- Context ctxt;
66
+ std::unique_ptr<Context> ctxt;
67
67
 
68
68
  std::string backend;
69
69
  std::string connStr;
@@ -43,6 +43,13 @@ struct AppID {
43
43
  return name == other.name && idx == other.idx;
44
44
  }
45
45
  bool operator!=(const AppID &other) const { return !(*this == other); }
46
+ friend std::ostream &operator<<(std::ostream &os, const AppID &id);
47
+
48
+ std::string toString() const {
49
+ if (idx.has_value())
50
+ return name + "[" + std::to_string(idx.value()) + "]";
51
+ return name;
52
+ }
46
53
  };
47
54
  bool operator<(const AppID &a, const AppID &b);
48
55
 
@@ -53,6 +60,7 @@ public:
53
60
  AppIDPath operator+(const AppIDPath &b) const;
54
61
  AppIDPath parent() const;
55
62
  std::string toStr() const;
63
+ friend std::ostream &operator<<(std::ostream &os, const AppIDPath &path);
56
64
  };
57
65
  bool operator<(const AppIDPath &a, const AppIDPath &b);
58
66
 
@@ -106,6 +114,8 @@ class MessageData {
106
114
  public:
107
115
  /// Adopts the data vector buffer.
108
116
  MessageData() = default;
117
+ MessageData(std::span<const uint8_t> data)
118
+ : data(data.data(), data.data() + data.size()) {}
109
119
  MessageData(std::vector<uint8_t> &data) : data(std::move(data)) {}
110
120
  MessageData(std::vector<uint8_t> &&data) : data(std::move(data)) {}
111
121
  MessageData(const uint8_t *data, size_t size) : data(data, data + size) {}
@@ -126,6 +136,7 @@ public:
126
136
 
127
137
  /// Get the size of the data in bytes.
128
138
  size_t getSize() const { return data.size(); }
139
+ size_t size() const { return getSize(); }
129
140
 
130
141
  /// Returns true if this message contains no data.
131
142
  bool empty() const { return data.empty(); }
@@ -158,7 +169,6 @@ private:
158
169
  } // namespace esi
159
170
 
160
171
  std::ostream &operator<<(std::ostream &, const esi::ModuleInfo &);
161
- std::ostream &operator<<(std::ostream &, const esi::AppID &);
162
172
 
163
173
  //===----------------------------------------------------------------------===//
164
174
  // Functions which should be in the standard library.
@@ -20,23 +20,30 @@
20
20
  #include "esi/Types.h"
21
21
 
22
22
  #include <exception>
23
+ #include <map>
23
24
  #include <memory>
24
- #include <optional>
25
+ #include <vector>
25
26
 
26
27
  namespace esi {
27
28
  class AcceleratorConnection;
28
29
 
29
30
  /// AcceleratorConnections, Accelerators, and Manifests must all share a
30
- /// context. It owns all the types, uniquifying them.
31
+ /// context. It owns all the types, uniquifying them. It also owns the
32
+ /// connections (which own the Accelerators). When it is destroyed, all
33
+ /// connections are disconnected and the objects are destroyed.
31
34
  class Context {
32
35
  public:
33
- Context() : logger(std::make_unique<ConsoleLogger>(Logger::Level::Warning)) {}
34
- Context(std::unique_ptr<Logger> logger) : logger(std::move(logger)) {}
36
+ Context();
37
+ Context(std::unique_ptr<Logger> logger);
38
+ ~Context();
39
+
40
+ /// Disconnect from all accelerators associated with this context.
41
+ void disconnectAll();
35
42
 
36
43
  /// Create a context with a specific logger type.
37
44
  template <typename T, typename... Args>
38
- static Context withLogger(Args &&...args) {
39
- return Context(std::make_unique<T>(args...));
45
+ static std::unique_ptr<Context> withLogger(Args &&...args) {
46
+ return std::make_unique<Context>(std::make_unique<T>(args...));
40
47
  }
41
48
 
42
49
  /// Resolve a type id to the type.
@@ -49,9 +56,9 @@ public:
49
56
  /// Register a type with the context. Takes ownership of the pointer type.
50
57
  void registerType(Type *type);
51
58
 
52
- /// Connect to an accelerator backend.
53
- std::unique_ptr<AcceleratorConnection> connect(std::string backend,
54
- std::string connection);
59
+ /// Connect to an accelerator backend. Retains ownership internally and
60
+ /// returns a non-owning pointer.
61
+ AcceleratorConnection *connect(std::string backend, std::string connection);
55
62
 
56
63
  /// Register a logger with the accelerator. Assumes ownership of the logger.
57
64
  void setLogger(std::unique_ptr<Logger> logger) {
@@ -63,6 +70,7 @@ public:
63
70
 
64
71
  private:
65
72
  std::unique_ptr<Logger> logger;
73
+ std::vector<std::unique_ptr<AcceleratorConnection>> connections;
66
74
 
67
75
  private:
68
76
  using TypeCache = std::map<Type::ID, std::unique_ptr<Type>>;
@@ -45,11 +45,15 @@ class Service;
45
45
 
46
46
  /// Represents either the top level or an instance of a hardware module.
47
47
  class HWModule {
48
+ public:
49
+ HWModule(const HWModule &) = delete;
50
+ HWModule &operator=(const HWModule &) = delete;
51
+
48
52
  protected:
49
53
  HWModule(std::optional<ModuleInfo> info,
50
54
  std::vector<std::unique_ptr<Instance>> children,
51
55
  std::vector<services::Service *> services,
52
- std::vector<std::unique_ptr<BundlePort>> &ports);
56
+ std::vector<std::unique_ptr<BundlePort>> &&ports);
53
57
 
54
58
  public:
55
59
  virtual ~HWModule() = default;
@@ -112,11 +116,12 @@ public:
112
116
  Instance(AppID id, std::optional<ModuleInfo> info,
113
117
  std::vector<std::unique_ptr<Instance>> children,
114
118
  std::vector<services::Service *> services,
115
- std::vector<std::unique_ptr<BundlePort>> &ports)
116
- : HWModule(info, std::move(children), services, ports), id(id) {}
119
+ std::vector<std::unique_ptr<BundlePort>> &&ports)
120
+ : HWModule(info, std::move(children), services, std::move(ports)),
121
+ id(id) {}
117
122
 
118
123
  /// Get the instance's ID, which it will always have.
119
- const AppID getID() const { return id; }
124
+ AppID getID() const { return id; }
120
125
 
121
126
  protected:
122
127
  const AppID id;
@@ -65,8 +65,6 @@ private:
65
65
 
66
66
  } // namespace esi
67
67
 
68
- std::ostream &operator<<(std::ostream &os, const esi::AppID &id);
69
- std::ostream &operator<<(std::ostream &, const esi::AppIDPath &);
70
68
  std::ostream &operator<<(std::ostream &, const esi::ModuleInfo &);
71
69
 
72
70
  #endif // ESI_MANIFEST_H