BW_MEM_CP(8)

NAME
bw_mem_cp - time memory copy speeds

SYNOPSIS
bw_mem_cp size rd|wr|rdwr|cp|fwr|frd|fcp|bzero|bcopy [unaligned]

DESCRIPTION
bw_mem measures memory bandwidth for a variety of memory operations, such as read, write, and copy. Results are reported in megabytes per second.

The size specification may end with ``k'' or ``m'' to mean kilobytes (* 1024) or megabytes (* 1024 * 1024).

The optional unaligned parameter ensures that the source and destination arrays are not aligned, and it only affects the rdwr, cp, and fcp benchmarks.

The illustrative code fragments included in the descriptions below are a simplification of the actual code included in the benchmark. The benchmark code includes a large number of the desired operation inside the inner loop to ensure that the loop overhead is less than 1%.

rd  measures the bandwidth for reading data into the processor. It computes the sum of an every fourth element of an integer array.

        for (i = 0; i < N; i += 4) sum += array[i];

wr  measures the bandwidth for writing data to memory. It assigns a constant value to every fourth element of an integer array.

        for (i = 0; i < N; i += 4) array[i] = 1;

rdwr
    measures the bandwidth for reading data into memory and then writing data to the same memory location. For every fourth element in an array it adds the current value to a running sum before assigning a new (constant) value to the element.

        for (i = 0; i < N; i += 4) {
            sum += array[i];
            array[i] = 1;
        }

cp  measures the bandwidth for copying data from one location to another. It does an array copy and it only accesses every fourth word.

        for (i = 0; i < N; i += 4) dest[i] = source[i];

frd measures the bandwidth for reading data into the processor. It computes the sum of an array of integer values.

        for (i = 0; i < N; i++) sum += array[i];

fwr measures the bandwidth for writing data to memory. It assigns a constant value to each member of an array of integer values.

        for (i = 0; i < N; i++) array[i] = 1;

fcp measures the bandwidth for copying data from one location to another. It does an array copy: dest[i] = source[i].

        for (i = 0; i < N; i++) {
            sum += array[i];
            array[i] = 1;
        }

bzero
    measures how fast the system can bzero memory.

bcopy
    measures how fast the system can bcopy data.

OUTPUT
Output format is "%0.2f %.2f\n", megabytes, megabytes_per_second, i.e.,

8.00 25.33

MEMORY UTILIZATION
This benchmark can move up to three times the requested memory. Bcopy will use 2-3 times as much memory bandwidth: there is one read from the source and a write to the destionation. 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'').

SEE ALSO
lmbench(8).