x86_64 intrinsics rustfft needs, and Windows symbols whose DLL is not loaded yet
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 18/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- rust
- Domain
- compilers, operating-systems
Research direction
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.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- Rust
- Stars
- 601
- Forks
- 34
- Avg merge
- 1h 58m
- Merged PRs (30d)
- 45
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from makepad/relax
-
std: `SliceIndex<str>` missing for `std::ops` ranges, so generic `R: SliceIndex<str>` bounds failOpen
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 42/100
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 18/100
Maintainers usually reply within 1 day
-
Relax live tests rerun the whole suite after a one-line body editMay be free again A pull request for this issue was closed without being merged. Open
Difficulty 4/5 3-5 days Newbie friendliness 32/100
Maintainers usually reply within 1 day
Similar issues
-
CI/CD ignore-for-release
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
eclipse-ankaios/ankaios#844 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
symposium-dev/symposium#530 ·
Maintainers usually reply within 5 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
topgrade-rs/topgrade#2540 ·
Maintainers usually reply within 1 day