﻿# Racecheck evidence for shared-memory reads before async-copy completion

Use Compute Sanitizer racecheck to investigate shared-memory hazards, asynchronous copy completion, line attribution, and the limits of a clean diagnostic run.

Author: Retrivium editorial team
Updated: 2026-11-04
Canonical URL: https://retrivium.ai/journal/fg2-compute-sanitizer-racecheck-async-copy-completion/
Language: en

## A tile looks correct until scheduling changes

An optimized tile loader may appear reliable because consumers usually arrive after producers. A different block shape, instrumentation, or neighboring workload can expose a missing dependency. The useful question is whether a shared-memory read is ordered after the operation that supplies its data, rather than whether repeated outputs happen to match.

[Compute Sanitizer](https://docs.nvidia.com/compute-sanitizer/ComputeSanitizer/index.html) separates shared-memory hazard checking from other diagnostic tools. That separation makes the scope of the evidence important.

## Racecheck observes a particular memory protocol

The current manual documents racecheck support for accesses to shared-memory destinations of asynchronous copies before the required completion protocol. CUDA `cuda::memcpy_async` and PTX `cp.async` are relevant examples. The diagnostic concerns the relationship between the asynchronous producer and a later access to its destination.

Review the actual pipeline stages, waits, and participating threads before changing synchronization. Adding a familiar barrier without understanding the copy protocol can conceal the design question rather than answer it. The [async shared-copy guide](/journal/learn-async-shared-copy-pipeline/) develops that ownership model.

## Preserve useful attribution

NVIDIA explains how `-lineinfo` improves source attribution in its [debugging walkthrough](https://developer.nvidia.com/blog/debugging-cuda-more-efficiently-with-nvidia-compute-sanitizer/). Keep the executable and source revision aligned when reading a reported location. A line containing a read identifies an observed access, while the missing ordering relationship may originate elsewhere.

Record selected kernels, launch filters, and command options with the report. In particular, disabling asynchronous-copy checks through `--racecheck-memcpy-async no` changes what a clean result means. An automated check should also distinguish a successful application exit from a tool-detected error.

## Start with a comprehensible hazard

The official [block-level Racecheck example](https://raw.githubusercontent.com/NVIDIA/compute-sanitizer-samples/master/Racecheck/block_error.cu) has threads write shared storage before a thread consumes the block-wide contents without the necessary ordering. It is a compact baseline for understanding report attribution; it is not an asynchronous-copy implementation.

Use a similarly small reproducer for the optimized loader. Keep the suspect producer, destination, consumer, and launch conditions while removing unrelated application behavior. This is a proposed debugging procedure, not a claim that the kernel was executed here.

## A clean run has bounded meaning

Racecheck evidence does not establish the absence of every global-memory race, every out-of-bounds access, or every application-level ordering defect. Match each concern to the documented tool and enabled checks.

An [acceptance evidence record](/journal/gpu-acceptance-evidence/) should retain the sanitizer version, tested inputs, and diagnostic scope. Performance comparisons belong in separate uninstrumented measurements after the access protocol is understood.
