Commit 92287ae
Add oneDNN matmul-primitive MatMul backend (threadpool runtime)
Second, build-time-selectable oneDNN backend that uses the high-level
dnnl::matmul primitive with the THREADPOOL CPU runtime, coexisting with
but mutually exclusive from the merged BRGeMM (SEQ ukernel) backend.
oneDNN picks the kernel and calls back into gemma.cpp's hwy::ThreadPool
through a threadpool_iface adapter for all parallelism.
- ops/onednn_matmul.h / -inl.h: engine singleton, HwyThreadPoolAdapter
bridge, self-validating reordered-weights cache, thread_local
user-managed scratchpad, and DoMatMul_OneDnn with native scale/add/
demote fusion (writes final values straight into C, clean fallback on
any failure).
- ops/matmul-inl.h: dispatch hook (BF16xBF16, M>1) with fallback to the
stock path; MMPerKey bookkeeping field; zones caller label; bench
fair-timing for the first JIT+reorder call.
- Mutual exclusion enforced at three layers: CMake FATAL_ERROR, Bazel
ambiguous-select(), and a C++ #error guard.
- CMake + Bazel wiring to fetch/build oneDNN v3.11 (THREADPOOL runtime).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent 4b26b03 commit 92287ae
11 files changed
Lines changed: 721 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
37 | 48 | | |
38 | 49 | | |
39 | 50 | | |
| |||
363 | 374 | | |
364 | 375 | | |
365 | 376 | | |
| 377 | + | |
366 | 378 | | |
367 | 379 | | |
368 | 380 | | |
369 | 381 | | |
370 | 382 | | |
371 | 383 | | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
372 | 387 | | |
373 | 388 | | |
374 | 389 | | |
| |||
384 | 399 | | |
385 | 400 | | |
386 | 401 | | |
| 402 | + | |
387 | 403 | | |
388 | 404 | | |
389 | 405 | | |
| |||
395 | 411 | | |
396 | 412 | | |
397 | 413 | | |
| 414 | + | |
398 | 415 | | |
399 | 416 | | |
400 | 417 | | |
| |||
412 | 429 | | |
413 | 430 | | |
414 | 431 | | |
| 432 | + | |
415 | 433 | | |
416 | 434 | | |
417 | 435 | | |
| |||
433 | 451 | | |
434 | 452 | | |
435 | 453 | | |
| 454 | + | |
436 | 455 | | |
437 | 456 | | |
438 | 457 | | |
| |||
449 | 468 | | |
450 | 469 | | |
451 | 470 | | |
| 471 | + | |
452 | 472 | | |
453 | 473 | | |
454 | 474 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
36 | 49 | | |
37 | 50 | | |
38 | 51 | | |
| |||
113 | 126 | | |
114 | 127 | | |
115 | 128 | | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
116 | 147 | | |
117 | 148 | | |
118 | 149 | | |
| |||
185 | 216 | | |
186 | 217 | | |
187 | 218 | | |
| 219 | + | |
| 220 | + | |
188 | 221 | | |
189 | 222 | | |
190 | 223 | | |
| |||
247 | 280 | | |
248 | 281 | | |
249 | 282 | | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
250 | 287 | | |
251 | 288 | | |
252 | 289 | | |
| |||
275 | 312 | | |
276 | 313 | | |
277 | 314 | | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
278 | 319 | | |
279 | 320 | | |
280 | 321 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
39 | 55 | | |
40 | 56 | | |
41 | 57 | | |
| |||
0 commit comments