Skip to content

[ESI][Runtime] Cosim test for multiple outstanding HostMem reads - #11284

Closed
teqdruid wants to merge 3 commits into
mainfrom
dev/teqdruid/esi/hostmem-read-cosim-test
Closed

teqdruid wants to merge 3 commits into
mainfrom
dev/teqdruid/esi/hostmem-read-cosim-test

Conversation

@teqdruid

Copy link
Copy Markdown
Contributor

Stacked on #11282 and #11283. Please review only the last commit, "Cosim test for multiple outstanding HostMem reads". The first two commits are those PRs, and this one will be rebased once they land.

This adds a cosim test that holds several logical reads in flight inside HostMemReadReqSplitter and checks the responses.

hw/hostmem_read.py builds, under CosimBSP(max_outstanding_reads=N), one host-driven read_list client per element width: 24, 32 and 96 bits, i.e. 3-, 4- and 12-byte strides over the 8-byte cosim host memory word. Each client has:

  • a response gate;
  • an accepted telemetry counter;
  • request and response channels.

test_hostmem_read.py runs with N = 1 and N = 4. For each width, it:

  1. calls HostMem.start() and closes the response gate;
  2. queues several reads of varied lengths;
  3. checks that exactly min(#reads, N) are accepted while nothing drains;
  4. opens the gate and checks every returned element, the per-request element counts, and that last lands exactly on each request's final element;
  5. streams short reads back to back and checks them the same way.

teqdruid and others added 3 commits October 10, 2026 01:07
`HostMemReadReqSplitter` accepted one logical read request and refused the
next until every response word of the current one had drained, capping each
read client at one request per host round trip.

Add an optional `max_outstanding` parameter (default 1, unchanged behavior).
Each accepted request's {word count - 1, final-word valid bytes, single-word}
is queued in a metadata FIFO of that depth; the response framer loads each
burst's metadata into registers from the FIFO head (or directly from a request
accepted while the FIFO is empty and the framer idle, so no latency is added)
and re-derives `last` / `valid_bytes` from them. Requires the upstream to
return each splitter's response words in request order; tags still pass
through untouched.

- A single-chunk request can be accepted every cycle (the next request is
  accepted in the cycle the previous one issues its final chunk); responses
  flow one word per cycle with no bubble between bursts.
- No combinational path from `resp_in` to `req_in` ready: the in-flight limit
  is a registered flag. `resp_in` ready is left ungated, since
  `esi.TaggedDemux` ANDs every output's ready.
- The final-chunk test is registered and the address/length advance by a
  constant chunk; datapath registers are not reset.

Plumb the limit through `HostmemReadProcessor` and `ChannelHostMem` as
`max_outstanding_reads` (default 1). `CosimBSP`/`CosimBSP_DMA` take it too and
default to 4: the cosim host answers reads in order, and it keeps the feature
exercised by every cosim test.

Tests: IR-only generation tests for widths 64/256 and max_outstanding 1/2/64,
and a check that max_outstanding=0 is rejected. A cosim test that holds
requests in flight and checks the responses follows separately.

Co-authored-by: Copilot <[email protected]>
`HostMem::start()` enables the host memory service on backends which need it
(cosim registers its read/write request handlers there), but it was not bound
in Python, so Python code could not enable host memory before the accelerator
used it. Bind it, and call it from the loopback cosim test.

Co-authored-by: Copilot <[email protected]>
`hw/hostmem_read.py` builds, under `CosimBSP(max_outstanding_reads=N)`, one
host-driven `read_list` client per element width (24, 32 and 96 bits, i.e.
3-, 4- and 12-byte strides over the 8-byte cosim host memory word). Each
client has a response gate, an `accepted` telemetry counter, and request and
response channels.

The test closes the response gate, queues several reads of varied lengths,
checks that exactly min(#reads, N) are accepted while nothing drains (so that
many logical requests are genuinely in flight inside
`HostMemReadReqSplitter`), then opens the gate and checks every returned
element, the per-request element counts and that `last` lands exactly on each
request's final element. It then streams short reads back to back. It runs
with N = 1 and N = 4.

Co-authored-by: Copilot <[email protected]>
@teqdruid

Copy link
Copy Markdown
Contributor Author

Folded into #11282, now that #11283 has merged.

@teqdruid teqdruid closed this Oct 13, 2026
@teqdruid
teqdruid deleted the dev/teqdruid/esi/hostmem-read-cosim-test branch October 13, 2026 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant