TransferBench data validation#
TransferBench validates the transfer results by comparing the destination (DST) memory to
precomputed expected values. For each transfer, the DST buffer must equal the element-wise sum of all SRC buffers, or zero if there are no sources. A transfer is correct if, for every element i, the value matches the expected value given in the following table:
Number of sources |
Expected value |
|---|---|
0 |
|
1 |
|
N |
|
Source data preparation#
Before any transfers run, TransferBench prepares the SRC and DST memories as discussed in the following sections:
Expected source pattern#
Before any transfers run, TransferBench builds reference SRC buffers on the host using
PrepareReference(cfg, cpuBuffer, bufferIdx).
The pattern used depends on the configuration:
Configuration |
Behavior |
|---|---|
|
Mix of random floats with optional zeroing per 64-byte line:
|
|
Repeats the given |
Default |
Pseudo-random:
|
Expected destination (dstReference)#
The expected destination is computed once before the iteration loop:
dstReference[0] = memset to MEMSET_CHAR # used when numSrcs == 0
dstReference[1] = srcReference[0] # 1 source
dstReference[2] = dstReference[1] + srcReference[1] # 2 sources
dstReference[k] = dstReference[k-1] + srcReference[k-1] # k sources
dstReference[numSrcs] is the expected result for a transfer with numSrcs sources.
Initializing source and destination memories#
For each transfer, the SRC memory on the rank that owns it is filled from the corresponding
srcReference buffer via hipMemcpy (host-to-device or device-to-device as appropriate).
DST memory is zeroed (or memset) before transfers run.
How validation is timed#
The timing of validation is controlled by the alwaysValidate option. By default
(alwaysValidate = 0), validation runs once after all timed iterations complete,
minimizing overhead during benchmarking. When alwaysValidate = 1, validation is
performed after every iteration; any detected error immediately stops the run.
Option |
When |
Behavior |
|---|---|---|
|
Once at the end of all iterations |
|
|
After every timed iteration |
|
How validation (ValidateAllTransfers) works#
For each transfer and each DST, the following steps are performed:
Rank check: Only the rank that owns the destination performs validation.
Get the actual output:
CPU destination or
validateDirect = 1: Point directly at the destination memory.GPU destination and
validateDirect = 0: Copy destination to a hostoutputBufferviahipMemcpy, then compare againstoutputBuffer.
Comparison: Performed using
memcmp(output, expected, numBytes). On mismatch, the code finds the first differing index and returns an error with the index, expected value, and actual value.Expected values: Calculated using
expected = dstReference[t.srcs.size()].data(). The precomputed sum for the number of sources.
Validation options#
The following options control when and how validation is performed. They can be set as environment variables or in a configuration file.
Option |
Environment variable |
Description |
|---|---|---|
|
|
To validate after each iteration, set to |
|
|
To compare GPU DST directly, set to |
|
|
To validate the SRC memory right after it’s initialized, set to |
Note
validateDirect is not supported on NVIDIA. The code falls back to copying to host.