◇Compute Lab

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
851.13 timesSpeedup against the stated baseline
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 processor reference across five rounds with fresh inputs and a prefilled output buffer.

Recorded measurements

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

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

Source material

Start with a real operating problem

What needs to work better?