Skip to content

Commit a84c880

Browse files
committed
fix mac CI
OpenMP (at least the specification) doesn't accept the expression includes a cast as loop condition with pragma omp parallel for
1 parent b48a671 commit a84c880

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

faiss/utils/utils.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -447,10 +447,12 @@ uint64_t bvec_checksum(size_t n, const uint8_t* a) {
447447
}
448448

449449
void bvecs_checksum(size_t n, size_t d, const uint8_t* a, uint64_t* cs) {
450-
#pragma omp parallel for if (n > 1000)
451-
for (std::make_signed<std::size_t>::type i_ = 0;
452-
static_cast<std::size_t>(i_) < n;
453-
i_++) {
450+
// MSVC can't accept unsigned index for #pragma omp parallel for
451+
// so below codes only accept n <= std::numeric_limits<ssize_t>::max()
452+
using ssize_t = std::make_signed<std::size_t>::type;
453+
const ssize_t size = n;
454+
#pragma omp parallel for if (size > 1000)
455+
for (ssize_t i_ = 0; i_ < size; i_++) {
454456
const auto i = static_cast<std::size_t>(i_);
455457
cs[i] = bvec_checksum(d, a + i * d);
456458
}

0 commit comments

Comments
 (0)