Skip to content

Commit

Permalink
Horizontally sum hash vector using unsigned ints, to avoid signed int…
Browse files Browse the repository at this point in the history
… overflow
  • Loading branch information
stuarthayhurst committed Oct 3, 2024
1 parent 1025d7e commit 52c3718
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/ammonite/utils/internal/hash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,13 @@ namespace ammonite {
}
}

return std::to_string((uint64_t)_mm512_reduce_add_epi64(last));
uint64_t* values = (uint64_t*)&last;
uint64_t result = 0;
for (int i = 0; i < 8; i++) {
result += values[i];
}

return std::to_string(result);
}
#else
std::string generateCacheString(std::string* filePaths,
Expand Down

0 comments on commit 52c3718

Please sign in to comment.