FYI vien [0] figured out that simply compiling with "-static -fno-pie" and _exit(0)-ing at the end puts the solution presented here to 15000 points and hence #4 on the leaderboard. Pretty funny.
Is there a path forward for compilers to eek out these optimization gains eventually? Is there even a path?
550x gains with some C ++ / mixed gnarly low level assembly vs standard C++ is pretty shocking to me.
Usually, it's fair game to use all of the information presented in an exam-style question to derive your answer.
With that in mind, I propose the following solution.
`print(976563)`
Does anyone have any tips for similar wizardry-level SIMD optimization on ARM?
Can this optimization be applied to matmult for us, critters who are running llama on cpu? XD
"The solution presented here is ~550x faster than the following naive program."
... std::cin >> v; ...
Oh come on! That's I/O for every item, I'm surprised it's not even slower.Le met hazard a guess: that blog post was not written by a LLM!?
My own solution which is ~1ms faster uses some other pattern that was found experimentally, but I cannot seem to get it to go any faster by tuning the parameters, and the #1 spot remains slightly out of reach.
Alexander Monakov has called the attention of the highload Telegram chat to this paper[0], saying:
So one wonders if it's not really a matter of reading the RAM in the right pattern to appease the prefetchers but of using values in the right pattern to create the right pattern of stalls to get the highest frequency.[0]: https://tu-dresden.de/zih/forschung/ressourcen/dateien/proje...