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
1
u/HuygensFresnel May 29 '25
I understand that is what i mean. The compiler can discover some optimisations but i should be the one who programs efficient code. So yes 100% what you are saying. I was hoping that there where some good books explaining more what happens under the hood when I run a bunch of math operations in a loop.