BW_MEM(8)

πŸ’– BW_MEM β€” like, the whole vibe πŸ’–

okay bestie, gather round, because we're about to talk about bw_mem from the LMBENCH crew (section 8, system admin girlies only πŸ’…). it's literally a memory bandwidth timer. that's it, that's the girl. ✨


✨ NAME ✨

bw_mem β€” it times your memory bandwidth, no cap 🧠πŸ”₯


πŸ¦‹ SYNOPSIS πŸ¦‹

bw_mem_cp [ -P <parallelism> ] [ -W <warmups> ] [ -N <repetitions> ]
size rd|wr|rdwr|cp|fwr|frd|bzero|bcopy [align]
yes the synopsis says bw_mem_cp and yes we are keeping it exactly like that. i don't make the rules, i just obey them 🫢

🌸 DESCRIPTION 🌸

so here's the tea πŸ“: bw_mem allocates twice the amount of memory you asked for, zeroes it all out, and then times how long it takes to copy the first half into the second half. results come back in megabytes moved per second. it's giving speed test but make it memory.

the size you pass can end with k or m, which means kilobytes (* 1024) or megabytes (* 1024 * 1024). k? m? iconic abbreviations, we love to see it. πŸ‘‘


πŸ’… OUTPUT πŸ’…

the output format is "%0.2f %.2f\n", and it spits out megabytes then megabytes_per_second, like this:

8.00 25.33

there are nine different memory benchmarks hiding inside bw_mem, and each one measures a slightly different way of reading, writing, or copying data. nine. a whole squad. let's meet them 🫢

  • rd β€” measures the time to read data into the processor. it computes the sum of an array of integer values. and it accesses every fourth word. (every fourth word. she's picky and i respect it.)
  • wr β€” measures the time to write data to memory. it assigns a constant value to each memory of an array of integer values. it accesses every fourth word.
  • rdwr β€” measures the time to read data into memory and then write data to the same memory location. for each element in an array it adds the current value to a running sum before assigning a new (constant) value to the element. it accesses every fourth word. read, write, read, write β€” main character energy, honestly.
  • cp β€” measures the time to copy data from one location to another. it does an array copy: dest[i] = source[i]. it accesses every fourth word.
  • frd β€” measures the time to read data into the processor. it computes the sum of an array of integer values.
  • fwr β€” measures the time to write data to memory. it assigns a constant value to each memory of an array of integer values.
  • fcp β€” measures the time to copy data from one location to another. it does an array copy: dest[i] = source[i].
  • bzero β€” measures how fast the system can bzero memory.
  • bcopy β€” measures how fast the system can bcopy data.
ngl bestie, if you clocked that the synopsis lists cp but the benchmark list also has fcp β€” yes. both exist. both are real. we are not merging them, that would be a crime πŸ’€

πŸŽ€ MEMORY UTILIZATION πŸŽ€

this is the part where we keep it real. this benchmark can move up to three times the requested memory. bcopy will use 2-3 times as much memory bandwidth: there's one read from the source and a write to the destination. the write usually results in a cache line read and then a write back of the cache line at some later point. πŸ’«

memory utilization might be reduced by 1/3 if the processor architecture implemented load cache line and store cache line instructions (as well as getcachelinesize). so, like, a third off. noted. 🧚


πŸ‘‘ SEE ALSO πŸ‘‘


🌈 AUTHOR 🌈

Carl Staelin and Larry McVoy

comments, suggestions, and bug reports are always welcome. (they literally said "always welcome" β€” so go off, bestie, send that feedback 🫢)


and that's the whole page, fr fr πŸ’œ this was BW_MEM(8) from LMBENCH, brought to you by the copyright girlies: Β©1994-2000 Larry McVoy and Carl... and stamped with a very mysterious $Date$. slay, periodt. ✨πŸ’