Skip to content
This repository has been archived by the owner on Aug 16, 2023. It is now read-only.

Commit

Permalink
remove openblas header, fix openblas always compile bug
Browse files Browse the repository at this point in the history
Signed-off-by: Yusheng.Ma <[email protected]>
  • Loading branch information
Presburger committed Sep 13, 2022
1 parent d22d205 commit 4255822
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 13 deletions.
16 changes: 5 additions & 11 deletions cmake/ThirdPartyPackagesKw.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -227,18 +227,10 @@ endmacro()
if (KNOWHERE_WITH_OPENBLAS)
if (OpenBLAS_SOURCE STREQUAL "AUTO")
# Protect OpenBLAS for faiss build
if (LINUX)
if(LINUX)
set (BLA_VENDOR OpenBLAS)
endif()

if ( CMAKE_BUILD_TYPE STREQUAL "Debug" OR APPLE OR MSYS)
message(STATUS "Using debug mode or host is MacOS/MSYS, try to find openblas")
find_package(BLAS)
message(STATUS "Knowhere openblas libraries: ${BLAS_LIBRARIES}")
message(STATUS "Knowhere openblas found: ${BLAS_FOUND}")
endif()


find_package(BLAS)
if (BLAS_FOUND)
add_library(openblas ALIAS BLAS::BLAS)
else()
Expand All @@ -248,7 +240,9 @@ if (KNOWHERE_WITH_OPENBLAS)
elseif (OpenBLAS_SOURCE STREQUAL "BUNDLED")
build_openblas()
elseif (OpenBLAS_SOURCE STREQUAL "SYSTEM")
set (BLA_VENDOR OpenBLAS)
if(LINUX)
set (BLA_VENDOR OpenBLAS)
endif(LINUX)
find_package(BLAS REQUIRED)
add_library(openblas ALIAS BLAS::BLAS)
endif ()
Expand Down
1 change: 0 additions & 1 deletion thirdparty/DiskANN/src/aux_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include "aux_utils.h"
#include "cached_io.h"
#include "index.h"
#include "openblas/cblas.h"
#include "omp.h"
#include "partition_and_pq.h"
#include "percentile_stats.h"
Expand Down
38 changes: 37 additions & 1 deletion thirdparty/DiskANN/src/math_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,46 @@
#include <unordered_set>
#include <malloc.h>
#include <math_utils.h>
#include "openblas/cblas.h"
#include "logger.h"
#include "utils.h"


#ifdef __cplusplus
extern "C" {
#endif

#ifndef OPENBLAS_CONST
# define OPENBLAS_CONST const
#endif

typedef int blasint;

typedef enum CBLAS_ORDER {
CblasRowMajor = 101,
CblasColMajor = 102
} CBLAS_ORDER;
typedef enum CBLAS_TRANSPOSE {
CblasNoTrans = 111,
CblasTrans = 112,
CblasConjTrans = 113,
CblasConjNoTrans = 114
} CBLAS_TRANSPOSE;

float cblas_snrm2(const int N, const float* X, const int incX);
void cblas_sgemm(OPENBLAS_CONST enum CBLAS_ORDER Order,
OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA,
OPENBLAS_CONST enum CBLAS_TRANSPOSE TransB,
OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N,
OPENBLAS_CONST blasint K, OPENBLAS_CONST float alpha,
OPENBLAS_CONST float* A, OPENBLAS_CONST blasint lda,
OPENBLAS_CONST float* B, OPENBLAS_CONST blasint ldb,
OPENBLAS_CONST float beta, float* C,
OPENBLAS_CONST blasint ldc);
#ifdef __cplusplus
}
#endif


namespace math_utils {

float calc_distance(float* vec_1, float* vec_2, size_t dim) {
Expand Down

0 comments on commit 4255822

Please sign in to comment.