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

Commit 71ef932

Browse files
committed
remove openblas header, fix openblas always compile bug
Signed-off-by: Yusheng.Ma <[email protected]>
1 parent 30a5e60 commit 71ef932

File tree

3 files changed

+42
-13
lines changed

3 files changed

+42
-13
lines changed

cmake/ThirdPartyPackagesKw.cmake

+5-11
Original file line numberDiff line numberDiff line change
@@ -227,18 +227,10 @@ endmacro()
227227
if (KNOWHERE_WITH_OPENBLAS)
228228
if (OpenBLAS_SOURCE STREQUAL "AUTO")
229229
# Protect OpenBLAS for faiss build
230-
if (LINUX)
230+
if(LINUX)
231231
set (BLA_VENDOR OpenBLAS)
232232
endif()
233-
234-
if ( CMAKE_BUILD_TYPE STREQUAL "Debug" OR APPLE OR MSYS)
235-
message(STATUS "Using debug mode or host is MacOS/MSYS, try to find openblas")
236-
find_package(BLAS)
237-
message(STATUS "Knowhere openblas libraries: ${BLAS_LIBRARIES}")
238-
message(STATUS "Knowhere openblas found: ${BLAS_FOUND}")
239-
endif()
240-
241-
233+
find_package(BLAS)
242234
if (BLAS_FOUND)
243235
add_library(openblas ALIAS BLAS::BLAS)
244236
else()
@@ -248,7 +240,9 @@ if (KNOWHERE_WITH_OPENBLAS)
248240
elseif (OpenBLAS_SOURCE STREQUAL "BUNDLED")
249241
build_openblas()
250242
elseif (OpenBLAS_SOURCE STREQUAL "SYSTEM")
251-
set (BLA_VENDOR OpenBLAS)
243+
if(LINUX)
244+
set (BLA_VENDOR OpenBLAS)
245+
endif()
252246
find_package(BLAS REQUIRED)
253247
add_library(openblas ALIAS BLAS::BLAS)
254248
endif ()

thirdparty/DiskANN/src/aux_utils.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include "aux_utils.h"
1919
#include "cached_io.h"
2020
#include "index.h"
21-
#include "openblas/cblas.h"
2221
#include "omp.h"
2322
#include "partition_and_pq.h"
2423
#include "percentile_stats.h"

thirdparty/DiskANN/src/math_utils.cpp

+37-1
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,46 @@
55
#include <unordered_set>
66
#include <malloc.h>
77
#include <math_utils.h>
8-
#include "openblas/cblas.h"
98
#include "logger.h"
109
#include "utils.h"
1110

11+
12+
#ifdef __cplusplus
13+
extern "C" {
14+
#endif
15+
16+
#ifndef OPENBLAS_CONST
17+
# define OPENBLAS_CONST const
18+
#endif
19+
20+
typedef int blasint;
21+
22+
typedef enum CBLAS_ORDER {
23+
CblasRowMajor = 101,
24+
CblasColMajor = 102
25+
} CBLAS_ORDER;
26+
typedef enum CBLAS_TRANSPOSE {
27+
CblasNoTrans = 111,
28+
CblasTrans = 112,
29+
CblasConjTrans = 113,
30+
CblasConjNoTrans = 114
31+
} CBLAS_TRANSPOSE;
32+
33+
float cblas_snrm2(const int N, const float* X, const int incX);
34+
void cblas_sgemm(OPENBLAS_CONST enum CBLAS_ORDER Order,
35+
OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA,
36+
OPENBLAS_CONST enum CBLAS_TRANSPOSE TransB,
37+
OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N,
38+
OPENBLAS_CONST blasint K, OPENBLAS_CONST float alpha,
39+
OPENBLAS_CONST float* A, OPENBLAS_CONST blasint lda,
40+
OPENBLAS_CONST float* B, OPENBLAS_CONST blasint ldb,
41+
OPENBLAS_CONST float beta, float* C,
42+
OPENBLAS_CONST blasint ldc);
43+
#ifdef __cplusplus
44+
}
45+
#endif
46+
47+
1248
namespace math_utils {
1349

1450
float calc_distance(float* vec_1, float* vec_2, size_t dim) {

0 commit comments

Comments
 (0)