esiaccel 0.1.5.dev138__cp313-cp313-win_amd64.whl → 0.1.5.dev163__cp313-cp313-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
Binary file
Binary file
esiaccel/MtiPli.dll CHANGED
Binary file
@@ -9,6 +9,8 @@
9
9
  // Package: Cosim_DpiPkg
10
10
  //
11
11
  // Main cosim <--> dpi bridge module.
12
+
13
+
12
14
  //
13
15
  //===----------------------------------------------------------------------===//
14
16
 
@@ -118,9 +120,8 @@ module Cosim_Endpoint_FromHost
118
120
  $error("Cosim endpoint (%s) register failed: %d", ENDPOINT_ID, rc);
119
121
  end
120
122
 
121
- /// *******************
122
- /// Data out management.
123
- ///
123
+ /// ***********************
124
+ /// Useful constants.
124
125
 
125
126
  localparam int FROM_HOST_SIZE_BYTES = int'((FROM_HOST_SIZE_BITS+7)/8);
126
127
  // The number of bits over a byte.
@@ -129,13 +130,30 @@ module Cosim_Endpoint_FromHost
129
130
  localparam int FROM_HOST_SIZE_BYTES_FLOOR_IN_BITS
130
131
  = FROM_HOST_SIZE_BYTES_FLOOR * 8;
131
132
 
133
+ // Buffer to hold incoming data directly from the DPI calls.
132
134
  byte unsigned DataOutBuffer[FROM_HOST_SIZE_BYTES-1:0];
135
+
136
+ // Pipeline interface signals for buffering DataOut.
137
+ // DataOut_a_valid is asserted when a complete message is available in
138
+ // DataOut_a buffer and waiting to be accepted by the skid buffer.
139
+ logic DataOut_a_valid;
140
+ // Packed representation of the byte buffer to feed the skid input.
141
+ logic [FROM_HOST_SIZE_BITS-1:0] DataOut_a;
142
+ // Ready/valid wires between this module and the skid buffer.
143
+ wire DataOut_a_ready;
144
+ wire DataOut_x_valid;
145
+ wire [FROM_HOST_SIZE_BITS-1:0] DataOut_x;
146
+
133
147
  always @(posedge clk) begin
134
148
  if (~rst) begin
135
- if (DataOutValid && DataOutReady) // A transfer occurred.
136
- DataOutValid <= 1'b0;
137
-
138
- if (!DataOutValid || DataOutReady) begin
149
+ // If the skid buffer accepted the input token this cycle, clear the
150
+ // internal valid that indicates we have buffered data.
151
+ if (DataOut_a_valid && DataOut_a_ready)
152
+ DataOut_a_valid <= 1'b0;
153
+
154
+ // Only attempt to fetch data from the host when the skid buffer can
155
+ // accept it (DataOut_a_ready).
156
+ if (!DataOut_a_valid && DataOut_a_ready) begin
139
157
  int data_limit;
140
158
  int rc;
141
159
 
@@ -149,7 +167,7 @@ module Cosim_Endpoint_FromHost
149
167
  ENDPOINT_ID, FROM_HOST_SIZE_BYTES, data_limit, rc);
150
168
  end else if (rc == 0) begin
151
169
  if (data_limit == FROM_HOST_SIZE_BYTES)
152
- DataOutValid <= 1'b1;
170
+ DataOut_a_valid <= 1'b1;
153
171
  else if (data_limit == 0)
154
172
  begin end // No message.
155
173
  else
@@ -159,24 +177,53 @@ module Cosim_Endpoint_FromHost
159
177
  end
160
178
  end
161
179
  end else begin
162
- DataOutValid <= 1'b0;
180
+ DataOut_a_valid <= 1'b0;
163
181
  end
164
182
  end
165
183
 
166
- // Assign packed output bit array from unpacked byte array.
184
+ // Pack the byte array into a single vector that will be handed to the
185
+ // skid buffer as its input payload.
167
186
  genvar iOut;
168
187
  generate
169
188
  for (iOut=0; iOut<FROM_HOST_SIZE_BYTES_FLOOR; iOut++)
170
- assign DataOut[((iOut+1)*8)-1:iOut*8] = DataOutBuffer[iOut];
189
+ assign DataOut_a[((iOut+1)*8)-1:iOut*8] = DataOutBuffer[iOut];
171
190
  if (FROM_HOST_SIZE_BITS_DIFF != 0)
172
- // If the type is not a multiple of 8, we've got to copy the extra bits.
173
- assign DataOut[(FROM_HOST_SIZE_BYTES_FLOOR_IN_BITS +
174
- FROM_HOST_SIZE_BITS_DIFF - 1) :
175
- FROM_HOST_SIZE_BYTES_FLOOR_IN_BITS]
191
+ // If the type is not a multiple of 8, copy the extra bits.
192
+ assign DataOut_a[(FROM_HOST_SIZE_BYTES_FLOOR_IN_BITS +
193
+ FROM_HOST_SIZE_BITS_DIFF - 1) :
194
+ FROM_HOST_SIZE_BYTES_FLOOR_IN_BITS]
176
195
  = DataOutBuffer[FROM_HOST_SIZE_BYTES - 1]
177
196
  [FROM_HOST_SIZE_BITS_DIFF - 1 : 0];
178
197
  endgenerate
179
198
 
199
+ /// *******************
200
+ /// Data out management.
201
+ ///
202
+ /// It has been observed that some simulators (verilator) does not handle
203
+ /// combinational driving from DPI well (resulting in non-determinism wrt
204
+ /// some of the combinational outputs being dropped/replicated). Questa does
205
+ /// not show this behavior.
206
+ /// A mitigation is to add a skid buffer to decouple the DPI interface
207
+ /// from the output interface.
208
+
209
+ // Instantiate a single-stage pipeline to buffer tokens that arrive from
210
+ // the host and present them to the module's output with proper
211
+ // ready/valid handshaking.
212
+ ESI_PipelineStage #(.WIDTH(FROM_HOST_SIZE_BITS)) out_pipe (
213
+ .clk(clk),
214
+ .rst(rst),
215
+ .a_valid(DataOut_a_valid),
216
+ .a(DataOut_a),
217
+ .a_ready(DataOut_a_ready),
218
+ .x_valid(DataOut_x_valid),
219
+ .x(DataOut_x),
220
+ .x_ready(DataOutReady)
221
+ );
222
+
223
+ // Drive the module's outward-facing signals from the pipeline output.
224
+ assign DataOutValid = DataOut_x_valid;
225
+ assign DataOut = DataOut_x;
226
+
180
227
  initial begin
181
228
  $display("FROM_HOST_SIZE_BITS: %d", FROM_HOST_SIZE_BITS);
182
229
  $display("FROM_HOST_SIZE_BYTES: %d", FROM_HOST_SIZE_BYTES);
esiaccel/esi-cosim.py CHANGED
@@ -82,6 +82,24 @@ class SourceFiles:
82
82
  return self.dpi_sv + self.user
83
83
 
84
84
 
85
+ class SimProcess:
86
+
87
+ def __init__(self, proc: subprocess.Popen, port: int):
88
+ self.proc = proc
89
+ self.port = port
90
+
91
+ def force_stop(self):
92
+ """Make sure to stop the simulation no matter what."""
93
+ if self.proc:
94
+ os.killpg(os.getpgid(self.proc.pid), signal.SIGINT)
95
+ # Allow the simulation time to flush its outputs.
96
+ try:
97
+ self.proc.wait(timeout=1.0)
98
+ except subprocess.TimeoutExpired:
99
+ # If the simulation doesn't exit of its own free will, kill it.
100
+ self.proc.kill()
101
+
102
+
85
103
  class Simulator:
86
104
 
87
105
  # Some RTL simulators don't use stderr for error messages. Everything goes to
@@ -135,6 +153,65 @@ class Simulator:
135
153
  """Return the command to run the simulation."""
136
154
  assert False, "Must be implemented by subclass"
137
155
 
156
+ def run_proc(self, gui: bool = False) -> SimProcess:
157
+ """Run the simulation process. Returns the Popen object and the port which
158
+ the simulation is listening on."""
159
+ # Open log files
160
+ self.run_dir.mkdir(parents=True, exist_ok=True)
161
+ simStdout = open(self.run_dir / "sim_stdout.log", "w")
162
+ simStderr = open(self.run_dir / "sim_stderr.log", "w")
163
+
164
+ # Erase the config file if it exists. We don't want to read
165
+ # an old config.
166
+ portFileName = self.run_dir / "cosim.cfg"
167
+ if os.path.exists(portFileName):
168
+ os.remove(portFileName)
169
+
170
+ # Run the simulation.
171
+ simEnv = Simulator.get_env()
172
+ if self.debug:
173
+ simEnv["COSIM_DEBUG_FILE"] = "cosim_debug.log"
174
+ if "DEBUG_PERIOD" not in simEnv:
175
+ # Slow the simulation down to one tick per millisecond.
176
+ simEnv["DEBUG_PERIOD"] = "1"
177
+ rcmd = self.run_command(gui)
178
+ simProc = subprocess.Popen(self.run_command(gui),
179
+ stdout=simStdout,
180
+ stderr=simStderr,
181
+ env=simEnv,
182
+ cwd=self.run_dir,
183
+ preexec_fn=os.setsid)
184
+ simStderr.close()
185
+ simStdout.close()
186
+
187
+ # Get the port which the simulation RPC selected.
188
+ checkCount = 0
189
+ while (not os.path.exists(portFileName)) and \
190
+ simProc.poll() is None:
191
+ time.sleep(0.1)
192
+ checkCount += 1
193
+ if checkCount > 500 and not gui:
194
+ raise Exception(f"Cosim never wrote cfg file: {portFileName}")
195
+ port = -1
196
+ while port < 0:
197
+ portFile = open(portFileName, "r")
198
+ for line in portFile.readlines():
199
+ m = re.match("port: (\\d+)", line)
200
+ if m is not None:
201
+ port = int(m.group(1))
202
+ portFile.close()
203
+
204
+ # Wait for the simulation to start accepting RPC connections.
205
+ checkCount = 0
206
+ while not is_port_open(port):
207
+ checkCount += 1
208
+ if checkCount > 200:
209
+ raise Exception(f"Cosim RPC port ({port}) never opened")
210
+ if simProc.poll() is not None:
211
+ raise Exception("Simulation exited early")
212
+ time.sleep(0.05)
213
+ return SimProcess(proc=simProc, port=port)
214
+
138
215
  def run(self,
139
216
  inner_command: str,
140
217
  gui: bool = False,
@@ -146,83 +223,23 @@ class Simulator:
146
223
  # syntax errors in that block.
147
224
  simProc = None
148
225
  try:
149
- # Open log files
150
- self.run_dir.mkdir(parents=True, exist_ok=True)
151
- simStdout = open(self.run_dir / "sim_stdout.log", "w")
152
- simStderr = open(self.run_dir / "sim_stderr.log", "w")
153
-
154
- # Erase the config file if it exists. We don't want to read
155
- # an old config.
156
- portFileName = self.run_dir / "cosim.cfg"
157
- if os.path.exists(portFileName):
158
- os.remove(portFileName)
159
-
160
- # Run the simulation.
161
- simEnv = Simulator.get_env()
162
- if self.debug:
163
- simEnv["COSIM_DEBUG_FILE"] = "cosim_debug.log"
164
- if "DEBUG_PERIOD" not in simEnv:
165
- # Slow the simulation down to one tick per millisecond.
166
- simEnv["DEBUG_PERIOD"] = "1"
167
- simProc = subprocess.Popen(self.run_command(gui),
168
- stdout=simStdout,
169
- stderr=simStderr,
170
- env=simEnv,
171
- cwd=self.run_dir,
172
- preexec_fn=os.setsid)
173
- simStderr.close()
174
- simStdout.close()
175
-
176
- # Get the port which the simulation RPC selected.
177
- checkCount = 0
178
- while (not os.path.exists(portFileName)) and \
179
- simProc.poll() is None:
180
- time.sleep(0.1)
181
- checkCount += 1
182
- if checkCount > 200 and not gui:
183
- raise Exception(f"Cosim never wrote cfg file: {portFileName}")
184
- port = -1
185
- while port < 0:
186
- portFile = open(portFileName, "r")
187
- for line in portFile.readlines():
188
- m = re.match("port: (\\d+)", line)
189
- if m is not None:
190
- port = int(m.group(1))
191
- portFile.close()
192
-
193
- # Wait for the simulation to start accepting RPC connections.
194
- checkCount = 0
195
- while not is_port_open(port):
196
- checkCount += 1
197
- if checkCount > 200:
198
- raise Exception(f"Cosim RPC port ({port}) never opened")
199
- if simProc.poll() is not None:
200
- raise Exception("Simulation exited early")
201
- time.sleep(0.05)
202
-
226
+ simProc = self.run_proc(gui=gui)
203
227
  if server_only:
204
228
  # wait for user input to kill the server
205
229
  input(
206
- f"Running in server-only mode on port {port} - Press anything to kill the server..."
230
+ f"Running in server-only mode on port {simProc.port} - Press anything to kill the server..."
207
231
  )
208
232
  return 0
209
233
  else:
210
234
  # Run the inner command, passing the connection info via environment vars.
211
235
  testEnv = os.environ.copy()
212
- testEnv["ESI_COSIM_PORT"] = str(port)
236
+ testEnv["ESI_COSIM_PORT"] = str(simProc.port)
213
237
  testEnv["ESI_COSIM_HOST"] = "localhost"
214
238
  return subprocess.run(inner_command, cwd=os.getcwd(),
215
239
  env=testEnv).returncode
216
240
  finally:
217
- # Make sure to stop the simulation no matter what.
218
241
  if simProc:
219
- os.killpg(os.getpgid(simProc.pid), signal.SIGINT)
220
- # Allow the simulation time to flush its outputs.
221
- try:
222
- simProc.wait(timeout=1.0)
223
- except subprocess.TimeoutExpired:
224
- # If the simulation doesn't exit of its own free will, kill it.
225
- simProc.kill()
242
+ simProc.force_stop()
226
243
 
227
244
 
228
245
  class Verilator(Simulator):
@@ -247,8 +264,11 @@ class Verilator(Simulator):
247
264
  "-Wno-TIMESCALEMOD",
248
265
  "-Wno-fatal",
249
266
  "-sv",
250
- "--build",
251
267
  "--exe",
268
+ "--build",
269
+ "-j",
270
+ "0",
271
+ "--output-split",
252
272
  "--assert",
253
273
  str(Verilator.DefaultDriver),
254
274
  ]
Binary file
esiaccel/esiquery.exe CHANGED
Binary file
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: esiaccel
3
- Version: 0.1.5.dev138
3
+ Version: 0.1.5.dev163
4
4
  Summary: ESI accelerators runtime
5
5
  Author-email: John Demme <John.Demme@microsoft.com>
6
6
  License: ==============================================================================
@@ -1,22 +1,22 @@
1
- esiaccel/CosimBackend.dll,sha256=wde-KSetQ_kLivkwaz2QZojox23PltB56S98L-K1hwE,7152128
1
+ esiaccel/CosimBackend.dll,sha256=tluLZykVh08ULYF-jlZJzND_NIgETI2RSMso4TwrKT0,7152128
2
2
  esiaccel/CosimBackend.lib,sha256=UjflmgR93Kl22Du0lTqGhXWQqWEF-V8VwcqUuFo8GNk,4992924
3
- esiaccel/ESICppRuntime.dll,sha256=eqVIWzyibawtNVr3IU8wuHDn4Ou1WGMkjDyugddc3L0,4078592
3
+ esiaccel/ESICppRuntime.dll,sha256=zXaoMVYtpCEfxAb304cwTzptTADyXlDxxY6WoqbLynM,4078592
4
4
  esiaccel/ESICppRuntime.lib,sha256=iGJtktQywYhQCody90jvprSYC7kB9LWt3LEX5yIGEkM,15154004
5
- esiaccel/EsiCosimDpiServer.dll,sha256=7rhUY6s7vN04EW18DbRfLaYjc4pJfMmeJiZmI-9Aqiw,159744
5
+ esiaccel/EsiCosimDpiServer.dll,sha256=JOp6ThE_y7VSo9YrI5X3RFNsTteieP9-NTwGRmGzJlk,159744
6
6
  esiaccel/EsiCosimDpiServer.lib,sha256=bYBigD0RtRRSEiDxf4_gvpasLjD8fcUmC0CjRgQiQ0s,604164
7
- esiaccel/MtiPli.dll,sha256=SG3AJtLGHG6t6QlWQDEzfKBAGykuXKSn-8jZRjSEmWA,14848
7
+ esiaccel/MtiPli.dll,sha256=yj9Mwa8hMbpYMYqt6eOissa99wtQ7gn_g4gnGn7vO8U,14848
8
8
  esiaccel/MtiPli.lib,sha256=X0PcXwheCUvBMgQ5BAawePxbXQSLNk5M1FFn6V56ydo,14570
9
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
- esiaccel/esi-cosim.py,sha256=GwYfNh4aagypheAhGf0EIX6ojkLYKkc5OMlFR9pfXe8,14381
13
- esiaccel/esiCppAccel.cp313-win_amd64.pyd,sha256=YtEbmof0UAdO4FccGknyvqAgH6T9gIWFnsLTucwy1Ec,510976
14
- esiaccel/esiquery.exe,sha256=-GvmCGvb94CkMGDuO0KAJIO0x3AKWxj0evmWsIsMLe4,441856
12
+ esiaccel/esi-cosim.py,sha256=Z8gBKNr4iWtrokBLd2xym9ClwsFP0kQNRCnjMRfytcY,14852
13
+ esiaccel/esiCppAccel.cp313-win_amd64.pyd,sha256=EpCMBwO8_SnfxK8xWx61JsnIkDasDh14zdeP5_Qq_IE,510976
14
+ esiaccel/esiquery.exe,sha256=sFRe_IuJx04LhxgTIIe55yq01_RfczDa25dIZno9QeU,441856
15
15
  esiaccel/types.py,sha256=LFLzUCvtYF6FLsmKet6eJTMq2ija2Z5kxd5Ks6tkS4U,19044
16
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
- esiaccel/cosim/Cosim_Endpoint.sv,sha256=ri1fHdkiphe8S2-vm6Ru16rBGYiDiS1c8qeCAsl1diU,6498
19
+ esiaccel/cosim/Cosim_Endpoint.sv,sha256=2F7UQYWavUlWx7Iqi_6iawn5geZRPG96H8rDBBDRAQ0,8391
20
20
  esiaccel/cosim/Cosim_Manifest.sv,sha256=vl9b6XieEkP880IBw1ferekBnDJwFanZZggJJGertXM,1123
21
21
  esiaccel/cosim/driver.cpp,sha256=DrEKkSN7Y_Hu7wcaUulH5mbC2L4yB9xLClRMeRUpzHM,3842
22
22
  esiaccel/cosim/driver.sv,sha256=ro-j9GM164A1W0MDPkqYfEn3TUKHSqVvgjO31fnloQI,1428
@@ -35,9 +35,9 @@ esiaccel/include/esi/Utils.h,sha256=KPd75GajIFeTBVJocXBjwsJqhbZg-ShWZCIe3oQdBss,
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.dev138.dist-info/licenses/LICENSE,sha256=vtnVnB8_lN1yPYcA5MeT56R8UsQtBhyzZLBvu_KMf7I,13468
39
- esiaccel-0.1.5.dev138.dist-info/METADATA,sha256=YQqAggLDdoG1ATE0w2j-xfAXui1Bw-luzvKtRRlPnzw,16148
40
- esiaccel-0.1.5.dev138.dist-info/WHEEL,sha256=qV0EIPljj1XC_vuSatRWjn02nZIz3N1t8jsZz7HBr2U,101
41
- esiaccel-0.1.5.dev138.dist-info/entry_points.txt,sha256=_CuNLV0fyTURxRREFwpzGycifZW_-7-MyuJNEwKK9J8,137
42
- esiaccel-0.1.5.dev138.dist-info/top_level.txt,sha256=fYWTWMDK4PDu4ePQ9NtcFHas2k8-d1kWhTs2avPpgB4,9
43
- esiaccel-0.1.5.dev138.dist-info/RECORD,,
38
+ esiaccel-0.1.5.dev163.dist-info/licenses/LICENSE,sha256=vtnVnB8_lN1yPYcA5MeT56R8UsQtBhyzZLBvu_KMf7I,13468
39
+ esiaccel-0.1.5.dev163.dist-info/METADATA,sha256=ghDk1XHfRI5GwmYRAW9aWvWpO3HcAE5he_FeHu2NtNk,16148
40
+ esiaccel-0.1.5.dev163.dist-info/WHEEL,sha256=qV0EIPljj1XC_vuSatRWjn02nZIz3N1t8jsZz7HBr2U,101
41
+ esiaccel-0.1.5.dev163.dist-info/entry_points.txt,sha256=_CuNLV0fyTURxRREFwpzGycifZW_-7-MyuJNEwKK9J8,137
42
+ esiaccel-0.1.5.dev163.dist-info/top_level.txt,sha256=fYWTWMDK4PDu4ePQ9NtcFHas2k8-d1kWhTs2avPpgB4,9
43
+ esiaccel-0.1.5.dev163.dist-info/RECORD,,