r/programming • u/mister_mort • 20h ago
Advent of Code 2026 starts today
adventofcode.comStart time is midnight EST (UTC-5), ~6H from the time this post is written.
r/programming • u/mister_mort • 20h ago
Start time is midnight EST (UTC-5), ~6H from the time this post is written.
r/programming • u/HappyAngrySquid • 18h ago
r/programming • u/mgyk1024 • 2h ago
r/programming • u/ingressstatue • 10h ago
r/programming • u/AndrewOfC • 6m ago
Take, for example, a simple reduction: summing all the elements in an array...
template<typename T>
T vector_reduce_simple(T *src, size_t len, T initial)
{
for(size_t i = 0; i < len; i++)
{
initial += src[i];
}
return initial;
}Or this version:
template<typename T>
T vector_reduce_cpu(const T *src, size_t len, T initial /* = 0 */)
{
while( len >= 4 ) {
T r00, r01, r02, r03 ;
r00 = src[0] ;
r01 = src[1] ;
r02 = src[2] ;
r03 = src[3] ;
r00 += r02 ;
r01 += r03 ;
r00 += r01 ;
initial += r00 ;
len -= 4 ;
src += 4 ;
} // while
while( len >= 2 ) {
T r00, r01 ;
r00 = src[0] ;
r01 = src[1] ;
r00 += r01 ;
initial += r00 ;
len -= 2 ;
src += 2 ;
} // while
while( len >= 1 ) {
T r00 ;
r00 = src[0] ;
initial += r00 ;
len -= 1 ;
src += 1 ;
} // while
return initial ;
}On an i9 CPU, with T being 'double', in optimal cases (i.e., a length of about 2000-7000), the longer version runs 4x faster when compiled with gcc and -O3. Why?
Even going back to the 1980s, with the 68882 FPU, floating-point units could perform operations in parallel. In the shorter case, that parallelism is defeated by the accumulation occurring solely through the 'initial' variable.
By introducing more variables, the additions can occur in parallel. The compiler also optimizes memory by interleaving variable loads with additions, which can also run in parallel.
So what's the takeaway?
r/programming • u/Fantastic_Wave1982 • 31m ago
r/programming • u/self • 1d ago
r/programming • u/Browhair3834 • 8h ago
I turned a personal project into an interactive article. It's about an LED board installation in my living room. I had a great time making it work and control it via a remote web client.
In this article, I aim to explain the basics of machine communication, and you can try it out for yourself at the end!
r/programming • u/mitchellvitez • 1d ago
r/programming • u/compy3 • 1d ago
hey everyone - a couple months ago, I posted an overview of caching in Postgres. This is the follow-up, for anyone who has decided to cache reads and is trying to figure out how to do it.
In addition to the main options, the article also covers some of the classic zingers that leave you serving stale data: invalidation, stampedes, tenants and RLS, read-your-own-writes, schema changes.
(disclaimer: I'm one of the founders of PgCache, which is one of the proxy options. I tried to keep it balanced)
Did I miss anything?
r/programming • u/r_retrohacking_mod2 • 2d ago
r/programming • u/anegri • 1d ago
For Delphi developers needing a tutorial on an alternative to TTimer when using FMX for cross platform solutions.
r/programming • u/Polixa12 • 3d ago
This was pretty fun for me to write up on. Would love to hear y'all's thoughts on scheduling bottlenecks in fair locks.
r/programming • u/CircumspectCapybara • 4d ago
r/programming • u/Old-Illustrator-8692 • 4d ago