AVX-512: When The Bits Really Count

For the majority of workloads, fiddling with assembly instructions isn’t worth it. The added complexity and code obfuscation generally outweigh the relatively modest gains. Mainly because compilers have become quite fantastic at generation code and because processors are just so much faster, it is hard to get a meaningful speedup by tweaking a small section of code. That changes when you introduce SIMD instructions and need to decode lots of bitsets fast. Intel’s fancy AVX-512 SIMD instructions can offer some meaningful performance gains with relatively low custom assembly.

Like many software engineers, [Daniel Lemire] had many bitsets (a range of ints/enums encoded into a binary number, each bit corresponding to a different integer or enum). Rather than checking if just a specific flag is present (a bitwise and), [Daniel] wanted to know all the flags in a given bitset. The easiest way would be to iterate through all of them like so:

while (word != 0) {
  result[i] = trailingzeroes(word);
  word = word & (word - 1);
  i++;
}

The naive version of this look is very likely to have a branch misprediction, and either you or the compiler would speed it up by unrolling the loop. However, the AVX-512 instruction set on the latest Intel processors has some handy instructions just for this kind of thing. The instruction is vpcompressd and Intel provides a handy and memorable C/C++ function called _mm512_mask_compressstoreu_epi32.

The function generates an array of integers and you can use the infamous popcnt instruction to get the number of ones. Some early benchmark testing shows the AVX-512 version uses 45% fewer cycles. You might be wondering, doesn’t the processor downclock when wide 512-bite registers are used? Yes. But even with the downclocking, the SIMD version is still 33% faster. The code is up on Github if you want to try it yourself.

All The Sticky Labels You Could Ever Need: No DRM, Just Masking Tape

Printable sticky labels are a marvelous innovation, but sadly also one beset by a variety of competing offerings, and more recently attempts by manufacturers to impose DRM on their media. Fortunately they don’t have to rely on expensive printers or proprietary rolls of stickies, as [michimartini] demonstrates with the masking tape plotter. It’s a tiny pen plotter that writes your label onto the tape.

At its heart is the popular grbl G-code to motion parser, and its mechanism uses the lead screw axis from a DVD drive. Not for this project simply another hacked-apart drive mechanism though, for it has a custom-designed carriage for the axis. It’s 3D printed, and to ensure the least friction possible for a pen using only its weight to keep contact with the tape it was heated up once assembled to ensure all parts had a chance to bed in. Meanwhile the tape roll forming the X axis is turned directly by a standard stepper motor.

We like this project a lot, and look forward to any refinements to the idea. Meanwhile, it’s not the first custom label printer we’ve shown you.

A Raspberry Pi As An Offboard Display Adapter

The humble USB-C port has brought us so many advantages over its USB ancestors, one of which is as a handy display output for laptops. Simply add an inexpensive adapter and you can hook up everything from a mobile phone upwards to an HDMI display or projector. There’s a snag though, merely having USB-C is not enough as the device has to support the display feature. It’s a problem [Gunnar Wolf] had to face with a Lenovo ARM laptop, and his solution is unexpected. Instead of an adapter, he’s used a Raspberry Pi 3 and some software tricks.

The obvious route to an off-board Pi mirroring onboard video is to use VNC, which he tried but found wanting due to lagginess. As a user of the Wayland compositor he found he could instead use wf-recorder and send its output to a stream, and thus capture his screen in a way that the Pi could read over the network. It’s not quite as convenient a solution as a pure-hardware adapter, but at least it allowed him to share the screen.

It’s surprising how often we find projects needing to mirror the display of a computer using what hardware is to hand, at least this one is more elegant than some others.

Autogyro Models Are Hard — Even For [Peter Sripol]

Aviation consists of two major groups. Airplane enthusiasts, and helicopter enthusiasts. The two groups rarely get along, each extolling the virtues of their chosen craft. Somewhere in between are autogyro folks. People who like vehicles that blend the best (or worst) of both airplanes and helicopters. Aviation master [Peter Sripol] has dipped his toes into the autogyro world, but not without some trouble.

Autogyros are propelled by a propeller, like a plane. They also have a tail section that works similar to a fixed-wing aircraft. That’s where the similarities end though. Lift for autogyros comes in the form of a rotating set of blades, much like a helicopter. Autogyro rotors aren’t powered during flight. They utilize autorotation. The blades freewheel, spun by the air as the craft moves forward.

[Peter] recently got his hands on a full-scale autogyro. So it made sense to build a model to help learn to fly. This isn’t [Peter’s] first attempt with autogyro models. He’s built a few in the past, with limited success. This time he started from scratch and ran into even more problems!

Continue reading “Autogyro Models Are Hard — Even For [Peter Sripol]”

How A Smartphone Is Made, In Eight “Easy” Blocks

The smartphone represents one of the most significant shifts in our world. In less than thirteen years, we went from some people owning a dumb phone to the majority of the planet having a smartphone (~83.7% as of 2022, according to Statista). There are very few things that a larger percentage of people on this planet have. Not clean water, not housing, not even food.

How does a smartphone work? Most people have no idea; they are insanely complicated devices. However, you can break them down into eight submodules, each of which is merely complex. What makes them work is that each of these components can be made small, at massive economies of scale, and are tightly integrated, allowing easy assembly.

So without further ado, the fundamental eight building blocks of the modern cellphone are: the application processor, the baseband processor, a SIM card, the RF processor, sensors, a display, cameras & lenses, and power management. Let’s have a look at them all, and how they fit together.

Continue reading “How A Smartphone Is Made, In Eight “Easy” Blocks”

Verbot Goes To The Dark Side

What happens to old, neglected 1980s toy robots? According to the [Randi Rain], they turn to the dark side! Way back in the ’80s, Tomy had an entire line of robots — from keychain wind-up toys to rolling, talking machines almost 2 feet tall. Tucked into the middle of this line was Verbot. Verbot’s claim to fame is that it is a voice-controlled robot. More than that, it was speaker-dependent. Train the robot with commands like “go forward” and then watch as it responds to your every command.

As you might guess, the speech recognition wasn’t great by today’s standards. Recognition was handled by a Microcontroller — a Mitsubishi product that was possibly a mask programmed 8051 variant. Pretty novel for an 80s toy — in fact, there’s a patent for it.

Continue reading “Verbot Goes To The Dark Side”

Will We Ever Shake The Polaroid Picture?

Today, most of us carry supercomputers in our pockets that happen to also take instantly-viewable pictures.This is something that even the dumbest phones do, meaning that we can reasonably draw the conclusion that photographic capability has become a basic feature of everyday carry, a necessity of 21st century life.

Despite the unwashed masses of just-plain-bad photographs clouding the digital landscape, photography itself remains as important as ever so we can retain and disseminate information as history unfolds. In a sense, the more instant, the better — unless it comes at the cost of image quality. The invention of photography is on par with the printing press or with language itself in that all three allow us to communicate within our own time as well as preserve The Way Things Were in frozen silence. And no invention made vivid preservation more convenient than the instant camera.

Continue reading “Will We Ever Shake The Polaroid Picture?”