Commit 83cfc57
committed
Phase 3: convert to_binary to async enif_send (Option 3a)
Converts the last worker-bound NIF to the async model. `to_binary`
was the hardest case because it returns a resource binary that
aliases MLX-owned memory via `fine::make_resource_binary` — Spike B
validated that building the resource binary on the worker-allocated
msg_env correctly pins the Tensor resource across `enif_send`, so
no memcpy fallback is needed.
The worker thread now runs `mx::contiguous + mx::eval` and builds
the resource binary directly into msg_env. The binary carries one
resource ref into the caller's heap fragment, keeping the MLX
buffer alive for the lifetime of the binary on the receiver.
Drops the `ERL_NIF_DIRTY_JOB_CPU_BOUND` flag — `to_binary` was the
last dirty-flagged NIF in the project. With Phase 3 merged, no
NIF blocks any BEAM scheduler (regular or dirty) on MLX work.
Full suite: 425 tests, 0 failures.
Full heavy suite (including qwen3_full, vit_full, whisper_full,
distilbert_full, training_full, qwen3_quant_full, fast_kernels_full,
conformance): 453 tests, 0 failures.1 parent 75ebeed commit 83cfc57
2 files changed
Lines changed: 36 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
87 | 96 | | |
88 | | - | |
89 | | - | |
| 97 | + | |
| 98 | + | |
90 | 99 | | |
91 | | - | |
92 | | - | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
93 | 104 | | |
94 | | - | |
| 105 | + | |
95 | 106 | | |
96 | 107 | | |
97 | 108 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
43 | 47 | | |
44 | | - | |
| 48 | + | |
45 | 49 | | |
46 | 50 | | |
47 | 51 | | |
| |||
0 commit comments