Skip to content
Merged
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
23 changes: 20 additions & 3 deletions include/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,11 @@ inline void alloc_aligned(void **ptr, size_t size, size_t align)
#ifndef _WINDOWS
*ptr = ::aligned_alloc(align, size);
#else
*ptr = ::_aligned_malloc(size, align); // note the swapped arguments!
#ifdef EXEC_ENV_OLS
*ptr = operator new(size, std::align_val_t(align));
#else
*ptr = ::_aligned_malloc(size, align); // note the swapped arguments!
#endif
#endif
if (*ptr == nullptr)
report_memory_allocation_failure();
Expand All @@ -274,7 +278,15 @@ inline void realloc_aligned(void **ptr, size_t size, size_t align)
if (IS_ALIGNED(size, align) == 0)
report_misalignment_of_requested_size(align);
#ifdef _WINDOWS
*ptr = ::_aligned_realloc(*ptr, size, align);
#ifdef EXEC_ENV_OLS
void *newptr;
alloc_aligned(&newptr, size, align);
std::memcpy(newptr, *ptr, size);
operator delete(*ptr, std::align_val_t(1));
*ptr = newptr;
#else
*ptr = ::_aligned_realloc(*ptr, size, align);
#endif
#else
diskann::cerr << "No aligned realloc on GCC. Must malloc and mem_align, "
"left it out for now."
Expand Down Expand Up @@ -302,7 +314,12 @@ inline void aligned_free(void *ptr)
#ifndef _WINDOWS
free(ptr);
#else
::_aligned_free(ptr);
#ifdef EXEC_ENV_OLS
operator delete(ptr, std::align_val_t(1));
ptr = nullptr;
#else
::_aligned_free(ptr);
#endif
#endif
}

Expand Down
6 changes: 3 additions & 3 deletions src/in_mem_data_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ template <typename data_t> location_t InMemDataStore<data_t>::expand(const locat
<< this->capacity() << ")" << std::endl;
throw diskann::ANNException(ss.str(), -1);
}
#ifndef _WINDOWS
#if !defined(_WINDOWS) || defined(EXEC_ENV_OLS)
data_t *new_data;
alloc_aligned((void **)&new_data, new_size * _aligned_dim * sizeof(data_t), 8 * sizeof(data_t));
memcpy(new_data, _data, this->capacity() * _aligned_dim * sizeof(data_t));
Expand All @@ -248,7 +248,7 @@ template <typename data_t> location_t InMemDataStore<data_t>::shrink(const locat
<< this->capacity() << ")" << std::endl;
throw diskann::ANNException(ss.str(), -1);
}
#ifndef _WINDOWS
#if !defined(_WINDOWS) || defined(EXEC_ENV_OLS)
data_t *new_data;
alloc_aligned((void **)&new_data, new_size * _aligned_dim * sizeof(data_t), 8 * sizeof(data_t));
memcpy(new_data, _data, new_size * _aligned_dim * sizeof(data_t));
Expand Down Expand Up @@ -378,4 +378,4 @@ template DISKANN_DLLEXPORT class InMemDataStore<float>;
template DISKANN_DLLEXPORT class InMemDataStore<int8_t>;
template DISKANN_DLLEXPORT class InMemDataStore<uint8_t>;

} // namespace diskann
} // namespace diskann
Loading