4 ms·
Sure, you can reorder floating point operations and assume no aliasing. Now you can vectorize and avoid redundant memory access. But it's a problem of the lang
by stabbles 3y ago
Sure, you can reorder floating point operations and assume no aliasing. Now you can vectorize and avoid redundant memory access.
But it's a problem of the language really.
Alias analysis in Fortran is much easier than in C / C++.
Also I'm reasonably sure that Rust's borrow checker could be used for alias analysis and improve performance without making unsafe assumptions, no clue if that is actually done.
For reordering of floating point numbers, there should just be clear demarcations in code where it's safe. It's ridiculous that `-ffast-math` works on the level of the command line. But I think that ship has sailed, cause although clang has supports pragma's, it's not a standard:
#pragma clang fp exceptions(strict)
- JonChesterfield 3y agoAlias analysis can definitely be easier/harder for different languages. It's the independence of loop iterations which really does the trick for vectorising numerical code. That would be why cuda is magic - if the lanes of the vector operations step on each other, it is defined to be the programmers problem, not the compiler. Thus cuda autovectoriser cannot fail, the code is already a vector. Futhark is probably very good at vector operations. Fast-math has crazy things like setting it for one file affects other files. Last time I checked a more reasonable alternative set of constructs were being considered/implemented. Other faster-but-kindof-wrong things like assuming signed integers don't overflow exist too. Agreed that they're all less alarming when locally scoped.
- WalterBright 3y agoThe semantics of C don't allow for alias analysis. For some cases, the compiler can prove that there are no aliases, but it will have to be conservative and throw up its hands most of the time. An ownership/borrowing system is able to implicitly fulfill the requirements of restrict.