Breaking
December 23, 2024

Faster Integer Division with Floating Point Al Williams | usagoldmines.com

Multiplication on a common microcontroller is easy. But division is much more difficult. Even with hardware assistance, a 32-bit division on a modern 64-bit x86 CPU can run between 9 and 15 cycles. Doing array processing with SIMD (single instruction multiple data)  instructions like AVX or NEON often don’t offer division at all (although the RISC-V vector extensions do). However, many processors support floating point division. Does it make sense to use floating point division to replace simpler division? According to [Wojciech Mula] in a recent post, the answer is yes.

The plan is simple: cast the 8-bit numbers into 32-bit integers and then to floating point numbers. These can be divided in bulk via the SIMD instructions and then converted in reverse to the 8-bit result. You can find several code examples on GitHub.

Since modern processors have several SIMD instructions, the post takes the time to benchmark many different variations of a program dividing in a loop. The basic program is the reference and, thus, has a “speed factor” of 1. Unrolling the loop, a common loop optimization technique, doesn’t help much and, on some CPUs, can make the loop slower.

Converting to floating point and using AVX2 sped the program up by a factor of 8X to 11X, depending on the CPU.  Some of the processors supported AVX512, which also offered considerable speed-ups.

This is one of those examples of why profiling is so important. If you’d had asked us if converting integer division to floating point might make a program run faster, we’d have bet the answer was no, but we’d have been wrong.

As CPUs get more complex, optimizing gets a lot less intuitive. If you are interested in things like AVX-512, we’ve got you covered.

 

This articles is written by : Nermeen Nabil Khear Abdelmalak

All rights reserved to : USAGOLDMIES . www.usagoldmines.com

You can Enjoy surfing our website categories and read more content in many fields you may like .

Why USAGoldMines ?

USAGoldMines is a comprehensive website offering the latest in financial, crypto, and technical news. With specialized sections for each category, it provides readers with up-to-date market insights, investment trends, and technological advancements, making it a valuable resource for investors and enthusiasts in the fast-paced financial world.

Recent:

E-Paper Anniversary Counter Is A Charming Gift With Minimal Power Draw Lewin Day | usagoldmines.com
DIY Camera Slider Moves And Rotates For Slick Shots Lewin Day | usagoldmines.com
Hackaday Links: December 22, 2024 Dan Maloney | usagoldmines.com
3D Printed Forklift Is A Cute Desk Toy Lewin Day | usagoldmines.com
240,000 Credit Union Customers Exposed As Hackers Access Trove of Sensitive Data: Report Alex Richar...
Optimizing Your Linux Shell Experience Al Williams | usagoldmines.com
Old 3D Printer Parts Repurposed Into DIY Camera Slider Lewin Day | usagoldmines.com
Dog Plays Chess on ESP32 Bryan Cockfield | usagoldmines.com
Vintage Audio Amp Gets LED Lighting Upgrade Lewin Day | usagoldmines.com
Inside a Diamond Plant Al Williams | usagoldmines.com
Nanoscale Imaging and Control of Altermagnetism in MnTe Maya Posch | usagoldmines.com
An LCD, Touch Sensor, USB-C, And A Microcontroller for a Buck Lewin Day | usagoldmines.com
Records of Nearly 1,000,000 Americans Exposed As Massive Data Breach Reveals Names, Phone Numbers, M...
The Bendix G-15 Runs 75,000 Lines of Code Adam Fabio | usagoldmines.com
Over $225,000,000 in Crypto Distributed To Hack Victims of Collapsed Exchange Cryptopia After Years ...
Custom Firmware For Even Cheaper Bluetooth Thermometers Tom Nardi | usagoldmines.com
8,358 Bank Customers Exposed As Billion-Dollar Lender Reveals Data Breach, Warns Social Security Num...
Intel Terminates X86S Initiative After Formation of New Industry Group Maya Posch | usagoldmines.com
Building A Custom Swiss Army Knife Lewin Day | usagoldmines.com
Training a Self-Driving Kart Bryan Cockfield | usagoldmines.com
JPMorgan Chase Refuses To Reimburse Customer After $7,000 Abruptly Drained From Bank Account: Report...
US Banks Witness 1,000% Surge in Digital Scams As JPMorgan Chase, Wells Fargo and Bank of America Cu...
Man Posing As Uber Driver Allegedly Steals Over $300,000 in Crypto From Unsuspecting Passengers: Rep...
Nigeria Arrests Nearly 800 Over ‘Pig Butchering’ Crypto Scam Targeting North Americans and Europeans...
Crypto Platforms Suffered $2,200,000,000 in Losses From Hacks in 2024 – But There’s a Catch: Chainal...
3D Printing A Big Lego Christmas Tree Lewin Day | usagoldmines.com
It’s Official: The North Pole is Moving Al Williams | usagoldmines.com
Rudolph’s Sleigh on a North Pole PCB Heidi Ulrich | usagoldmines.com
Making a Mechanical Watch From Scratch Is Fine Work Lewin Day | usagoldmines.com
Building a Diet Coke Button Lewin Day | usagoldmines.com
Embossing Leather With a Pipe Bender and 3D Printed Tooling Lewin Day | usagoldmines.com
Hackaday Podcast Episode 301: Hacking NVMe into Raspberry Pi, Lighting LEDs with Microwaves, and How...
Subchannel Stations: The Radio Broadcasts You Didn’t Know Were There Lewin Day | usagoldmines.com
Multimeter Gets Socket Upgrade To Use Nicer Probes Lewin Day | usagoldmines.com
Watch a 3D Scan Become a Car Body Model Donald Papp | usagoldmines.com
Old BBC Micro Gets Some Disk Help From A Raspberry Pi Lewin Day | usagoldmines.com
Getting Dial-Up To Work Over VOIP Isn’t Always Easy Lewin Day | usagoldmines.com
Fixing 1986 Sinclair Spectrum+2 With a High-Score of Issues Maya Posch | usagoldmines.com
Fibonacci Clock Looks Like Beautiful Modern Art Lewin Day | usagoldmines.com
Measuring a Well with Just a Hammer and a Smartphone Dan Maloney | usagoldmines.com
The Battle Over Vanishing Spray Lewin Day | usagoldmines.com
Better C Strings, Simply Al Williams | usagoldmines.com
Human Civilization and the Black Plastic Kitchen Utensils Panic Maya Posch | usagoldmines.com
Where This Xmas Card’s Going, We Don’t Need Batteries! Jenny List | usagoldmines.com
Homebrew Electron Beam Lithography with a Scanning Electron Microscope Dan Maloney | usagoldmines.co...
Back to the Future of Texting: SMS on a Panasonic Typewriter Heidi Ulrich | usagoldmines.com
Bacterium Demonstrates Extreme Radiation Resistance Courtesy of an Antioxidant Maya Posch | usagoldm...
Simple Fluorometer Makes Nucleic Acid Detection Cheap and Easy Dan Maloney | usagoldmines.com
FLOSS Weekly Episode 813a: Happy Holidays! Jonathan Bennett | usagoldmines.com
Push for On, Hold for Off, AC Edition Al Williams | usagoldmines.com
Upper Room UV-C Keeps Air Cleaner Lewin Day | usagoldmines.com
Enabling NVMe on the Raspberry Pi 500 With a Handful of Parts Maya Posch | usagoldmines.com
Why Did Early CD-ROM Drives Rely On Awkward Plastic Caddies? Lewin Day | usagoldmines.com
Catching the View from the Edge of Space Dan Maloney | usagoldmines.com
Learning About The Flume Water Monitor Lewin Day | usagoldmines.com
Pulling Backward to Go Forward: The Brennan Torpedo Explained Donald Papp | usagoldmines.com
The World Morse Code Championship Al Williams | usagoldmines.com
PCB Motor Holds Fast, Even After 1.6 Billion Spins Donald Papp | usagoldmines.com
A Compass That Looks to the Stars Bryan Cockfield | usagoldmines.com
Why NASA Only Needs Pi To So Many Decimal Places Lewin Day | usagoldmines.com
Tech in Plain Sight: Table Saw Safety Al Williams | usagoldmines.com
The Last Acorn BBC Computer Wasn’t a BBC Micro Jenny List | usagoldmines.com
Man Overboard Systems Aim To Increase Survival Rates At Sea Lewin Day | usagoldmines.com
See What ‘They’ See In Your Photos Lewin Day | usagoldmines.com
3D Printed Blaster Does it with Compliant Components Donald Papp | usagoldmines.com
Robot Air Hockey Player Predicts Your Next Move Lewin Day | usagoldmines.com
Versatile, yet Grounded: The Rotodyne Revisited Heidi Ulrich | usagoldmines.com
Emulating The Battery Controller In An Ancient Acer PDA Lewin Day | usagoldmines.com
Using A Smartphone As A Touchscreen For Arduino Lewin Day | usagoldmines.com
3D-Printed Boat Feeds The Fishes Lewin Day | usagoldmines.com
Sony Vaio Revived: How Does One Start? Arya Voronova | usagoldmines.com
A Red Ring Light Show For Your Xbox 360 Lewin Day | usagoldmines.com
Keebin’ with Kristina: the One With the Curvy Centerfold Kristina Panos | usagoldmines.com
Building the Spectacular Fibonacci128 Simple Add-On Tom Nardi | usagoldmines.com
Single Crystal Electrode Lithium Ion Batteries Last a Long Time Al Williams | usagoldmines.com
Documented Source Code for Elite on the C64, BBC Micro and Others Maya Posch | usagoldmines.com
Finally… a Man Page for Life Al Williams | usagoldmines.com
Hackaday Links: December 15, 2024 Dan Maloney | usagoldmines.com
Rainwater From the Road to the Garden Bryan Cockfield | usagoldmines.com
Wago Terminals Make This Ham Radio Dipole Light and Packable Dan Maloney | usagoldmines.com
An iPhone Case Study Bryan Cockfield | usagoldmines.com
ESP8266 Keeps Tabs on Wood Stove Temperature Tom Nardi | usagoldmines.com
Running Fusion 360 on Linux with Wine Maya Posch | usagoldmines.com
A Portable Chainsaw Sawmill Bryan Cockfield | usagoldmines.com
Might Morphin’ Antenna Al Williams | usagoldmines.com
How the Lost Mystery Pigment ‘Maya Blue’ Got Recreated Donald Papp | usagoldmines.com
Behold a Geared, Continuously Variable Transmission Donald Papp | usagoldmines.com
tldr-pages Keeps it Short, Wherever You Need It Tom Nardi | usagoldmines.com
Hacker Tools, Hacked Tools Elliot Williams | usagoldmines.com
A Self Balancing Bike for Crash Dummy Billy Al Williams | usagoldmines.com
Personal Traffic Light Stops Them In Their Tracks Kristina Panos | usagoldmines.com
Origami-Inspired, Self-locking Structures With 3D Printing Donald Papp | usagoldmines.com
Walkie Talkies, Jedi Style: Building a Communicator Heidi Ulrich | usagoldmines.com
Flashy Paper Christmas Tree Does It With a 555 Kristina Panos | usagoldmines.com
Apple Newton Gets Rebuilt Battery Pack Bryan Cockfield | usagoldmines.com
The Stern-Gerlach Experiment Misunderstood Al Williams | usagoldmines.com
Hack On Self: How’d My Day Go? Arya Voronova | usagoldmines.com
Saving an Electron Microscope from the Trash Maya Posch | usagoldmines.com
Hackaday Podcast Episode 300: The Dwingeloo 25 m Dish, a Dead-Tech Twofer, and Deconstructing PCBs K...
This Week in Security: Recall, BadRAM, and OpenWRT Jonathan Bennett | usagoldmines.com

Leave a Reply