Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added AARCH64 support #136

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
22 changes: 20 additions & 2 deletions AnnService/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

file(GLOB HDR_FILES ${PROJECT_SOURCE_DIR}/AnnService/inc/Core/*.h ${PROJECT_SOURCE_DIR}/AnnService/inc/Core/Common/*.h ${PROJECT_SOURCE_DIR}/AnnService/inc/Core/BKT/*.h ${PROJECT_SOURCE_DIR}/AnnService/inc/Core/KDT/*.h ${PROJECT_SOURCE_DIR}/AnnService/inc/Helper/*.h ${PROJECT_SOURCE_DIR}/AnnService/inc/Helper/VectorSetReaders/*.h)
file(GLOB SRC_FILES ${PROJECT_SOURCE_DIR}/AnnService/src/Core/*.cpp ${PROJECT_SOURCE_DIR}/AnnService/src/Core/Common/*.cpp ${PROJECT_SOURCE_DIR}/AnnService/src/Core/BKT/*.cpp ${PROJECT_SOURCE_DIR}/AnnService/src/Core/KDT/*.cpp ${PROJECT_SOURCE_DIR}/AnnService/src/Helper/*.cpp ${PROJECT_SOURCE_DIR}/AnnService/src/Helper/VectorSetReaders/*.cpp)
file(GLOB HDR_FILES
${PROJECT_SOURCE_DIR}/AnnService/inc/Core/*.h
${PROJECT_SOURCE_DIR}/AnnService/inc/Core/Common/*.h
${PROJECT_SOURCE_DIR}/AnnService/inc/Core/BKT/*.h
${PROJECT_SOURCE_DIR}/AnnService/inc/Core/KDT/*.h
${PROJECT_SOURCE_DIR}/AnnService/inc/Helper/*.h
${PROJECT_SOURCE_DIR}/AnnService/inc/Helper/VectorSetReaders/*.h
${PROJECT_SOURCE_DIR}/simde/simde/*.h
${PROJECT_SOURCE_DIR}/simde/simde/x86/*.h
${PROJECT_SOURCE_DIR}/simde/simde/arm/*.h
${PROJECT_SOURCE_DIR}/simde/simde/arm/neon/*.h
)
file(GLOB SRC_FILES
${PROJECT_SOURCE_DIR}/AnnService/src/Core/*.cpp
${PROJECT_SOURCE_DIR}/AnnService/src/Core/Common/*.cpp
${PROJECT_SOURCE_DIR}/AnnService/src/Core/BKT/*.cpp
${PROJECT_SOURCE_DIR}/AnnService/src/Core/KDT/*.cpp
${PROJECT_SOURCE_DIR}/AnnService/src/Helper/*.cpp
${PROJECT_SOURCE_DIR}/AnnService/src/Helper/VectorSetReaders/*.cpp
)

include_directories(${PROJECT_SOURCE_DIR}/AnnService)

Expand Down
8 changes: 4 additions & 4 deletions AnnService/inc/Core/Common/BKTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ namespace SPTAG
T* newTCenters;

KmeansArgs(int k, DimensionType dim, SizeType datasize, int threadnum) : _K(k), _D(dim), _T(threadnum) {
centers = (T*)aligned_malloc(sizeof(T) * k * dim, ALIGN);
newTCenters = (T*)aligned_malloc(sizeof(T) * k * dim, ALIGN);
centers = (T*)simde_mm_malloc(sizeof(T) * k * dim, ALIGN);
newTCenters = (T*)simde_mm_malloc(sizeof(T) * k * dim, ALIGN);
counts = new SizeType[k];
newCenters = new float[threadnum * k * dim];
newCounts = new SizeType[threadnum * k];
Expand All @@ -58,8 +58,8 @@ namespace SPTAG
}

~KmeansArgs() {
aligned_free(centers);
aligned_free(newTCenters);
simde_mm_free(centers);
simde_mm_free(newTCenters);
delete[] counts;
delete[] newCenters;
delete[] newCounts;
Expand Down
25 changes: 13 additions & 12 deletions AnnService/inc/Core/Common/Dataset.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@

#include <fstream>

#if defined(_MSC_VER) || defined(__INTEL_COMPILER)
// #if defined(_MSC_VER) || defined(__INTEL_COMPILER)
#include <malloc.h>
#else
#include <mm_malloc.h>
#endif // defined(__GNUC__)
// #else
// #include <mm_malloc.h>
#include "malloc_aligned.hpp"
// #endif // defined(__GNUC__)

#define ALIGN 32

#define aligned_malloc(a, b) _mm_malloc(a, b)
#define aligned_free(a) _mm_free(a)
//
// #define aligned_malloc(a, b) _mm_malloc(a, b)
// #define aligned_free(a) _mm_free(a)

#pragma warning(disable:4996) // 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.

Expand Down Expand Up @@ -48,8 +49,8 @@ namespace SPTAG
}
~Dataset()
{
if (ownData) aligned_free(data);
for (T* ptr : incBlocks) aligned_free(ptr);
if (ownData) simde_mm_free(data);
for (T* ptr : incBlocks) simde_mm_free(ptr);
incBlocks.clear();
}
void Initialize(SizeType rows_, DimensionType cols_, T* data_ = nullptr, bool transferOnwership_ = true)
Expand All @@ -60,7 +61,7 @@ namespace SPTAG
if (data_ == nullptr || !transferOnwership_)
{
ownData = true;
data = (T*)aligned_malloc(((size_t)rows) * cols * sizeof(T), ALIGN);
data = (T*)simde_mm_malloc(((size_t)rows) * cols * sizeof(T), ALIGN);
if (data_ != nullptr) memcpy(data, data_, ((size_t)rows) * cols * sizeof(T));
else std::memset(data, -1, ((size_t)rows) * cols * sizeof(T));
}
Expand Down Expand Up @@ -109,7 +110,7 @@ namespace SPTAG
while (written < num) {
SizeType curBlockIdx = (incRows + written) / rowsInBlock;
if (curBlockIdx >= (SizeType)incBlocks.size()) {
T* newBlock = (T*)aligned_malloc(((size_t)rowsInBlock) * cols * sizeof(T), ALIGN);
T* newBlock = (T*)simde_mm_malloc(((size_t)rowsInBlock) * cols * sizeof(T), ALIGN);
if (newBlock == nullptr) return ErrorCode::MemoryOverFlow;
incBlocks.push_back(newBlock);
}
Expand All @@ -130,7 +131,7 @@ namespace SPTAG
while (written < num) {
SizeType curBlockIdx = (incRows + written) / rowsInBlock;
if (curBlockIdx >= (SizeType)incBlocks.size()) {
T* newBlock = (T*)aligned_malloc(sizeof(T) * rowsInBlock * cols, ALIGN);
T* newBlock = (T*)simde_mm_malloc(sizeof(T) * rowsInBlock * cols, ALIGN);
if (newBlock == nullptr) return ErrorCode::MemoryOverFlow;
std::memset(newBlock, -1, sizeof(T) * rowsInBlock * cols);
incBlocks.push_back(newBlock);
Expand Down
Loading