esiaccel 0.1.5.dev93__cp310-cp310-win_amd64.whl → 0.1.5.dev107__cp310-cp310-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.

Potentially problematic release.


This version of esiaccel might be problematic. Click here for more details.

esiaccel/CosimBackend.dll CHANGED
Binary file
esiaccel/CosimBackend.lib CHANGED
Binary file
Binary file
Binary file
Binary file
esiaccel/MtiPli.dll CHANGED
Binary file
esiaccel/__init__.py CHANGED
@@ -1,7 +1,8 @@
1
1
  # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
2
2
  # See https://llvm.org/LICENSE.txt for license information.
3
3
  # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4
-
4
+ import sys
5
+ import os
5
6
  from .accelerator import AcceleratorConnection
6
7
 
7
8
  from .esiCppAccel import (AppID, Type, BundleType, ChannelType, ArrayType,
@@ -11,3 +12,11 @@ __all__ = [
11
12
  "AcceleratorConnection", "AppID", "Type", "BundleType", "ChannelType",
12
13
  "ArrayType", "StructType", "BitsType", "UIntType", "SIntType"
13
14
  ]
15
+
16
+ if sys.platform == "win32":
17
+ """Ensure that ESI libraries are in the dll path on Windows. Necessary to
18
+ call when users build against the esiaccel-provided prebuilt CMake/prebuilt
19
+ libraries, before they are loaded via. python.
20
+ """
21
+ from .utils import get_dll_dir
22
+ os.add_dll_directory(str(get_dll_dir()))
Binary file
esiaccel/esiquery.exe CHANGED
Binary file
@@ -20,6 +20,7 @@
20
20
  #include <cstdint>
21
21
  #include <map>
22
22
  #include <optional>
23
+ #include <span>
23
24
  #include <stdexcept>
24
25
  #include <string>
25
26
  #include <vector>
@@ -115,6 +116,11 @@ public:
115
116
  /// Get the data as a vector of bytes.
116
117
  const std::vector<uint8_t> &getData() const { return data; }
117
118
 
119
+ /// Implicit conversion to a vector/span of bytes, to play nice with other
120
+ /// APIs that accept bytearray-like things.
121
+ operator const std::vector<uint8_t> &() const { return data; }
122
+ operator std::span<const uint8_t>() const { return data; }
123
+
118
124
  /// Move the data out of this object.
119
125
  std::vector<uint8_t> takeData() { return std::move(data); }
120
126
 
@@ -16,11 +16,17 @@
16
16
  #ifndef ESI_TYPES_H
17
17
  #define ESI_TYPES_H
18
18
 
19
+ #include <algorithm>
20
+ #include <any>
19
21
  #include <cstdint>
20
22
  #include <map>
23
+ #include <span>
24
+ #include <stdexcept>
21
25
  #include <string>
22
26
  #include <vector>
23
27
 
28
+ #include "esi/Common.h"
29
+
24
30
  namespace esi {
25
31
 
26
32
  /// Root class of the ESI type system.
@@ -33,6 +39,37 @@ public:
33
39
  ID getID() const { return id; }
34
40
  virtual std::ptrdiff_t getBitWidth() const { return -1; }
35
41
 
42
+ /// Serialize an object to MessageData. The object should be passed as a
43
+ /// std::any to provide type erasure. Returns a MessageData containing the
44
+ /// serialized representation.
45
+ virtual MessageData serialize(const std::any &obj) const {
46
+ throw std::runtime_error("Serialization not implemented for type " + id);
47
+ }
48
+
49
+ /// Deserialize from a span of bytes to an object. Returns the deserialized
50
+ /// object as a std::any and a span to the remaining bytes.
51
+ virtual std::pair<std::any, std::span<const uint8_t>>
52
+ deserialize(std::span<const uint8_t> data) const {
53
+ throw std::runtime_error("Deserialization not implemented for type " + id);
54
+ }
55
+
56
+ /// Ensure that a std::any object is valid for this type. Throws
57
+ /// std::runtime_error if the object is not valid.
58
+ virtual void ensureValid(const std::any &obj) const {
59
+ throw std::runtime_error("Validation not implemented for type " + id);
60
+ }
61
+
62
+ // Check if a std::any object is valid for this type. Returns an optional
63
+ // error message if the object is not valid, else, std::nullopt.
64
+ std::optional<std::string> isValid(const std::any &obj) const {
65
+ try {
66
+ ensureValid(obj);
67
+ return std::nullopt;
68
+ } catch (const std::runtime_error &e) {
69
+ return e.what();
70
+ }
71
+ }
72
+
36
73
  protected:
37
74
  ID id;
38
75
  };
@@ -54,12 +91,7 @@ public:
54
91
  const ChannelVector &getChannels() const { return channels; }
55
92
  std::ptrdiff_t getBitWidth() const override { return -1; };
56
93
 
57
- std::pair<const Type *, Direction> findChannel(std::string name) const {
58
- for (auto [channelName, dir, type] : channels)
59
- if (channelName == name)
60
- return std::make_pair(type, dir);
61
- throw std::runtime_error("Channel '" + name + "' not found in bundle");
62
- }
94
+ std::pair<const Type *, Direction> findChannel(std::string name) const;
63
95
 
64
96
  protected:
65
97
  ChannelVector channels;
@@ -73,6 +105,11 @@ public:
73
105
  const Type *getInner() const { return inner; }
74
106
  std::ptrdiff_t getBitWidth() const override { return inner->getBitWidth(); };
75
107
 
108
+ void ensureValid(const std::any &obj) const override;
109
+ MessageData serialize(const std::any &obj) const override;
110
+ std::pair<std::any, std::span<const uint8_t>>
111
+ deserialize(std::span<const uint8_t> data) const override;
112
+
76
113
  private:
77
114
  const Type *inner;
78
115
  };
@@ -83,6 +120,11 @@ public:
83
120
  VoidType(const ID &id) : Type(id) {}
84
121
  // 'void' is 1 bit by convention.
85
122
  std::ptrdiff_t getBitWidth() const override { return 1; };
123
+
124
+ void ensureValid(const std::any &obj) const override;
125
+ MessageData serialize(const std::any &obj) const override;
126
+ std::pair<std::any, std::span<const uint8_t>>
127
+ deserialize(std::span<const uint8_t> data) const override;
86
128
  };
87
129
 
88
130
  /// The "any" type is a special type which can be used to represent any type, as
@@ -112,6 +154,11 @@ private:
112
154
  class BitsType : public BitVectorType {
113
155
  public:
114
156
  using BitVectorType::BitVectorType;
157
+
158
+ void ensureValid(const std::any &obj) const override;
159
+ MessageData serialize(const std::any &obj) const override;
160
+ std::pair<std::any, std::span<const uint8_t>>
161
+ deserialize(std::span<const uint8_t> data) const override;
115
162
  };
116
163
 
117
164
  /// Integers are bit vectors which may be signed or unsigned and are interpreted
@@ -125,12 +172,22 @@ public:
125
172
  class SIntType : public IntegerType {
126
173
  public:
127
174
  using IntegerType::IntegerType;
175
+
176
+ void ensureValid(const std::any &obj) const override;
177
+ MessageData serialize(const std::any &obj) const override;
178
+ std::pair<std::any, std::span<const uint8_t>>
179
+ deserialize(std::span<const uint8_t> data) const override;
128
180
  };
129
181
 
130
182
  /// Unsigned integer.
131
183
  class UIntType : public IntegerType {
132
184
  public:
133
185
  using IntegerType::IntegerType;
186
+
187
+ void ensureValid(const std::any &obj) const override;
188
+ MessageData serialize(const std::any &obj) const override;
189
+ std::pair<std::any, std::span<const uint8_t>>
190
+ deserialize(std::span<const uint8_t> data) const override;
134
191
  };
135
192
 
136
193
  /// Structs are an ordered collection of fields, each with a name and a type.
@@ -138,8 +195,8 @@ class StructType : public Type {
138
195
  public:
139
196
  using FieldVector = std::vector<std::pair<std::string, const Type *>>;
140
197
 
141
- StructType(const ID &id, const FieldVector &fields)
142
- : Type(id), fields(fields) {}
198
+ StructType(const ID &id, const FieldVector &fields, bool reverse = true)
199
+ : Type(id), fields(fields), reverse(reverse) {}
143
200
 
144
201
  const FieldVector &getFields() const { return fields; }
145
202
  std::ptrdiff_t getBitWidth() const override {
@@ -153,8 +210,21 @@ public:
153
210
  return size;
154
211
  }
155
212
 
213
+ void ensureValid(const std::any &obj) const override;
214
+ MessageData serialize(const std::any &obj) const override;
215
+ std::pair<std::any, std::span<const uint8_t>>
216
+ deserialize(std::span<const uint8_t> data) const override;
217
+
218
+ // Returns whether this struct type should be reversed when
219
+ // serializing/deserializing.
220
+ // By default, a truthy value here makes StructType's compatible with system
221
+ // verilog, which has reversed struct field ordering, wrt. C/software struct
222
+ // ordering.
223
+ bool isReverse() const { return reverse; }
224
+
156
225
  private:
157
226
  FieldVector fields;
227
+ bool reverse;
158
228
  };
159
229
 
160
230
  /// Arrays have a compile time specified (static) size and an element type.
@@ -172,6 +242,11 @@ public:
172
242
  return elementSize * size;
173
243
  }
174
244
 
245
+ void ensureValid(const std::any &obj) const override;
246
+ MessageData serialize(const std::any &obj) const override;
247
+ std::pair<std::any, std::span<const uint8_t>>
248
+ deserialize(std::span<const uint8_t> data) const override;
249
+
175
250
  private:
176
251
  const Type *elementType;
177
252
  uint64_t size;
esiaccel/types.py CHANGED
@@ -245,6 +245,8 @@ class StructType(ESIType):
245
245
  def is_valid(self, obj) -> Tuple[bool, Optional[str]]:
246
246
  fields_count = 0
247
247
  if not isinstance(obj, dict):
248
+ if not hasattr(obj, "__dict__"):
249
+ return (False, "must be a dict or have __dict__ attribute")
248
250
  obj = obj.__dict__
249
251
 
250
252
  for (fname, ftype) in self.fields:
@@ -260,14 +262,20 @@ class StructType(ESIType):
260
262
 
261
263
  def serialize(self, obj) -> bytearray:
262
264
  ret = bytearray()
263
- for (fname, ftype) in reversed(self.fields):
265
+ if not isinstance(obj, dict):
266
+ obj = obj.__dict__
267
+ ordered_fields = reversed(
268
+ self.fields) if self.cpp_type.reverse else self.fields
269
+ for (fname, ftype) in ordered_fields:
264
270
  fval = obj[fname]
265
271
  ret.extend(ftype.serialize(fval))
266
272
  return ret
267
273
 
268
274
  def deserialize(self, data: bytearray) -> Tuple[Dict[str, Any], bytearray]:
269
275
  ret = {}
270
- for (fname, ftype) in reversed(self.fields):
276
+ ordered_fields = reversed(
277
+ self.fields) if self.cpp_type.reverse else self.fields
278
+ for (fname, ftype) in ordered_fields:
271
279
  (fval, data) = ftype.deserialize(data)
272
280
  ret[fname] = fval
273
281
  return (ret, data)
esiaccel/utils.py CHANGED
@@ -40,5 +40,15 @@ def run_cppgen():
40
40
  return codegen.run()
41
41
 
42
42
 
43
- def get_cmake_dir():
43
+ def get_cmake_dir() -> Path:
44
44
  return _thisdir / "cmake"
45
+
46
+
47
+ def get_dll_dir() -> Path:
48
+ """Return the directory where the ESI dll's are located"""
49
+ import sys
50
+ import os
51
+ if sys.platform == "win32":
52
+ return _thisdir
53
+ else:
54
+ return _thisdir / "lib"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: esiaccel
3
- Version: 0.1.5.dev93
3
+ Version: 0.1.5.dev107
4
4
  Summary: ESI accelerators runtime
5
5
  Author-email: John Demme <John.Demme@microsoft.com>
6
6
  License: ==============================================================================
@@ -1,19 +1,19 @@
1
- esiaccel/CosimBackend.dll,sha256=ozoEzvXMWeOlk_1H-52BFZIjvubx-RhniL58MPWhmfs,7150592
2
- esiaccel/CosimBackend.lib,sha256=5-p0KcNVY5sy5f3H59i2V6w-jXAiy_eVBrXLki3GuAY,4991546
3
- esiaccel/ESICppRuntime.dll,sha256=LnwmG1RadcFSQSxFYjuMmlvVBlRq4L7u_DZFopK-JRs,3721728
4
- esiaccel/ESICppRuntime.lib,sha256=PhqlDlxNWjShXt4I58b5VgrerTgIG9DQU787cVqxh30,14530116
5
- esiaccel/EsiCosimDpiServer.dll,sha256=BD0cUT2uiQv4jUl4IC4Uju1x6DvLQGyrbqHoUQqDBaA,159744
1
+ esiaccel/CosimBackend.dll,sha256=0veW9ijJLlvlM-VPVlxNTxrqd26Ny47gBBIpRBLbASg,7152128
2
+ esiaccel/CosimBackend.lib,sha256=UjflmgR93Kl22Du0lTqGhXWQqWEF-V8VwcqUuFo8GNk,4992924
3
+ esiaccel/ESICppRuntime.dll,sha256=dxcVfC7bm9J__GZVlI9Y_9WIItmSuWxjM4L49q4Lt1Q,4072448
4
+ esiaccel/ESICppRuntime.lib,sha256=zpBXrDVpgUYN8m56gh-qEpMMCgp3C9nOB_1GqKyKDAs,15137922
5
+ esiaccel/EsiCosimDpiServer.dll,sha256=CM-2qznORdac-33xo31lpwnPMJhZrzU48N8nX_ki4fA,159744
6
6
  esiaccel/EsiCosimDpiServer.lib,sha256=bYBigD0RtRRSEiDxf4_gvpasLjD8fcUmC0CjRgQiQ0s,604164
7
- esiaccel/MtiPli.dll,sha256=kZzylUcjHJQ6FB224YnjDTTpdGAfTwQhbpcm8WQz-cg,14848
7
+ esiaccel/MtiPli.dll,sha256=K6fBPe8Qu4MtFoq4iSBPjO0DESRcgPlCO0M7VkGbWSc,14848
8
8
  esiaccel/MtiPli.lib,sha256=X0PcXwheCUvBMgQ5BAawePxbXQSLNk5M1FFn6V56ydo,14570
9
- esiaccel/__init__.py,sha256=C0GLqCQuF5g5qTzmAkf_YAHmBV2XAyiJad3Qz7h8u1g,562
9
+ esiaccel/__init__.py,sha256=65xXWHwJwRePsyhWk837NpzuN0qsNhoAX29TOiSYKGc,905
10
10
  esiaccel/accelerator.py,sha256=BcXPsUqcQV3YsVVyYbz9P6JnZLlcnuageFbJwID9_3s,3318
11
11
  esiaccel/codegen.py,sha256=uoYELtnIabVvgLeCABj-mWras0BvmSKABPH-cd9nDFk,6560
12
12
  esiaccel/esi-cosim.py,sha256=GwYfNh4aagypheAhGf0EIX6ojkLYKkc5OMlFR9pfXe8,14381
13
- esiaccel/esiCppAccel.cp310-win_amd64.pyd,sha256=36UECYviqC8s5B8puXz8eClZ6XF6BLxAYV-T7yjsaFc,496128
14
- esiaccel/esiquery.exe,sha256=0FC3KdBHplJlHgI6rsc-KM7uq_HdC99DLR4GY4iHcQc,441856
15
- esiaccel/types.py,sha256=LtBYmpmSBlzbB-f_4XqcptmseqI6Q0ibnNWJT3G-GI8,18696
16
- esiaccel/utils.py,sha256=0_A8Jw3M7mjvjTHeV6u00tvRWxLnWKdFq_6NFKTgbVk,1296
13
+ esiaccel/esiCppAccel.cp310-win_amd64.pyd,sha256=GFB_ibSo-ZfG73aNoH93hUW8kdlZQxq6lKrhQYwhl6c,500224
14
+ esiaccel/esiquery.exe,sha256=rGKSf8l-bEruBCe_kM5XCu2_zKID_9iyaJp5f3NCFXM,441856
15
+ esiaccel/types.py,sha256=LFLzUCvtYF6FLsmKet6eJTMq2ija2Z5kxd5Ks6tkS4U,19044
16
+ esiaccel/utils.py,sha256=q-8fmgJ9tUvmBsIvqZiZ7u845IJhOjvjYTQLhhrNYl0,1515
17
17
  esiaccel/cmake/esiaccelConfig.cmake,sha256=u2aW99k1lEcmYTG1P3BTJqtmDrj53wUUaBz_jzw8kYY,565
18
18
  esiaccel/cosim/Cosim_DpiPkg.sv,sha256=9qGn1VyAVrzBP5At1thV6xrovg0WghICD01Zz9J221E,3458
19
19
  esiaccel/cosim/Cosim_Endpoint.sv,sha256=ri1fHdkiphe8S2-vm6Ru16rBGYiDiS1c8qeCAsl1diU,6498
@@ -22,7 +22,7 @@ esiaccel/cosim/driver.cpp,sha256=DrEKkSN7Y_Hu7wcaUulH5mbC2L4yB9xLClRMeRUpzHM,384
22
22
  esiaccel/cosim/driver.sv,sha256=ro-j9GM164A1W0MDPkqYfEn3TUKHSqVvgjO31fnloQI,1428
23
23
  esiaccel/include/esi/Accelerator.h,sha256=RhkZ2HeMZ0iHc5BkHdDWXoeg9J9lyPQciH5bWq5Qc_w,9772
24
24
  esiaccel/include/esi/CLI.h,sha256=Nn8tHn_xtEfkrD7USE2tao6ktYOJ6xcbnhZkS9-ox0A,2540
25
- esiaccel/include/esi/Common.h,sha256=pR2cqBEgKRYeJsHatjE7MC5WAw9SGbcO-JOyIGjIwF8,5503
25
+ esiaccel/include/esi/Common.h,sha256=IGJvAU72dlearXFbSmlXFFriy8aomirp7opEBjgewek,5775
26
26
  esiaccel/include/esi/Context.h,sha256=Tk_4nBDtTeVY62GfX4Cs_ZMIQstjSgrWHddN_PKANEA,2396
27
27
  esiaccel/include/esi/Design.h,sha256=mU8OwpCYijiWSdDq17l45LMzZxBca93nosudWCXNHfQ,4922
28
28
  esiaccel/include/esi/Engines.h,sha256=bbGbhXjYMpIpXh_DR0OS57zyGQUIDXh_S7xHX3su0Y0,4831
@@ -30,14 +30,14 @@ esiaccel/include/esi/Logging.h,sha256=sHqMcpp0lNIHkIEyvSm-BBWx4zXXh6NOATCgZpgzYI
30
30
  esiaccel/include/esi/Manifest.h,sha256=j3v9UA0ogtJQBlv6k5s4j_3sCsq-gwF9btVg5dKTBlg,2244
31
31
  esiaccel/include/esi/Ports.h,sha256=T2WbPBViUSvFbO5Jjxlcp_eGq9jMitguvNnz3O0564U,10543
32
32
  esiaccel/include/esi/Services.h,sha256=H7Iq3F3LivSZHblFJmrC8RAU_MftfKAPDtyGBfJ2nP4,14815
33
- esiaccel/include/esi/Types.h,sha256=P4ExO8-zvm7qQocUmkM_ATIvamxtDZ8JT2ToLkFo1dk,5483
33
+ esiaccel/include/esi/Types.h,sha256=zAwdD24BtXFXMBNCkEy59pQ0r_NLM4GyxqIgjWuQ6ac,8675
34
34
  esiaccel/include/esi/Utils.h,sha256=KPd75GajIFeTBVJocXBjwsJqhbZg-ShWZCIe3oQdBss,3061
35
35
  esiaccel/include/esi/backends/Cosim.h,sha256=s7vYd0ra6m1nvk-n37MjvBoGVI-CCUKBt0DU4PKlaHM,2838
36
36
  esiaccel/include/esi/backends/RpcServer.h,sha256=WMwnhwU2qnrcglGNeiKg9QQHpkDx1QE1JydKYDK4jqE,1856
37
37
  esiaccel/include/esi/backends/Trace.h,sha256=kx4wwLH3a0ndmRUdaDyYGZ1SP83zlpFrk30Nw8ZrJJA,3286
38
- esiaccel-0.1.5.dev93.dist-info/licenses/LICENSE,sha256=vtnVnB8_lN1yPYcA5MeT56R8UsQtBhyzZLBvu_KMf7I,13468
39
- esiaccel-0.1.5.dev93.dist-info/METADATA,sha256=54v_sDwTnOYIdAn_OsDKFrbXthsDYxQWTIDcbfa15vE,16147
40
- esiaccel-0.1.5.dev93.dist-info/WHEEL,sha256=KUuBC6lxAbHCKilKua8R9W_TM71_-9Sg5uEP3uDWcoU,101
41
- esiaccel-0.1.5.dev93.dist-info/entry_points.txt,sha256=_CuNLV0fyTURxRREFwpzGycifZW_-7-MyuJNEwKK9J8,137
42
- esiaccel-0.1.5.dev93.dist-info/top_level.txt,sha256=fYWTWMDK4PDu4ePQ9NtcFHas2k8-d1kWhTs2avPpgB4,9
43
- esiaccel-0.1.5.dev93.dist-info/RECORD,,
38
+ esiaccel-0.1.5.dev107.dist-info/licenses/LICENSE,sha256=vtnVnB8_lN1yPYcA5MeT56R8UsQtBhyzZLBvu_KMf7I,13468
39
+ esiaccel-0.1.5.dev107.dist-info/METADATA,sha256=vVWw_5dsXSxjz0I_apI9ldCbqYQdzYCLAyQmi7VAtx0,16148
40
+ esiaccel-0.1.5.dev107.dist-info/WHEEL,sha256=KUuBC6lxAbHCKilKua8R9W_TM71_-9Sg5uEP3uDWcoU,101
41
+ esiaccel-0.1.5.dev107.dist-info/entry_points.txt,sha256=_CuNLV0fyTURxRREFwpzGycifZW_-7-MyuJNEwKK9J8,137
42
+ esiaccel-0.1.5.dev107.dist-info/top_level.txt,sha256=fYWTWMDK4PDu4ePQ9NtcFHas2k8-d1kWhTs2avPpgB4,9
43
+ esiaccel-0.1.5.dev107.dist-info/RECORD,,