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

Fix knowhere always compile openblas #462

Merged
merged 1 commit into from
Sep 14, 2022
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
6 changes: 3 additions & 3 deletions ci/pod/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ spec:
topologyKey: "kubernetes.io/hostname"
containers:
- name: build
image: milvusdb/knowhere-cpu-build:amd64-ubuntu20.04-20220913-4d10334
image: milvusdb/knowhere-cpu-build:amd64-ubuntu20.04-20220914-30a5e60
tty: true
args: ["cat"]
- name: main
image: milvusdb/knowhere-cpu-e2e:amd64-ubuntu20.04-20220913-4d10334
image: milvusdb/knowhere-cpu-e2e:amd64-ubuntu20.04-20220914-30a5e60
tty: true
args: ["cat"]
resources:
Expand All @@ -46,4 +46,4 @@ spec:
volumes:
- name: db-data
persistentVolumeClaim:
claimName: db-data
claimName: db-data
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()
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