Memories: The Corners of Your Mind

Vinnie doesn’t let go of a question. “OK, Robert, I got that a computer’s internal network is sorta like a horse’s sinews, tying muscle and bone together. An’ I got that a computer’s processors of whichever kind are like a horse’s muscles. But what does for a computer what bones do for a horse?”

“The ‘bones’ are a bit of a stretch, Vinnie. Data’s one possibility, memory or storage is the other one.”

Vinnie takes the bait. “Horse muscles move horse bones. The processors move data, so data’s got to be the bones.”

For the sake of argument, I come back. “But when the electricity turns off, the data goes away, right? Memory’s still there, so memory must be the bones. Or is it storage? What’s the difference between memory and storage?”

“You’ve put your finger on it, Sy — persistence. If the data’s retained when the power’s off, like on a hard drive, it’s in storage. Otherwise it’s in memory. Setting aside power glitches, of course — a bad glitch can even kill some kinds of storage and the data it’s holding, which is one reason for doing backups. As a general rule, memory is smaller, more expensive and much faster than storage so there’s a trade-off. If you want a lot of speed, load up on fast memory but it’ll cost you cash and resilience.”

“I’ll bet that’s where your special skills come in handy, right, Robert?”

“Pretty much, Vinnie. The trick is to get the right data into the right kind of memory at the right time.”

“The right kind…?”

“Ohhhyeah, there’s a whole hierarchy out there — on-chip memory essentially inside the processor, on-board memory on separate chips, off-board memory and storage…. It goes on all the way out to The Cloud if you’re set up that way. There’s even special memory for keeping track of which data is where in the other memories. The internal network plays into it, too — the data bus to a given memory could be just a byte wide or many times fatter, which makes a big difference in access speed. The hardware takes care of some data placement automatically, but a lot of it we can affect with the software. That’s mostly where I come in.”

Horse skeleton from Wikimedia Commons by CC license

“Doin’ what? The hardware’s pretty much what your boss already bought, not much you can tinker with there. The bits are zoomin’ around inside at electronic speeds, you can’t pick and choose where to put ’em.”

“Yes, we can, if we’re smart and careful. You know Michael Corleone’s line, ‘Keep your friends close but your enemies closer‘? With us it’s ‘Keep your next data byte close but your next program instruction closer.'”

The Memory Pyramid

“Whuzzat mean?”

“What you want to do is have bytes ready for the processor as soon as it’s ready to work with them. That means predicting which bytes it’ll want next and getting those to the top of the memory pyramid. Programs do a lot of short loops, enough that standard architectures have separate instruction memories just for that.”

“So how do you do that predicting? Like Vinnie said, things move fast in there.”

“You design for patterns. My favorite is sequential-and-discard. When you’re watching a movie you look at frames in series and you rarely go back. In the computer we deliver sequential bytes in an orderly manner to fast memory but we don’t have to worry about storing them back out again. Easy-peasy. Sequential-and-store is also highly predictable but then you have to down-copy, too.”

“Yeah, either way the data just flows through. What others?”

Periodic is useful if you can arrange your program and data to exploit it. If you know a just-used series of bytes are going to be relevant again soon, you try to reserve enough close-in memory to hold onto them. Data references tend to spread out but sometimes you can tilt the odds by clumping together related bytes that are likely to be used together — like all weather data for one location.”

“What if you don’t have any of those patterns?”

“Worst case scenario. You guess periodic, buy lots of memory and cross your fingers.”

~~ Rich Olcott

Computer Power, Or Not

A voice from the scone line behind me. “That’s like poetical, sayin’ a horse’s sinews tie muscle to bone and a computer’s internal network is like sinew ’cause it ties things together the same way. But what does for the computer what muscle and bone do for a horse? Hi, Robert, I’m Vinnie, me and Sy here go way back. I’ll have a strawberry scone, Al, and these guys are on me.”

“Sure thing, Vinnie, here ya go.”

“Thanks, Al.” “Thanks, Vinnie.” “Thanks — Vinnie, is it?”

“Yeah. Glad to meetcha. So what are they?”

“The computer equivalent of horse muscle and bone? Well, the horse’s muscle activity generates its power so the computer’s ‘muscles’ are clearly its processors.”

Horse musculature from artwork by Jenny Stout, with permission

“Processors, plural? My heavy-duty desk machine only has one CPU thingy in there, I looked.”

“Only one chip package, Sy, but there’s a lot inside that black block. Your ‘Central Processing Unit’ is probably multi-core, which means it has somewhere between four and dozens of more-or-less independent sub-processors, each with its own set of registers and maybe even local cache memories. If your operating system is multi-core-aware, at any given moment your system could be running a different program on each core.”

“Hey, you’re right, I often download emails and browse the internet at the same time I’ve got a big calculation going. Doesn’t seem to slow it down.”

“Mm-hm. I like to call those cores eccentric processing units because they’re not really central.” <Vinnie pretends to grab Robert’s scone.> “You’ve got a video card in there, too, right?”

“Of course.”

“This may come as a shock, but you probably have more raw compute power on that card than you do in your CPU module. The card’s primary chip has hundreds of millions of transistors allocated to hundreds or thousands of simple-minded micro-micro-processors ganged together to do identical calculations on separate inputs. Rotating a 3-D object, for example, requires four multiplications and an addition for each x-, y- and z-coordinate of every point on the object. No if-then logic, just a very small arithmetic program repeated a gazillion times.”

“So the main CPU doesn’t have to do that.”

“Right. Same principle, you may have ASICs in there devoted to certain tasks like network interfacing.”

“A-six?”

Application Specific Integrated Circuits. They’re everywhere from your smartphone to your hobby drone.”

“Don’t have a hobby drone, use mine for business.”

“OK, your business drone, Vinnie. Your drone and its controller both use ASICs.”

“How will the quantum computer play into this, Robert? I’ve been reading how it automagically tries all possible solutions and instantly comes up with the one that solves the problem.”

“That’s hype, mostly. Quantum computing could indeed give quick solutions, but to a very limited set of problems. For instance, everyone talks about factoring special large numbers. When QC succeeds in that it’ll disrupt internet security, cryptography, blockchain applications and a couple more not-here-yet technologies that depend on factorization being hard to do. But QC can only tackle problems that involve a small amount of data. It’s no good for Big Data kinds of problems like weather modeling or fingerprint matching or rummaging through a medical database to find the optimal treatment for a given collection of clinical findings.”

“Why’s that?”

“A quantum CPU works with a set of constraints and inputs. It does its tryeverything thing to generate an output that’s consistent with the constraints and input. The factorization constraint, for example, is just one algorithm. The input is a single number. The output is one set of factors. Compare that with the weather problem where the goal is to calculate the future weather for every kilometer-by-kilometer-by-kilometer cell of atmosphere on the globe. The constraint is a whole series of equations governing atmospheric gases (especially water) together with the topography of the underlying surface. Each cell’s input is all the measurable weather variables (temperature, humidity, wind velocity, clouds, whatever) plus history for that cell and its neighbors. The output per time-step is predicted weather variables for a billion cells. Quantum’s no help with that data flood — you need good networks.”

~~ Rich Olcott

The Lengths We Go To

A new face in the scone line at Al’s coffee shop. “Morning. I’m Sy Moire, free-lance physicist and Al’s steadiest customer. And you’re…?”

“Robert Tobanu, newest Computer Science post-doc on Dr Hanneken’s team. He needed some help improving the performance of their program suite.”

“Can’t he just buy a faster computer?”

“He could if there is a faster computer, if his grant could afford its price tag, and if it’s faster in the way he needs to solve our problems. My job is to squeeze the most out of what we’ve got on the floor.”

“I didn’t realize that different kinds of problem need different kinds of computer. I just see ratings in terms of mega-somethings per second and that’s it.”

“Horse racing.”

“Beg pardon?”

“Horse speed-ratings come from which horse wins the race. Do you bet on the one with the strongest muscles? The one with the fastest out-of-the-box time? The best endurance? How about Odin’s fabulous eight-legged horse?”

“Any of the above, I suppose, except for the eight-legged one. What’s this got to do with computers?”

“Actually, eight-legged Sleipnir is the most interesting example. But my point is, just saying ‘This is a 38-mph horse‘ leaves a lot of variables up for discussion. It doesn’t tell you how much better the horse would do with a more-skilled jockey. It doesn’t say how much worse the horse would do pulling a racing sulky or a fully-loaded Conestoga. And then there’s the dash-versus-marathon aspect.”

“I’m thinking about Odin’s horse — power from doubled-up legs would be a big positive in a pulling contest, but you’d think they’d just get in the jockey’s way during a quarter-mile dash.”

“Absolutely. All of that’s why I think computer speed ratings belong in marketing brochures, not in engineering papers. ‘MIPS‘ is supposed to mean ‘Millions of Instructions Per Second‘ but it’s actually closer to ‘Misleading Indication of Processor Speed.'”

“How do they get those ratings in the first place? Surely no-one sat there and actually counted instructions as the thing was running.”

“Of course not. Well, mostly not. Everything’s in comparison to an ancient base-case system that everyone agreed to rate at 1.0 MIPS. There’s a collection of benchmark programs you’re supposed to run under ‘standard‘ conditions. A system that runs that benchmark in one-tenth the base-case time is rated at 10 MIPS and so on.”

“I heard voice-quotes around ‘standard.’ Conditions aren’t standard?”

“No more than racing conditions are ever standard. Sunny or wet weather, short-track, long-track, steeplechase, turf, dirt, plastic, full-card or two-horse pair-up — for every condition there are horses well-suited to it and many that aren’t. Same thing for benchmarks and computer systems.”

“That many different kinds of computers? I thought ‘CPU‘ was it.”

Horse photo by Helena Lopes on Unsplash

“Hardly. With horses it’s ‘muscle, bone and sinew.’ With computers it’s ‘processor, storage and network.’ In many cases network makes or breaks the numbers.”

“Network? Yeah, I got a lot faster internet response when I switched from phone-line to cable, but that didn’t make any difference to things like sorting or computation that run just within my system.”

“Sure, the external network impacts your upload and download performance, but I’m talking about the internal network that transports data between your memories and your processors. If transport’s not fast enough you’re wasting cycles. Four decades ago when the Cray-1’s 12.5-nanosecond cycle time was the fastest thing afloat, the company bragged that it had no wire more than a meter long, Guess why.”

“Does speed-of-light play into it?”

“Well hit. Lightspeed in vacuum is 0.3 meters per nanosecond. Along a copper wire it’s about 2/3 of that, so a signal takes about 5 nanoseconds each way to traverse a meter-long wire. Meanwhile, the machine’s working away at 12.5 nanoseconds per cycle. If it’s lucky and there’s no delay at the other end, the processor burns a whole cycle between making a memory request and getting the bits it asked for. Designers have invented all sorts of tricks to get those channels as short as possible.”

“OK, I get that the internal network’s important. Now, about that eight-legged horse…”

~~ Rich Olcott

  • Thanks to Richard Meeks for asking an instigating question.

Better A Saber Than A Club?

There’s a glass-handled paper-knife on my desk, a reminder of a physics experiment gone very bad back in the day. “Y’know, Vinnie, this knife gives me an idea for another Star Trek weapons technology.”

“What’s that, Sy?”

“Some kinds of wave have another property in addition to frequency, amplitude and phase. What do you know about seismology?”

“Not a whole lot. Uhh … earthquakes … Richter scale … oh, and the Insight lander on Mars has seen a couple dozen marsquakes in the first six months it was looking for them.”

“Cool. Well, where I was going is that earthquakes have three kinds of waves. One’s like a sound wave — it’s called a Pwave or pressure wave and it’s a push-pull motion along the direction the wave is traveling. The second is called an Swave or shear wave. It generates motion in some direction perpendicular to the wave’s path.”

“Not only up-and-down?”

“No, could be any perpendicular direction. Deep in the Earth, rock can slide any which-way. One big difference between the two kinds is that a Pwave travels through both solid and molten rock, but an Swave can’t. Try to apply shearing stress to a fluid and you just stir it around your paddle. The side-to-side shaking isn’t transmitted any further along the wave’s original path. The geophysicists use that difference among other things to map out what’s deep below ground.”

“Parallel and perpendicular should cover all the possibilities. What’s the third kind?”

“It’s about what happens when either kind of deep wave hits the surface. A Pwave will use up most of its energy bouncing things up and down. So will an Swave that’s mostly oriented up-and-down. However, an Swave that’s oriented more-or-less parallel to the surface will shake things side-to-side. That kind’s called a surface wave. It does the most damage and also spreads out more broadly than a P- or Swave that meets the surface with the same energy.”

“This is all very interesting but what does it have to do with Starfleet’s weapons technology? You can’t tell a Romulan captain what direction to come at you from.”

“Of course not, but you can control the polarization angle in your weapon beams.”

“Polarization angle?”

Plane-polarized electromagnetic wave
Electric (E) field is red
Magnetic (B) field is blue
(Image by Loo Kang Wee and
Fu-Kwun Hwang from Wikimedia Commons)

“Yeah. I guess we sort of slid past that point. Any given Swave vibrates in only one direction, but always perpendicular to the wave path. Does that sound familiar?”

“Huh! Yeah, it sounds like polarized light. You still got that light wave movie on Old Reliable?”

“Sure, right here. The red arrow represents the electric part of a light wave. Seismic waves don’t have a magnetic component so the blue arrow’s not a thing for them. The beam is traveling along the y‑axis, and the electric field tries to move electrons up and down in the yz plane. A physicist would say the light beam is planepolarized. Swaves are polarized the same way. See the Enterprise connection?”

“Not yet.”

“Think about the Star Trek force-projection weapons — regular torpedoes, photon torpedoes, ship-mounted phasers, tractor beams, Romulan pulse cannons and the like. They all act like a Pwave, delivering push-pull force along the line of fire. Even if Starfleet’s people develop a shield-shaker that varies a tractor beam’s phase, that’s still just a high-tech version of a club or cannon ball. Beamed Swaves with polarization should be interesting to a Starfleet weapons designer.”

“You may have something. The Bridge crew talks about breaking through someone’s shield. Like you’re using a mace or bludgeon. A polarized wave would be more like an edged knife or saber. Why not rip the shield instead? Those shields are never perfect spheres around a ship. If your beam’s polarization angle happens to match a seam where two shield segments come together — BLOOEY!”

“That’s the idea. And you could jiggle that polarization angle like a jimmy — another way to confuse the opposition’s defense system.”

“I’m picturing a Klingon ship’s butt showing through a rip in its invisibility cloak. Haw!”

~~ Rich Olcott