BLAS-1 methods pass reversed views to oneMKL with a negative increment
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
- 1-2 ngày
- Mức phù hợp với người mới
- 74/100
Hướng nghiên cứu
Start in lib/mkl/linalg.jl and lib/mkl/wrappers_blas.jl; compare the BLAS-1 methods and pointer/increment handling with LinearAlgebra's vec_pointer_stride behavior described in the issue. Check how non-contiguous multidimensional arrays reach these wrappers and where they can fall back to GPUArrays implementations. Done means reversed views and non-contiguous arrays produce correct results without writing outside the view; use the examples in the issue to verify.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
The BLAS-1 methods in lib/mkl/linalg.jl (norm, dot, BLAS.asum, axpy!, axpby!, rmul!, rotate!, reflect!) forward any oneStridedArray to the wrappers in lib/mkl/wrappers_blas.jl, which pass pointer(x) with incx = stride(x, 1). With a reversed view, that increment is negative and the results are silently wrong:
using oneAPI, LinearAlgebra
x = oneArray(Float32[3, 4]); r = view(x, 2:-1:1); y = oneArray(Float32[1, 2])
norm(r) # 4.0, expected 5.0
dot(r, y) # 8.0, expected 10.0
LinearAlgebra.BLAS.asum(r) # 4.0, expected 7.0
axpy!(1f0, r, copy(y)) # [1, 6], expected [5, 5]
rmul!(r, 2f0); x # [3, 8], expected [6, 8]
BLAS routines that accept a negative increment walk the vector backwards from its lowest address, while the pointer of a reversed view points at its first logical element, so they read and write the wrong memory.
The methods also accept non-contiguous arrays with more than one dimension, and the wrappers then treat them as length(x) elements with stride stride(x, 1). That gives wrong results and writes outside the view:
M = rand(Float32, 3, 2); dM = oneArray(M)
norm(view(dM, 1:2, :)) ≈ norm(M[1:2, :]) # false
rmul!(view(dM, 1:2, :), 2f0) # scales M[3, 1] instead of M[2, 2]
LinearAlgebra handles negative strides in its BLAS wrappers: vec_pointer_stride passes the pointer to the lowest address together with the signed increment, and nrm2, asum and scal use abs(stride(x, 1)), since the order doesn't matter for them. The wrappers should only take strided vectors or dense arrays, with other arrays falling back to the GPUArrays implementations. The storage-level mul! has a similar problem for gemv and friends, which is #700.
Same issue in CUDA.jl: JuliaGPU/CUDA.jl#3410.
Reproduced with oneAPI.jl 2.9.2 on an Iris Xe, Julia 1.12.7. The BLAS-1 methods and wrappers are unchanged on main.
- 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)
- 45
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ó 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
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
JuliaGPU/oneAPI.jl#538 · 2 bình luận ·
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 83/100
JuliaGenAI/HuggingFaceDatasets.jl#96 ·
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 83/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 66/100
JuliaData/DBFTables.jl#50 ·
-
_fit_phylo_binomial_xlv: default start calls undefined logit (UndefVarError without beta_init)Có thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởcode-review
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
JuliaNLSolvers/Optim.jl#1296 ·