Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions faiss/utils/distances_fused/simdlib_based.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,17 +257,19 @@ void exhaustive_L2sqr_fused_cmax(
}
}

const size_t nx_p = (nx / NX_POINTS_PER_LOOP) * NX_POINTS_PER_LOOP;
const ssize_t nx_p = (ssize_t)((nx / NX_POINTS_PER_LOOP) * NX_POINTS_PER_LOOP);
// the main loop.
#pragma omp parallel for schedule(dynamic) num_threads(num_omp_threads)
for (size_t i = 0; i < nx_p; i += NX_POINTS_PER_LOOP) {
// use signed instead of size_t because of C3016 error on windows:
// https://learn.microsoft.com/en-us/cpp/error-messages/compiler-errors-2/compiler-error-c3016
for (ssize_t i = 0; i < nx_p; i += (ssize_t)NX_POINTS_PER_LOOP) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this works if ssize_t is defined and available (it is non standard)
pls refer to facebook/faiss commit facebookresearch#2889
that fixed the same issue in another file

kernel<DIM, NX_POINTS_PER_LOOP, NY_POINTS_PER_LOOP>(
x, y, y_transposed.data(), ny, res, y_norms, i);
x, y, y_transposed.data(), ny, res, y_norms, (size_t)i);
}

for (size_t i = nx_p; i < nx; i++) {
for (ssize_t i = nx_p; i < (ssize_t)nx; i++) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is not required to add any changes to this line as
pragma omp for only applies to the immediate next for loop (which is the one above)
this for loop is not under openmp

kernel<DIM, 1, NY_POINTS_PER_LOOP>(
x, y, y_transposed.data(), ny, res, y_norms, i);
x, y, y_transposed.data(), ny, res, y_norms, (size_t)i);
}

// Does nothing for Top1BlockResultHandler, but
Expand Down