Commit bfd3b81
Unify kernel and firmware JIT build deduplication into JitBuildCache (#37452)
### Ticket
#31189
### Problem description
Multi-thread concurrency handling for JIT build for the same target is
handled by HashLookup for kernels, and mutex+set for firmware at call
sites. This logic can be absorbed into jit build and the call sites can
be cleaned up.
### What's changed
Replace two separate concurrency/deduplication mechanisms (HashLookup
for kernels, mutex+set for firmware) with a single JitBuildCache class
in the jit_build module. Callers now use jit_build_once(hash, fn) which
guarantees exactly-once execution per hash, with concurrent callers
blocking until the build completes.
Fixed a subtle bug in the old HashLookup::clear() where a thread waiting
in wait_for_bin_generated() could sleep forever if clear() was called
concurrently.
### Checklist
- [ ] [](https://github.com/tenstorrent/tt-metal/actions/workflows/all-post-commit-workflows.yaml?query=branch:ruizhang/jit_build_cache)
- [ ] [](https://github.com/tenstorrent/tt-metal/actions/workflows/blackhole-post-commit.yaml?query=branch:ruizhang/jit_build_cache)
- [ ]
[](https://github.com/tenstorrent/tt-metal/actions/workflows/tt-metal-l2-nightly.yaml?query=branch:ruizhang/jit_build_cache)
(failures in tools test is due to [recent
change](#37147 (comment)))
- [ ] New/Existing tests provide coverage for changes
---------
Co-authored-by: Cursor <cursoragent@cursor.com>1 parent ad0d780 commit bfd3b81
File tree
12 files changed
+135
-92
lines changed- tests/tt_metal/tt_metal
- api
- tt_metal
- detail
- impl
- context
- program
- jit_build
12 files changed
+135
-92
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | 16 | | |
18 | 17 | | |
19 | 18 | | |
| |||
35 | 34 | | |
36 | 35 | | |
37 | 36 | | |
38 | | - | |
| 37 | + | |
39 | 38 | | |
40 | 39 | | |
41 | 40 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
21 | 20 | | |
22 | 21 | | |
23 | 22 | | |
| |||
38 | 37 | | |
39 | 38 | | |
40 | 39 | | |
41 | | - | |
| 40 | + | |
42 | 41 | | |
43 | 42 | | |
44 | 43 | | |
| |||
Lines changed: 1 addition & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
29 | 28 | | |
30 | 29 | | |
31 | 30 | | |
| |||
184 | 183 | | |
185 | 184 | | |
186 | 185 | | |
187 | | - | |
| 186 | + | |
188 | 187 | | |
189 | 188 | | |
190 | 189 | | |
| |||
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
| |||
273 | 274 | | |
274 | 275 | | |
275 | 276 | | |
276 | | - | |
277 | 277 | | |
278 | 278 | | |
279 | 279 | | |
280 | 280 | | |
281 | 281 | | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
| 282 | + | |
| 283 | + | |
289 | 284 | | |
290 | 285 | | |
291 | 286 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
201 | 201 | | |
202 | 202 | | |
203 | 203 | | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | 204 | | |
209 | 205 | | |
210 | 206 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
69 | 68 | | |
70 | 69 | | |
71 | 70 | | |
| |||
190 | 189 | | |
191 | 190 | | |
192 | 191 | | |
193 | | - | |
| 192 | + | |
194 | 193 | | |
195 | 194 | | |
196 | 195 | | |
| |||
1487 | 1486 | | |
1488 | 1487 | | |
1489 | 1488 | | |
1490 | | - | |
| 1489 | + | |
1491 | 1490 | | |
1492 | 1491 | | |
1493 | 1492 | | |
1494 | 1493 | | |
1495 | 1494 | | |
1496 | 1495 | | |
1497 | 1496 | | |
1498 | | - | |
1499 | | - | |
1500 | | - | |
| 1497 | + | |
1501 | 1498 | | |
1502 | 1499 | | |
1503 | 1500 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
7 | 9 | | |
8 | 10 | | |
9 | 11 | | |
| |||
748 | 750 | | |
749 | 751 | | |
750 | 752 | | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
751 | 759 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
171 | 180 | | |
0 commit comments