Repository navigation
[TOGSim] Spad buffer sizes come from the producer (trace ABI 15); semaphore refusals pinned by name - #324
Merged
Conversation
…As that fill it Trace ABI 15. A producer exports togsim_spad_buffer_count and togsim_spad_buffer_bytes[]: the byte size of every buffer id its read_bufs/write_bufs name (0 for an id that is no spad buffer). The loader refuses a producer that states none, and the bridge refuses a DMA'd buffer whose stated size is missing or 0. sram_schedule() no longer sums the bytes of the DMAs filling or draining one version. That sum over-counted every buffer stored more than once in a version: a store leaves the version open, so each later store of the same tile added its bytes again. A tile stored to two tensors counted twice, a state stored on each of N trips counted N times, and when the sum passed the spad, try_occupy_sram never succeeded and the simulator never ended. The compiler allocated the buffer and knows its size; TOGSim reads it instead of deriving it a second time. tests/sram_pieces gains three producers, each failing on 05c2d47: producer 05c2d47 footprint now twostore 49152 32768 runstate 65536 (max_dispatch 1) 16384 (max_dispatch 2) computestate 81920, no end (timeout) 32768, ends and unsized_producer (a too-short table, no table) for the two refusals. pieces and scatter keep 32768 and 16640. Every test producer states its sizes. run_pieces.sh writes the trace_tensors.txt TOGSim has required beside the .so since the packed tensor layout (d91215e); without it both sram_pieces cases already failed on 05c2d47 with "trace_tensors.txt is absent". The tensors sit 1 MiB apart, as before that change.
run_k1.sh passed a refused case on rc != 0 plus any lowercase [TOGSim-trace] line, so a case that lost its scenario and tripped another of the four semaphore refusals still passed. Each case now names its expected message: K1 1 "wait expects another element count", 2 "wait on a semaphore never signaled", 3 "unwaited load batch", rewait 1 "re-wait expects another element count". Checked by mutation: K1 case 2 rewritten to wait sem 7 (case 1's refusal) passes the old script and fails this one with "wanted \"wait on a semaphore never signaled\", got: ... wait expects another element count". Like run_pieces.sh, it now writes trace_tensors.txt beside the .so (1 MiB apart, the layout K1's arrival order was measured on); on 05c2d47 every case failed with "trace_tensors.txt is absent".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-ups to the semaphore change (7b21d07, 2fd095a), from a review of it.
A spad buffer is as large as the producer states (trace ABI 15)
sram_schedule()sized a buffer by summing the bytes of the DMAs that fill or drain one version. A store leaves the version open, so every later store of the same tile added its bytes again: a tile stored twice counted twice, a state stored on each of N trips N times, and once the sum passed the spadtry_occupy_sramnever succeeded and the simulator never ended. 2fd095a itself lists the double drain as not fixed.The compiler allocated the buffer and knows its size, so the producer now exports it and TOGSim only reads it:
togsim_runtime.h: ABI 15. A producer definestogsim_spad_buffer_countandtogsim_spad_buffer_bytes[], the byte size of each buffer id itsread_bufs/write_bufsname (0 for an id that is no spad buffer).index()andsram_schedule()is gone.tests/sram_piecesgains producers that fail on 05c2d47 (48 KB spad):piecesandscatterkeep 32768 and 16640. Every test producer now states its sizes.Each refused semaphore case names its refusal
run_k1.shused to pass a refused case on any non-zero exit with any[TOGSim-trace]message, so a case that lost its scenario and hit a different refusal still passed. Each case now names the message it must get.Checked by mutation: with K1 case 2 rewritten to wait on sem 7, the old script passes and this one fails ("wanted wait on a semaphore never signaled, got: ... wait expects another element count").
Test scripts on 05c2d47
Since the packed tensor layout (d91215e), TOGSim requires a
trace_tensors.txtnext to the.so. Neither test script wrote one, so on 05c2d47 every case failed with "trace_tensors.txt is absent". Both scripts now write it, placing tensors 1 MiB apart (the old layout). K1's arrival order (the small load lands first) was measured on that layout; with tensors 128 MiB apart the scenario is lost.Verification
All on this branch:
tests/sram_pieces/run_pieces.sh: all PASS.tests/semaphore_batch/run_k1.sh: K1 PASS. Cases 1, 2 and 3 and rewait case 1 each get the refusal they name.semaphore-followups, which pins this branch: 10 kernels have the same TOGSim cycles as on 05c2d47, and their spad footprints are identical except istft_overlap_add, 57344 → 55296. That drop is exactly the 2048 B its twice-stored output had been over-counted.PyTorchSim-Triton-Backend PR that pins this branch: PSAL-POSTECH/PyTorchSim-Triton-Backend#27