Skip to content

Commit

Permalink
fix mac CI
Browse files Browse the repository at this point in the history
OpenMP on Mac doesn't accept the expression includes a cast as loop condition with pragma omp parallel for
  • Loading branch information
wx257osn2 committed May 31, 2023
1 parent b48a671 commit 632b3bb
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions faiss/utils/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -447,10 +447,12 @@ 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 (std::make_signed<std::size_t>::type i_ = 0;
static_cast<std::size_t>(i_) < n;
i_++) {
// MSVC can't accept unsigned index for #pragma omp parallel for
// so below codes only accepts n <= std::numeric_limits<ssize_t>::max()
using ssize_t = std::make_signed<std::size_t>::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<std::size_t>(i_);
cs[i] = bvec_checksum(d, a + i * d);
}
Expand Down

0 comments on commit 632b3bb

Please sign in to comment.