Skip to content

add contrib/dot benchmarks#3067

Open
mytsvy wants to merge 1 commit into
google:masterfrom
mytsvy:mytsvy/add-dot-benchmark
Open

add contrib/dot benchmarks#3067
mytsvy wants to merge 1 commit into
google:masterfrom
mytsvy:mytsvy/add-dot-benchmark

Conversation

@mytsvy
Copy link
Copy Markdown

@mytsvy mytsvy commented May 29, 2026

Add a dot product benchmark that measures both generic and kMultipleOfVector paths side-by-side across common sizes.
Dot::Compute has assumption-dependent fast paths; benchmarking only the generic path hides key perf behavior. This adds an explicit comparison in one run.

Test:

[ RUN      ] DotBenchGroup/DotBench.BenchAllDot/AVX2
Dot same (f32x8):
256 elems: gen  163.04 GB/s (MAD 0.29%) | mult  160.82 GB/s (MAD 0.28%)
1024 elems: gen  209.07 GB/s (MAD 0.22%) | mult  193.11 GB/s (MAD 1.06%)
16384 elems: gen   95.18 GB/s (MAD 0.89%) | mult   95.75 GB/s (MAD 0.97%)
262144 elems: gen   54.48 GB/s (MAD 0.47%) | mult   54.50 GB/s (MAD 0.45%)
1048576 elems: gen   41.13 GB/s (MAD 5.64%) | mult   44.42 GB/s (MAD 1.92%)
[        OK ] DotBenchGroup/DotBench.BenchAllDot/AVX2

Copy link
Copy Markdown
Member

@jan-wassenberg jan-wassenberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding :) Two minor suggestions:

FillArrays(a.get(), b.get(), max_count, rng);

const size_t N = Lanes(d);
(void)N;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use N when passing to TypeName, then no need for the void cast?

static_cast<double>(count) * (sizeof(TA) + sizeof(TB));

const size_t num_results_generic = MeasureClosure(
[&](FuncInput) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To ensure the computation isn't elided, can we make Compute() depend on the FuncInput? For example, we could set input to count * Unpredictable1(), then pass the FuncInput as the count arg to Compute?

@jan-wassenberg
Copy link
Copy Markdown
Member

Also looks like we have some check failures: signed/unsigned casts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants