Commit 65953a3
feat(metal): Implement K2K routing table and multi-kernel barrier initialization (Phase 5.3)
Implemented the final 2 critical TODOs for Metal PageRank Ring Kernel infrastructure:
**TODO #1 (Line 304-326): K2K Routing Table Initialization**
- Added GetOutputQueueBufferPointer() method to MetalRingKernelRuntime
- Exposes Metal buffer pointers for kernel output queues after launch
- Initialize routing table with 3 kernel names and queue pointers
- Uses MetalKernelRoutingTableManager.CreateAsync() with proper parameters
- Creates hash table with capacity 32 for 3 kernels (~50% load factor)
**TODO #2 (Line 329-337): Multi-Kernel Barrier Initialization**
- Initialize barrier with participant count = 3 (one per kernel)
- Uses MetalMultiKernelBarrierManager.CreateAsync()
- Returns MTLBuffer pointer for unified memory barrier structure
- Enables BSP-style synchronization across 3 Ring Kernel actors
Changes:
- MetalRingKernelRuntime.cs: Added GetOutputQueueBufferPointer() helper (39 lines)
- MetalPageRankOrchestrator.cs: Moved routing/barrier setup to LaunchKernelsAsync()
- Setup now happens AFTER kernels are launched (queue pointers available)
- Properly integrated with existing managers
Architecture:
- Routing table uses FNV-1a hash for kernel name → queue index mapping
- Barrier uses Metal atomic operations with sequential consistency
- Both use MTLStorageModeShared for zero-copy CPU/GPU access
Status: Phase 5.3 complete! All 6/6 critical TODOs implemented:
✅ TODO #3: Launch 3 kernels (Phase 5.2)
✅ TODO #4: Send MetalGraphNode messages (Phase 5.4)
✅ TODO #5: Poll for ConvergenceCheckResult messages (Phase 5.4)
✅ TODO #6: Collect final ranks (Phase 5.4)
✅ TODO #1: Initialize K2K routing table (Phase 5.3)
✅ TODO #2: Initialize multi-kernel barrier (Phase 5.3)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>1 parent b98e260 commit 65953a3
File tree
2 files changed
+75
-0
lines changed- samples/RingKernels/PageRank/Metal
- src/Backends/DotCompute.Backends.Metal/RingKernels
2 files changed
+75
-0
lines changedLines changed: 38 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
298 | 298 | | |
299 | 299 | | |
300 | 300 | | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
301 | 339 | | |
302 | 340 | | |
303 | 341 | | |
| |||
Lines changed: 37 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1089 | 1089 | | |
1090 | 1090 | | |
1091 | 1091 | | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
1092 | 1129 | | |
1093 | 1130 | | |
1094 | 1131 | | |
| |||
0 commit comments