Memory Bandwidth Test

Benchmark application for measuring memory read/write bandwidth using PXL runtime and MU kernels.

Overview

The example in example/memory_test measures device memory read and write throughput. Each task accesses its own region of the allocation.

Use cases:

  • Evaluate memory bandwidth performance
  • Compare different memory access patterns
  • Benchmark system configuration changes

Build and Run

Build

cd example/memory_test
./build.sh

Run

./build/memory_test [options]

Options:

Option Description Default
-s Total memory size (GiB) 192
-t Number of parallel tasks 3072
-o Operation: read or write read
-i Number of iterations 1
-u Loop unrolling: 0 or 1 1
-b Requested Sub count (0 uses the runtime default) 0
-d Device ID 0
-p Extra bytes per task, rounded down to a multiple of 64 4096

Examples:

# Default test: 192 GiB read with 3072 tasks
./build/memory_test

# Write test with 64 GiB, 1024 tasks
./build/memory_test -s 64 -t 1024 -o write

# Compare with/without loop unrolling
./build/memory_test -s 128 -t 2048 -u 1
./build/memory_test -s 128 -t 2048 -u 0

The host rounds the base size per task down to a multiple of 64 bytes, then adds -p bytes. The kernel accesses the full resulting region, including the padding. The reported throughput therefore uses that adjusted allocation size and the iteration count. Use -p 0 to compare with an unpadded layout.

Output example (QEMU)

./build/memory_test -s 1 -p 0
=== Memory Bandwidth Test ===
Operation        : read
Device ID        : 0
Total Memory Size: 1023.94 MiB (1.00 GiB)
Task Count       : 3072
Size per Task    : 349504 bytes (341.31 KiB)
Stride Padding   : 0 bytes
Iterations       : 1
Use Unrolling    : 1
-----------------------------
Elapsed Time     : 35275.891 ms
Throughput       : 0.028 GiB/s (0.030 GB/s)
-----------------------------

Emulator timing includes software emulation overhead. Use hardware runs to measure device bandwidth.

Code Structure

main.cpp holds the host program and the memory_test kernel, and pxcc++ builds both.

Host Application

  1. Parse command-line arguments
  2. Initialize the PXL runtime
  3. Allocate memory and flush host cache
  4. Execute kernel across all tasks
  5. Measure time and calculate throughput

pxl::Launcher synchronizes the managed buffer around the kernel execution, so the reported elapsed time includes launch and synchronization overhead.

MU Kernel

  • Memory read/write operations
  • Loop unrolling optimization (8 x 64-bit accesses per iteration)
  • Per-task memory region calculation using mu::getTaskIdx()
  • Volatile buffer accesses, which keep the compiler from removing repeated reads or writes

Next Steps