← Back to Pull requests

POCL: initialize large arrays with a kernel in `zeros` and `ones` #927

Closed
unknown closed this pull request without merging on Oct 26, 2026 14:55 UTC
View on GitHub
unknown unknown commented on Oct 26, 2026 11:44 UTC
Author

On a NUMA system, Linux places a page of memory in the domain of the thread that first writes to it. Since #795, KernelAbstractions.zeros and ones on the CPU back-end allocate a plain Array and fill it with fill! on the calling thread, so all of the memory ends up in that thread's domain, however many PoCL threads later work on it. KernelAbstractions 0.9 filled these arrays with a kernel, and the NUMA example relied on that.

This fills arrays of bits types of at least 1 MiB with a kernel again, so that PoCL's threads touch the pages first. #795 removed the old kernel because it took the element type as a Type{T} argument, which GPUCompiler can't handle for bits unions like Union{Missing, Bool} on Julia 1.13 and earlier. The new kernel takes the value (zero(T) or one(T)) instead, and arrays of bits unions, which aren't isbitstype, keep the host fill! regardless. Like before, the arrays are filled when zeros and ones return, since PoCL launches wait for the kernel.

Smaller arrays are still filled from the host. Timing the initialization of a fresh Float32 array (allocation and fill, median, excluding the first compilation) on a Ryzen 9950X with one memory domain:

| size | 1 thread | 8 threads | 16 threads |
|---|---|---|---|
| 4 KiB | 12.8 | 22.4 | 20.8 |
| 16 KiB | 3.6 | 4.4 | 3.0 |
| 64 KiB | 3.1 | 6.1 | 7.2 |
| 256 KiB | 1.34 | 2.36 | 1.89 |
| 1 MiB | 0.77 | 1.04 | 1.02 |
| 4 MiB | 0.91 | 0.89 | 1.04 |
| 16 MiB | 1.00 | 0.84 | 1.12 |
| 64 MiB | 1.13 | 1.14 | 1.11 |
| 256 MiB | 1.15 | 1.21 | 1.16 |

(time with the kernel divided by time with fill!; threads set with JULIA_KA_CPU_THREADS, process pinned to 16 cores)

Below 1 MiB the launch overhead dominates; from 1 MiB on both are about equally fast, and the largest arrays are bound by memory bandwidth, where the kernel is 10-20% slower on this single-domain machine. That's the price for spreading the pages over the domains of PoCL's threads on a NUMA machine, which I couldn't measure here. With the static scheduling of work-groups in JuliaGPU/pocl#7, a later kernel with as many work-groups runs each of them on the thread that initialized it, so the pages end up near the thread that uses them; this PR doesn't depend on that change.

The NUMA example's remark about zeros is updated accordingly. Tests: zeros and ones of Float32, Int8, ComplexF64 and a small isbits struct, at just above the threshold, as 1- and 2-D arrays and as one-element arrays, next to the existing bits-union test from #795.

Diff: 326 lines (+244 / -82) across 4 files Reviewer: vchuravy Review duration: 191m
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.42) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.42 · 326 lines diff across 4 files
0.42
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
60%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.346
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #927"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 60.5% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 42% (MEDIUM) · Higher = larger blast radius
42%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 60.5% · Lower = rushed or shallow review
60.5%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 16.6% · Safe to merge
16.6%