Skip to content

Commit 15d3c89

Browse files
authored
fix in reduce check (#723)
1 parent c32b15c commit 15d3c89

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

benchmarks/gbench/common/distributed_vector.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,10 @@ DR_BENCHMARK(Copy_Serial);
152152
T fill = 100;
153153
void check_reduce(T actual) {
154154
if (comm_rank == 0) {
155-
std::vector<T> local_src(default_vector_size, fill);
156-
auto ref = std::reduce(local_src.begin(), local_src.end());
157-
155+
// Don't call std::reduce on big vectors, result is wrong due to adding
156+
// small float to big one. E.g. adding 80M values of 100 results
157+
// in 8.58993e+09
158+
const T ref = fill * default_vector_size;
158159
if ((ref - actual) / ref > .001) {
159160
fmt::print("Mismatch:\n Ref {} Actual {}\n", ref, actual);
160161
exit(1);

0 commit comments

Comments
 (0)