Array construction queries device properties on every allocation
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- Nửa ngày
- Mức phù hợp với người mới
- 65/100
- Loại issue
- Tái cấu trúc
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Lĩnh vực
- performance
Hướng nghiên cứu
Start in check_eltype and _device_supports_bfloat16 in src/array.jl, and reuse the device_limits cache in src/oneAPIKernels.jl as a pattern. Run the benchmark script in the issue to get a baseline, then check _device_supports_bfloat16 in compilation.jl too. Done when the fp16, fp64 and bf16 flags are cached per device, the capability bits come from module_properties(dev).flags, the benchmark drops well below 1 µs, and test/runtests.jl still passes.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
check_eltype (src/array.jl), which runs on every oneArray construction, queries the driver each time it's called:
oneL0.module_properties(device()), twice (Float16 and Float64 checks);_device_supports_bfloat16(), which on devices that don't advertiseZE_bfloat16_conversions(everything except PVC with recent drivers) falls through tooneL0.properties(dev). That builds the full device-properties NamedTuple, including the nameStringand UUID.
On an Iris Xe (TGL, NEO 26.18) with oneAPI.jl master (fa0f23a2):
| call | median | allocs |
|---|---|---|
oneAPI.check_eltype(Float32) |
29.2 µs | 67 (3.4 KiB) |
oneL0.properties(dev) |
20.9 µs | 32 |
oneL0.module_properties(dev) |
2.6 µs | 15 |
check_eltype with cached capability flags |
0.08 µs | 1 |
Allocating and freeing a small array (unsafe_free!(oneArray{Float32}(undef, 16))) takes about 25 µs on an idle machine, so this check accounts for most of the cost of a small allocation. A profile shows most samples under check_eltype → _device_supports_bfloat16 → properties. Arrays allocated inside GPUArrays/AcceleratedKernels internals (reduction scratch space, similar) pay this cost as well.
Suggested fix: compute the per-device capability flags (fp16, fp64, bf16) once and cache them, like device_limits in src/oneAPIKernels.jl does (a Dict keyed by ZeDevice), or memoize properties/module_properties themselves, since they're static for a device. compilation.jl also calls _device_supports_bfloat16(dev), so it would benefit too.
While you're there: check_eltype (and test/runtests.jl) test fp16flags & ZE_DEVICE_MODULE_FLAG_FP16 and fp64flags & ZE_DEVICE_MODULE_FLAG_FP64. But fp16flags/fp64flags are ze_device_fp_flags_t (DENORM=1, INF_NAN=2, ...), not ze_device_module_flags_t, so these checks test the denorm/inf-nan bits. They give the right answer in practice (a device either reports no fp64 flags at all or reports the full set), but the capability bits are in module_properties(dev).flags, which is what device_limits already uses.
Benchmark script
using oneAPI, BenchmarkTools
const L0 = oneAPI.oneL0
dev = device()
@benchmark oneAPI.check_eltype(Float32)
@benchmark L0.module_properties($dev)
@benchmark L0.properties($dev)
const cache = Dict{L0.ZeDevice,NTuple{3,Bool}}()
caps(d=device()) = get!(cache, d) do
m = L0.module_properties(d)
(m.flags & L0.ZE_DEVICE_MODULE_FLAG_FP16 != 0,
m.flags & L0.ZE_DEVICE_MODULE_FLAG_FP64 != 0,
oneAPI._device_supports_bfloat16(d))
end
function check_cached(T)
Base.allocatedinline(T) || error()
fp16, fp64, bf16 = caps()
fp16 || (oneAPI.contains_eltype(T, Float16) && error())
fp64 || (oneAPI.contains_eltype(T, Float64) && error())
bf16 || (oneAPI.contains_eltype(T, Core.BFloat16) && error())
nothing
end
@benchmark check_cached(Float32)
- Ngôn ngữ chính
- Julia
- Star
- 217
- Fork
- 37
- Merge trung bình
- 1 ngày 7 giờ
- Pull request đã merge (30 ngày)
- 38
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của JuliaGPU/oneAPI.jl
-
libraries upstream
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 22/100
JuliaGPU/oneAPI.jl#703 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
Maintainer thường phản hồi trong vòng 1 ngày
-
IGC heap corruption compiling findmax's reduction kernel on Julia 1.12 with --check-bounds=yesĐang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
JuliaGPU/oneAPI.jl#663 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của JuliaGPU/oneAPI.jl
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
JuliaGPU/KernelAbstractions.jl#897 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
oscar-system/GAP.jl#1455 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
JuliaAI/MLJTransforms.jl#85 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
SciML/OrdinaryDiffEq.jl#4875 ·
Maintainer thường phản hồi trong vòng 4 ngày