r/computerscience • u/HuygensFresnel • May 26 '25
Advice Resource on low level math optimisation
Hello people. Im currently making a FEM matrix assembler. I want to have it work as efficiently as possible. Im currently programming it in python+numba but i might switch to Rust. I want to learn more about how to write code in a way that the compiler can optimise it as well as possible. I dont know if the programming language makes night and day differences but i feel like in general there should be information on heuristics that will guide me in writing my code so that it runs as fast as possible. I do understand that some compilers are more efficient at finding these optimisations than others. The type of stuff I’m referring to could be for example (pseudo code)
f(0,0) = ab + cd f(1,0) = ab - cd
vs
q1 = ab q2 = cd f(0,0) = q1+q2 f(1,0) = q1-q2
Does anyone know of videos/books/webpages to consult?
View all comments
Show parent comment
2
u/crimson1206 May 26 '25 edited May 26 '25
In such cases it’s definitely a good idea to move the things into outer loops as much as possible.
Functions calls in particular can be difficult for the compiler