Discussion: Fortran/C interface fixes surfaced by wasm ABI enforcement
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ó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Cần làm rõ
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- c, fortran, wasm
- Lĩnh vực
- api, build-system
Hướng nghiên cứu
Bắt đầu bằng việc xem xét các patch downstream trong recipe emscripten-forge OpenBLAS, sau đó kiểm tra các khai báo interface Fortran, lapack-netlib/SRC và tập con được LAPACKE gọi được đề cập trong cuộc thảo luận. So sánh các thay đổi được đề xuất đối với strlen và các kiểu trả về của SUBROUTINE giữa các bản build wasm và native; công việc được xem là hoàn tất khi đã thống nhất được hướng upstream, các kiểm tra ABI wasm hoạt động và các bài kiểm thử liên quan đều đạt.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Hi,
We maintain the emscripten build of OpenBLAS at emscripten-forge and are considering upstreaming a few patches, notably on matching the c/fortran interface with its calling conventions more precisely. Before opening PRs I'd like to initiate discussion here.
The main issue is that Wasm32 checks function signatures at call sites more strictly than native. Mismatched arity/types are hard errors at link or load time rather than being silently absorbed. This surfaces a Fortran/C interface mismatch: My understanding of it is that Fortran's ABI appends a hidden size_t string-length arg for each CHARACTER arg at the end of each function argument list. Native compilation and use tolerates C callers omitting those trailing args, causing the Fortran callee to read whatever garbage is in that register/stack slot. This may or may not produce issues, depending on whether that empty argument is actually used. Wasm, on the other hand, rejects the signature mismatch outright.
Patches we have downstream to overcome this are:
-
Conditionally add, for builds that need it (such as wasm), the trailing size_t (dummy hidden strlen) arguments to the C-side declarations of BLAS/LAPACK interface functions that take Fortran CHARACTER args matching the "strlen at end" convention (LAPACK_FORTRAN_STRLEN_END). It seems likely difficult to activate this by default because downstream C consumers may all have to get rewritten then. But if it's activated it may be able to catch some bugs, e.g. if the string length argument is actually used by the fortran routine. It could get activated on CI, for example.
-
Change return type of the SUBROUTINE-wrapping C prototypes from int to void, since flang expects SUBROUTINE to have no return value. A quick grep across the OpenBLAS tree (including the ~2000 f2c-derived files in lapack-netlib/SRC) showed zero internal callers that read the return value of a Fortran SUBROUTINE. It seems f2c did this for historic reasons but unsure. There is a potential risk for external callers reading that return int although it's garbage, but it seems thos callers shouldn't use return values anyway if it's just garbage returned.
-
Same for a subset of LAPACK functions called from LAPACKE.
-
Remove the #ifndef EMSCRIPTEN guard around #define LAPACK_FORTRAN_STRLEN_END, so it's defined for every target. The comment above already asserts this is the universally available convention.
More opinions on this would be great. We also have a few additional patches (mostly around testing and build workarounds), but the ones above seem most fundamental and are a good place to start. The diff for these may be large, but the changes themselves would be rather mechanical. One way to start would be to open a draft PR so that we can test.
Thoughts @martin-frbg ? Also tagging @ianthomas23 and @jjerphan who worked on this.
- Ngôn ngữ chính
- C
- Star
- 7.6k
- Fork
- 1.7k
- Merge trung bình
- 1 ngày 6 giờ
- Pull request đã merge (30 ngày)
- 46
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 OpenMathLib/OpenBLAS
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
OpenMathLib/OpenBLAS#6069 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Missing cgroup awarenessĐang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 52/100
OpenMathLib/OpenBLAS#6059 ·
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
OpenMathLib/OpenBLAS#6029 · 21 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 68/100
OpenMathLib/OpenBLAS#6028 · 1 bình luận ·
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
OpenMathLib/OpenBLAS#5930 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của OpenMathLib/OpenBLAS
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
microsoft/ebpf-for-windows#5604 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/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 70/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 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Update OPENEXR_IMATH_TAGĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 84/100
AcademySoftwareFoundation/openexr#2683 ·
Maintainer thường phản hồi trong vòng 1 ngày