x86_64 intrinsics rustfft needs, and Windows symbols whose DLL is not loaded yet
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 18/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- rust
調査の方向性
Two separate pieces. For the intrinsics, read libs/relax/compiler/std/core/arch/x86_64.rs and run libs/relax/compiler/tests/rustfft_avx_intrinsics.rs first; done means its expected numbers match rustc's stdarch output. For the Windows gap, start at find_system in libs/relax/compiler/src/os/proc.rs and reproduce with the winit 0.30 snippet (also with NO_DND=1); done means both print window created, theme: Some(Dark). The reporter's fork commits are the reference, but the fixed DLL list is called a stopgap, so expect design discussion.
索引モデルが issue の本文から書いたものです。
説明
Two independent gaps, both found running Suhina (an open-source DAW in Rust, on eframe/winit 0.30 and rustfft 6.4) under relax run on Windows; rustc builds and runs both cases. The first hits any program that uses rustfft 6.4 on x86_64: both its SSE and its AVX paths call intrinsics Relax's std lacks. The second hits Windows programs whose Win32 calls go through windows-sys 0.52 to 0.60 (windows-targets) when nothing has loaded the function's DLL yet; winit 0.30 does this for ole32 and uxtheme when it creates a window. windows-sys 0.61 and later (windows-link) name the DLL and are not affected.
Fixes for both are in my fork, linked in each section; the branch also carries an unrelated local commit, so please take the commits listed here only.
1. core::arch::x86_64 lacks intrinsics rustfft 6.4 calls
rustfft 6.4's SSE and AVX butterflies call intrinsics Relax's std lacks. On a CPU with AVX and FMA the first FFT stops at a compile error on _mm256_moveldup_ps and parks the thread that runs it; without AVX, the SSE path needs _mm_load1_ps, _mm_moveldup_ps, _mm_addsub_ps and _mm_blend_ps.
Every intrinsic the two paths name that std lacked:
_mm_load1_ps, _mm_load_ps1, _mm_moveldup_ps, _mm_addsub_ps, _mm_blend_ps, _mm_permute_ps, _mm_broadcast_ss, _mm_fmaddsub_ps, _mm_fmsubadd_ps, _mm256_moveldup_ps, _mm256_movehdup_ps, _mm256_blend_ps, _mm256_permute_ps, _mm256_broadcast_ss, _mm256_castps128_ps256, _mm256_zextps128_ps256, _mm256_insertf128_ps, _mm256_fmaddsub_ps, _mm256_fmsubadd_ps, _mm256_loadu2_m128d
Fix: the intrinsics in std/core/arch/x86_64.rs (commits 8992487, 64f17de, a1f8a5f), and a test, tests/rustfft_avx_intrinsics.rs, that checks the same expected numbers under rustc (against stdarch) and under Relax.
With the fix the intrinsics run 4 to 7 times slower than rustc's code (add and mul 3 to 4). rustfft 6.4 under the JIT, forward FFT, f32:
| Size | Relax main | Relax with the fix | rustc AVX |
|---|---|---|---|
| 5400 points | stops at the compile error | 24–27 µs | 7.5 µs |
| 4096 points | stops at the compile error | 75–300 µs | 4.5 µs |
Which size is fast moves with small changes in std. The time left is in the O3 build of rustfft's large butterflies (Butterfly512Avx::column_butterflies_and_transpose), where the JIT also reports an inline candidate it leaves out.
2. Windows: a symbol whose DLL nothing has loaded yet is "not available on this host"
windows-targets 0.52 and 0.53 (used by windows-sys 0.52 to 0.60) name a function's DLL in link! only under windows_raw_dylib, a cfg cargo resolves dependencies by, so Relax cannot set it. Without it the extern block links the import library windows.0.5x.0, which names no DLL to load. windows-link (windows-sys 0.61+) always uses raw-dylib with the DLL's name, which Relax already loads.
Such a symbol resolves only once other code has loaded its DLL into the process. A winit 0.30 app that only opens a window meets it at once: winit calls OleInitialize (ole32.dll, for drag and drop) and SetWindowTheme (uxtheme.dll) while it creates the window, before anything has loaded either.
Reproduction (Windows 11, x86_64; winit 0.30.13, windows-sys 0.52.0):
[dependencies]
winit = { version = "=0.30.13", default-features = false, features = ["rwh_06"] }
use winit::application::ApplicationHandler;
use winit::event::WindowEvent;
use winit::event_loop::{ActiveEventLoop, EventLoop};
use winit::window::{Window, WindowId};
#[derive(Default)]
struct App {
window: Option<Window>,
}
impl ApplicationHandler for App {
fn resumed(&mut self, event_loop: &ActiveEventLoop) {
println!("creating window");
let attributes = {
use winit::platform::windows::WindowAttributesExtWindows;
Window::default_attributes()
.with_title("winit-theme")
.with_drag_and_drop(std::env::var_os("NO_DND").is_none())
};
match event_loop.create_window(attributes) {
Ok(window) => {
println!("window created, theme: {:?}", window.theme());
self.window = Some(window);
}
Err(e) => println!("create_window failed: {e}"),
}
event_loop.exit();
}
fn window_event(&mut self, _: &ActiveEventLoop, _: WindowId, _: WindowEvent) {}
}
fn main() {
let event_loop = match EventLoop::new() {
Ok(l) => l,
Err(e) => return println!("event loop failed: {e}"),
};
let mut app = App::default();
if let Err(e) = event_loop.run_app(&mut app) {
println!("run_app failed: {e}");
}
println!("done");
}
relax run on main (148c09246), registry paths shortened:
creating window
thread 'main' panicked at windows-sys-0.52.0/src/Windows/Win32/System/Ole/mod.rs:119:1:
foreign function `OleInitialize` is not available on this host -- cfg the call out or link its library
relax: `windows-sys` 0.52.0: an item Relax cannot compile (if cargo builds it, a Relax gap: report it)
relax: main panic: foreign function `OleInitialize` is not available on this host -- cfg the call out or link its library
With drag and drop off (NO_DND=1), the next one fails the same way:
creating window
thread 'main' panicked at windows-sys-0.52.0/src/Windows/Win32/UI/Controls/mod.rs:368:1:
foreign function `SetWindowTheme` is not available on this host -- cfg the call out or link its library
relax: `windows-sys` 0.52.0: an item Relax cannot compile (if cargo builds it, a Relax gap: report it)
relax: main panic: foreign function `SetWindowTheme` is not available on this host -- cfg the call out or link its library
The rustc build, and Relax with the fix below, print window created, theme: Some(Dark) and done in both forms.
Fix: find_system in src/os/proc.rs (commit 91a3608). When no loaded module exports the symbol, it also tries about 30 common system DLLs windows-sys imports from (user32, gdi32, uxtheme, dwmapi, shell32, ole32, dxgi, d3d12 and so on), loaded from System32 only. It works, but a fixed list is a stopgap: reading each symbol's DLL name from the import library would cover every DLL.
- 主要言語
- Rust
- スター
- 601
- フォーク
- 34
- 平均マージ
- 1時間 58分
- マージ済み PR(30日)
- 45
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
makepad/relax のほかの issue
-
std: `SliceIndex<str>` missing for `std::ops` ranges, so generic `R: SliceIndex<str>` bounds failオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 42/100
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 18/100
メンテナーはふだん 1 日以内に返信
-
Relax live tests rerun the whole suite after a one-line body edit再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 32/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
CI/CD ignore-for-release
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
eclipse-ankaios/ankaios#844 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
symposium-dev/symposium#530 ·
メンテナーはふだん 5 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
topgrade-rs/topgrade#2540 ·
メンテナーはふだん 1 日以内に返信