diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-07-03 12:36:18 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-07-03 12:36:18 +0100 |
commit | 55f59de699aa0c7c7018e05375131d22cfd46530 (patch) | |
tree | 1fc8072b713108e865084d80b4513bd79b7667d9 | |
parent | 4a08d5f01e27aa2e67e54386c9206ad4f42d40c1 (diff) | |
download | rspamd-55f59de699aa0c7c7018e05375131d22cfd46530.tar.gz rspamd-55f59de699aa0c7c7018e05375131d22cfd46530.zip |
[Minor] Allow to work without cblas.h
-rw-r--r-- | config.h.in | 4 | ||||
-rw-r--r-- | contrib/kann/CMakeLists.txt | 13 | ||||
-rw-r--r-- | contrib/kann/kann.c | 2 | ||||
-rw-r--r-- | contrib/kann/kautodiff.c | 15 |
4 files changed, 30 insertions, 4 deletions
diff --git a/config.h.in b/config.h.in index 9dcf51a50..8b876cd60 100644 --- a/config.h.in +++ b/config.h.in @@ -157,10 +157,6 @@ #cmakedefine DISABLE_PTHREAD_MUTEX 1 -#ifdef HAVE_LIBEVENT2 -#define HAVE_EVUTIL_RNG_INIT 1 -#endif - /* Detect endianness */ #ifdef HAVE_ENDIAN_H diff --git a/contrib/kann/CMakeLists.txt b/contrib/kann/CMakeLists.txt index d7bd73d28..ba38e14c8 100644 --- a/contrib/kann/CMakeLists.txt +++ b/contrib/kann/CMakeLists.txt @@ -15,6 +15,19 @@ ProcessPackage(BLAS OPTIONAL LIBRARY openblas blas LIB_OUTPUT BLAS_REQUIRED_LIBRARIES) IF(WITH_BLAS) MESSAGE(STATUS "Use openblas to accelerate kann") + IF(NOT BLAS_INCLUDE) + FIND_FILE(HAVE_CBLAS_H HINTS "${RSPAMD_SEARCH_PATH}" + NAMES cblas.h + DOC "Path to cblas.h header") + IF(NOT HAVE_CBLAS_H) + MESSAGE(STATUS "Blas header cblas.h has not been found, use internal workaround") + ELSE() + ADD_DEFINITIONS(-DHAVE_CBLAS_H) + ENDIF() + ELSE() + ADD_DEFINITIONS(-DHAVE_CBLAS_H) + ENDIF() + TARGET_LINK_LIBRARIES(rspamd-kann ${BLAS_REQUIRED_LIBRARIES}) ADD_DEFINITIONS(-DHAVE_CBLAS) ENDIF(WITH_BLAS) diff --git a/contrib/kann/kann.c b/contrib/kann/kann.c index 43227bdc6..76ade6a52 100644 --- a/contrib/kann/kann.c +++ b/contrib/kann/kann.c @@ -1,3 +1,5 @@ +#include "config.h" + #include <math.h> #include <float.h> #include <string.h> diff --git a/contrib/kann/kautodiff.c b/contrib/kann/kautodiff.c index f303a723f..bc9458f42 100644 --- a/contrib/kann/kautodiff.c +++ b/contrib/kann/kautodiff.c @@ -1,3 +1,5 @@ +#include "config.h" + #include <stdlib.h> #include <assert.h> #include <stdarg.h> @@ -898,7 +900,20 @@ void kad_vec_mul_sum(int n, float *a, const float *b, const float *c) void kad_saxpy(int n, float a, const float *x, float *y) { kad_saxpy_inlined(n, a, x, y); } #ifdef HAVE_CBLAS +#ifdef HAVE_CBLAS_H #include "cblas.h" +#else +/* Poor man approach */ +enum CBLAS_ORDER {CblasRowMajor=101, CblasColMajor=102 }; +enum CBLAS_TRANSPOSE {CblasNoTrans=111, CblasTrans=112 }; +extern void cblas_sgemm(const enum CBLAS_ORDER Order, + const enum CBLAS_TRANSPOSE TA, + const enum CBLAS_TRANSPOSE TB, + const int M, const int N, const int K, + const float alpha, const float *A, const int lda, + const float *B, const int ldb, const float beta, + float *C, const int ldc); +#endif void kad_sgemm_simple(int trans_A, int trans_B, int M, int N, int K, const float *A, const float *B, float *C) { cblas_sgemm(CblasRowMajor, trans_A? CblasTrans : CblasNoTrans, trans_B? CblasTrans : CblasNoTrans, M, N, K, 1.0f, A, trans_A? M : K, B, trans_B? K : N, 1.0f, C, N); |