S4 · Lesson 41 · Near-data and in-memory computing
Processing near memory, processing in memory, analog crossbars and when offloading pays
If moving a byte from DRAM costs far more time and energy than computing with it, then compute where the data is. Logic in the base die of a memory stack can use the stack's internal bandwidth; small processors inside DRAM chips can work on every bank at once; arrays of resistive memory cells can multiply a matrix by a vector in one analog step, using Ohm's and Kirchhoff's laws. Each trades generality and precision for bandwidth and energy, and each pays off only for the right fraction of a workload.
- The curve is the speedup from offloading the data-movement part of a kernel to near-memory logic: a fraction m of the time is data movement, made s times faster, plus an overhead o for launching and synchronizing: .
- Kernels dominated by data movement gain the most; compute-bound ones gain little and can lose to the overhead.
- The dashed line is the limit with free data movement, .
Predict
A 256 × 256 crossbar of resistive cells holds a weight matrix as conductances. Applying input voltages to its rows and reading every column's current (with its converter) takes 100 ns. How many multiply-accumulates does it perform per second?
Every cell multiplies its row voltage by its conductance (Ohm's law) and each column wire sums its cells' currents (Kirchhoff's current law): multiply-accumulates per read. At one read per 100 ns that's a second from one small array, with no weight ever moved.
Name it
Why move the compute
From lesson 27: reading a bit from DRAM costs about 10 to 20 pJ, while moving it a millimeter across a logic die costs about 0.1 pJ. Off-chip pins are scarce, but inside a memory chip or stack there are thousands of banks and very wide internal paths.
Processing near memory
Logic on the base die of a stacked memory (HBM, HMC) reaches the stack's banks through its through-silicon vias, with more bandwidth and less energy than the host's interface. Suitable for streaming kernels: scans, reductions, graph traversals.
Processing in memory
Simple processors placed beside DRAM banks work on their own bank's data in parallel. Aggregate bandwidth = number of banks × per-bank bandwidth, often ten times the host channels' bandwidth. Data must be laid out so each unit's work stays in its bank; moving data between units is slow.
Analog crossbars
A crossbar of resistive cells stores a matrix G as conductances. Driving row voltages gives column currents : a whole matrix-vector product in one step. The catches: converters (ADCs) to read the columns dominate area and energy, device variation and noise limit precision to a few bits, and writing new weights is slow.
When offloading pays
If a fraction m of a kernel's time is data movement that the near-data hardware speeds up by s, with an overhead o (as a fraction of the original time):
Amdahl's law again, with the offload's setup as part of the serial part.
Worked example
Moving a 64-bit word off-chip costs 15 pJ per bit; moving it 1 mm on a logic die costs 0.1 pJ per bit. How much energy does computing next to the memory save per word?
Show the solution
- Off-chip.
- On-die, 1 mm.
- Compare. The near-data unit spends 150 times less energy delivering each operand, which is why even modest logic beside memory can win on energy-limited workloads.
Answer computing next to the memory spends 6.4 pJ per word instead of 960 pJ, 150 times less.
Worked example
A processing-in-memory system has 2560 DRAM banks, each feeding its processor 1 GB/s. The host has 8 channels of 25.6 GB/s. Compare the bandwidths.
Show the solution
- In memory.
- Host.
- Compare. The in-memory units see 12.5 times the bandwidth, but only if each works on data in its own bank; anything that needs data from other banks goes back through the slow host path.
Answer 2.56 TB/s in memory against 205 GB/s for the host, 12.5 times as much.
Worked example
A kernel spends 70% of its time moving data. Near-memory logic makes that part 10 times faster but costs 5% of the original time in setup. What is the speedup?
Show the solution
- Speedup.
- The new bottleneck. The compute part, 30% of the original time, now dominates; even infinitely fast data movement would give only
Answer the speedup is 2.38.
Check
An n × n crossbar (n = 128) performs one matrix-vector product per 50 ns, using 10 nJ per product, converters included.
(a)
How many multiply-accumulates does it perform per second?
(b)
What energy does each multiply-accumulate cost?
Write units the way you normally would: 1.5 fJ and 0.0015 pJ are the same answer.
Check
A processing-in-memory system has 2560 banks, each feeding its unit 0.5 GB/s; the host has 8 channels of 38.4 GB/s.
(a)
What aggregate bandwidth do the in-memory units see?
(b)
How many times the host's bandwidth is that?
Check
A fraction 0.7 of a kernel's time is data movement that offloading speeds up 5 times, at an overhead of 0.1 of the original time.
(a)
What speedup results?
(b)
What is the most any speedup of data movement could give?
Check
Reading a bit from DRAM costs 15 pJ; moving a bit across a logic die costs 0.05 pJ per mm, and near-memory logic sits 5 mm from its data.
(a)
What does fetching a 64-bit word off-chip cost?
Write units the way you normally would: 1.5 pJ and 0.0015 nJ are the same answer.
(b)
How many times cheaper is delivering it to the near-memory logic?
Check
Why do analog crossbar accelerators usually compute at only a few bits of precision?
Check
A fraction m of a kernel's time is data movement, sped up s times by near-memory logic at an overhead o.
Step 1
What fraction of the original time does the offloaded kernel take?
Type it the way you would write it, like 3sin(2πft) or 3*sin(2*pi*f*t). Angles can be in radians or carry a degree sign, like 45°.
Step 2
What is the speedup?
Step 3
What does the speedup approach as s grows without bound?
Check
Write crossbar(G, v, bits): G is a list of rows of conductances in [0, 1] (siemens, scaled) and v a list of row voltages in [0, 1]; compute each column's exact current , then quantize it with a bits-bit converter spanning 0 to the number of rows (round to the nearest level). Return (exact currents, quantized currents).
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Explain why
Why can near-memory computing save energy even when its processors are slower than the host's?
In data-intensive programs most of the energy goes not into arithmetic but into moving data: each bit read from DRAM and driven across the board to the processor costs tens of picojoules, while an arithmetic operation on it costs a few. Logic placed beside the memory banks reads the same data over short internal wires, at a small fraction of that energy, and has far more internal bandwidth available than the pins provide. Even if each operation runs more slowly, the total energy falls because the expensive part, moving the data, mostly disappears; the processors can be simple because the work is limited by bandwidth rather than by computation.
Practice
Keep practicing
7 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.