﻿# Include address arithmetic in a memory-kernel profile

Trace compiled address calculations and prove index ranges before attributing a gather kernel to bandwidth or narrowing its arithmetic.

Author: Retrivium editorial team
Updated: 2026-11-03
Canonical URL: https://retrivium.ai/journal/guide-perf-integer-address/
Language: en

A gather kernel moves few values yet spends substantial execution effort calculating their addresses. Calling it a memory kernel does not prove that external-memory bandwidth limits it. Trace the index calculations feeding the expensive loads before changing the data format or purchasing a bandwidth explanation from a low arithmetic-intensity label.

## Map one logical lookup

Write the mapping from logical record, head and feature coordinates to an element offset and then a byte address. Include page or row strides, indirection tables, boundaries and element size. Repeated divisions, remainders and conversions can belong to that mapping even when the source line appears to contain only an array access.

## Inspect the compiled path

Use line information and the profiler's source and instruction views to associate address-producing instructions with the load that consumes them. Read the final device code, not just an intermediate PTX listing. PTX is a virtual instruction set translated for the target; its instruction count is not a direct count of executed native instructions or their cost.

## Preserve width and range

PTX documents integer operations with low, high and widened results. These distinctions explain why a multiplication used for an address may require a particular width. Do not narrow indices merely to shorten instructions without proving the maximum intermediate offset. Casting an already overflowed intermediate to a wider pointer-sized value does not restore the intended calculation.

## Change a specific calculation

If dimensions remain invariant for a launch, test hoisting a repeated calculation or using a specialization that makes the invariant visible to the compiler. If an indirection is necessary, preserve its dependency and output correspondence. Avoid assuming every division survives compilation unchanged. Compare the generated address path and register demand, since retaining a computed value can trade instructions for longer-lived state.

## Validate the complete hypothesis

Check boundaries and large valid offsets against a reference, then compare normal execution on representative layouts. A useful result shows fewer relevant address instructions or a shorter dependency with unchanged values and coordinates. It does not establish that all memory kernels are instruction limited. Cache misses, scattered transactions and insufficient parallel work remain distinct explanations that require their own evidence.

## Primary references

[NVIDIA PTX Instruction Set Architecture](https://docs.nvidia.com/cuda/parallel-thread-execution/index.html).

[Nsight Compute Report and Source Views](https://docs.nvidia.com/nsight-compute/NsightCompute/index.html).

[CUDA Compiler Driver Options](https://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/).

Related reading: [Tensor strides: why transpose changes access without moving values](/journal/tensor-strides-transpose-contiguous/); [GPU warp scheduling: how ready work hides stalls](/journal/learn-warp-scheduler-ready-work/).
