Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 0 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,6 @@ if(HNSWLIB_EXAMPLES)
if(ENABLE_MSAN)
add_cxx_flags(-fsanitize=memory)
endif()
if(ENABLE_ASAN OR ENABLE_UBSAN)
add_cxx_flags(-DHNSWLIB_USE_PREFETCH=0)
endif()

add_cxx_flags(-Wall -Wextra -Wpedantic -Werror)

Expand Down
18 changes: 12 additions & 6 deletions hnswlib/hnswalg.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,10 @@ class HierarchicalNSW : public AlgorithmInterface<dist_t> {
// if (candidate_id == 0) continue;
#ifdef USE_SSE
#if HNSWLIB_USE_PREFETCH
_mm_prefetch((char *) (visited_array + *(datal + j + 1)), _MM_HINT_T0);
_mm_prefetch(getDataByInternalId(*(datal + j + 1)), _MM_HINT_T0);
if (j + 1 < size) {
_mm_prefetch((char *) (visited_array + *(datal + j + 1)), _MM_HINT_T0);
_mm_prefetch(getDataByInternalId(*(datal + j + 1)), _MM_HINT_T0);
}
#endif
#endif
if (visited_array[candidate_id] == visited_array_tag) continue;
Expand Down Expand Up @@ -393,9 +395,11 @@ class HierarchicalNSW : public AlgorithmInterface<dist_t> {
// if (candidate_id == 0) continue;
#ifdef USE_SSE
#if HNSWLIB_USE_PREFETCH
_mm_prefetch((char *) (visited_array + *(data + j + 1)), _MM_HINT_T0);
_mm_prefetch(data_level0_memory_ + (*(data + j + 1)) * size_data_per_element_ + offsetData_,
_MM_HINT_T0); ////////////
if (j + 1 < size) {
_mm_prefetch((char *) (visited_array + *(data + j + 1)), _MM_HINT_T0);
_mm_prefetch(data_level0_memory_ + (*(data + j + 1)) * size_data_per_element_ + offsetData_,
_MM_HINT_T0);
}
#endif
#endif
if (!(visited_array[candidate_id] == visited_array_tag)) {
Expand Down Expand Up @@ -1126,7 +1130,9 @@ class HierarchicalNSW : public AlgorithmInterface<dist_t> {
for (int i = 0; i < size; i++) {
#ifdef USE_SSE
#if HNSWLIB_USE_PREFETCH
_mm_prefetch(getDataByInternalId(*(datal + i + 1)), _MM_HINT_T0);
if (i + 1 < size) {
_mm_prefetch(getDataByInternalId(*(datal + i + 1)), _MM_HINT_T0);
}
#endif
#endif
tableint cand = datal[i];
Expand Down