From 15c5ad443ec7045b726b8d4e15b1e7db5513eb2b Mon Sep 17 00:00:00 2001 From: "Yusheng.Ma" Date: Fri, 9 Sep 2022 08:00:12 +0000 Subject: [PATCH] remove openblas header, fix openblas always compile bug Signed-off-by: Yusheng.Ma --- cmake/ThirdPartyPackagesKw.cmake | 14 ++---------- thirdparty/DiskANN/src/aux_utils.cpp | 1 - thirdparty/DiskANN/src/math_utils.cpp | 33 ++++++++++++++++++++++++++- 3 files changed, 34 insertions(+), 14 deletions(-) diff --git a/cmake/ThirdPartyPackagesKw.cmake b/cmake/ThirdPartyPackagesKw.cmake index 6df3b2788..864d21fb0 100644 --- a/cmake/ThirdPartyPackagesKw.cmake +++ b/cmake/ThirdPartyPackagesKw.cmake @@ -227,18 +227,8 @@ endmacro() if (KNOWHERE_WITH_OPENBLAS) if (OpenBLAS_SOURCE STREQUAL "AUTO") # Protect OpenBLAS for faiss build - 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() - - + set (BLA_VENDOR OpenBLAS) + find_package(BLAS) if (BLAS_FOUND) add_library(openblas ALIAS BLAS::BLAS) else() diff --git a/thirdparty/DiskANN/src/aux_utils.cpp b/thirdparty/DiskANN/src/aux_utils.cpp index 54bc0a61f..05c66bad8 100644 --- a/thirdparty/DiskANN/src/aux_utils.cpp +++ b/thirdparty/DiskANN/src/aux_utils.cpp @@ -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" diff --git a/thirdparty/DiskANN/src/math_utils.cpp b/thirdparty/DiskANN/src/math_utils.cpp index dfca4f6ea..ce493bf4c 100644 --- a/thirdparty/DiskANN/src/math_utils.cpp +++ b/thirdparty/DiskANN/src/math_utils.cpp @@ -5,10 +5,41 @@ #include #include #include -#include "openblas/cblas.h" #include "logger.h" #include "utils.h" + + +#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); + + + namespace math_utils { float calc_distance(float* vec_1, float* vec_2, size_t dim) {