ELSEIF
Your brief EB
180 stories from 108 feeds 348 clusters Refreshed 4 minutes ago next pull 23:36

TECH Signal 392

New fast modulus techniques compute day-of-the-week in a single multiplication plus two cycles

New fast modulus techniques convert a day-count to a day-of-the-week using a three-instruction sequence that outperforms existing solutions on AMD Ryzen 9 and Apple M4 Pro processors.

WHY IT MATTERS

These optimizations matter for high-performance date libraries, database engines, and compiler authors. The techniques also generalize to other modulus operations like x % 24 and x % 60, which are applicable to timekeeping.

Written by elseif from the cluster below · every claim links back to a source

The three things worth knowing

01

The new algorithms achieve a latency of a single multiplication plus two cycles for computing the weekday.

02

Weekday can be computed in ISO format ([1‥7]) with the exact same instructions as Unix format ([0‥6]) by tweaking constants.

03

The fast modulus techniques generalize to x % (2^N - 1) and other divisors such as x % 24 and x % 60.

THE CLUSTER

Same story, 1 feed.

ORDERED BY FIRST SEEN
benjoffe.com via Lobsters A faster way to calculate the day-of-the-week Open ↗