diff --git a/faiss/utils/utils.cpp b/faiss/utils/utils.cpp index 9cc8d3fe45..5f3e5eb964 100644 --- a/faiss/utils/utils.cpp +++ b/faiss/utils/utils.cpp @@ -28,6 +28,7 @@ #include #include +#include #include #include @@ -446,8 +447,13 @@ uint64_t bvec_checksum(size_t n, const uint8_t* a) { } void bvecs_checksum(size_t n, size_t d, const uint8_t* a, uint64_t* cs) { -#pragma omp parallel for if (n > 1000) - for (size_t i = 0; i < n; i++) { + // MSVC can't accept unsigned index for #pragma omp parallel for + // so below codes only accept n <= std::numeric_limits::max() + using ssize_t = std::make_signed::type; + const ssize_t size = n; +#pragma omp parallel for if (size > 1000) + for (ssize_t i_ = 0; i_ < size; i_++) { + const auto i = static_cast(i_); cs[i] = bvec_checksum(d, a + i * d); } }