Kernel engineering

Reducing contention in a histogram kernel

A change to the counting method reduced runtime on a skewed histogram workload.

67,108,864Input keys
4,096Output bins
0.1015 msBlock-local counts, down from 86.3898 ms

RUNTIME COMPARISON

Runtime comparisonMI300X

Skewed integer histogram

Stated baseline86.3898 ms
Block-local counts0.1015 ms
67,108,864 keys · 4,096 bins · ROCm 7.2.4

Recorded results. Select a series to inspect it.

AMD Instinct MI300X VF

The baseline took 86.3898 ms and the revised kernel took 0.1015 ms on the same card.

The measurement uses a skewed integer histogram under ROCm 7.2.4. The speedup compares these two implementations on that workload.

The problem

Many input keys reached the same histogram bins, so global atomic updates competed for those locations.

The method

The baseline made one global atomic update per key. The revised kernel counted within each block and merged those counts.

Validation

The revised kernel matched the CPU reference across five rounds with fresh inputs and a prefilled output buffer.

Recorded measurements

Replay the recorded run and check its Ed25519 receipt in your browser: type computelab verify mi300x.

MethodRecorded result
Global atomic baseline86.3898 ms
Larger block and vector loads86.3963 ms
Wave aggregated atomics73.2241 ms
Block local counts and merge0.1015 ms

Source material

The four-method timing table is published directly on this page above; the external Hugging Face dataset repository below hosts the raw CSV archive (Hugging Face dataset access sign-in required).

Start with an operating problem

What needs to work better?