Skip to content
This repository was archived by the owner on Feb 18, 2020. It is now read-only.

Commit ba8fecc

Browse files
Removed OpenBLAS and LAPACKE requirement for compilation and matrix products
1 parent 2138d4c commit ba8fecc

File tree

5 files changed

+14
-88
lines changed

5 files changed

+14
-88
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,5 @@ aclocal.m4
3030
acinclude.m4
3131
playground.py
3232
*.php
33+
config.h
3334
CMakeLists.txt

config.h

Lines changed: 0 additions & 85 deletions
This file was deleted.

config.m4

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,9 @@ PHP_CHECK_LIBRARY(blas,cblas_sdot,
7171
PHP_CHECK_LIBRARY(openblas,cblas_sdot,
7272
[
7373
PHP_ADD_LIBRARY(openblas)
74+
AC_DEFINE(HAVE_BLAS,1,[ ])
7475
],[
75-
AC_MSG_ERROR([wrong openblas/blas version or library not found])
76+
AC_MSG_RESULT([wrong openblas/blas version or library not found.])
7677
],[
7778
-lopenblas
7879
])
@@ -82,9 +83,10 @@ PHP_CHECK_LIBRARY(blas,cblas_sdot,
8283

8384
PHP_CHECK_LIBRARY(lapacke,LAPACKE_sgetrf,
8485
[
86+
AC_DEFINE(HAVE_LAPACKE,1,[ ])
8587
PHP_ADD_LIBRARY(lapacke)
8688
],[
87-
AC_MSG_ERROR([wrong lapacke version or library not found])
89+
AC_MSG_RESULT([wrong lapacke version or library not found])
8890
],[
8991
-llapacke
9092
])

kernel/common/cblas_funcs.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "common.h"
2020
#include "cblas.h"
2121

22+
#ifdef HAVE_BLAS
2223
/*
2324
* Helper: dispatch to appropriate cblas_?gemm for typenum.
2425
*/
@@ -572,4 +573,5 @@ cblas_matrixproduct(int typenum, CArray * ap1, CArray *ap2, CArray *out, MemoryP
572573
//CArray_DECREF(out_buf);
573574
//CArray_DECREF(result);
574575
return NULL;
575-
}
576+
}
577+
#endif

kernel/linalg.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ DOUBLE_dot(char *ip1, int is1, char *ip2, int is2, char *op, int n)
8686
int is1b = blas_stride(is1, sizeof(double));
8787
int is2b = blas_stride(is2, sizeof(double));
8888

89+
#ifdef HAVE_CBLAS
8990
if (is1b && is2b)
9091
{
9192
double sum = 0.;
@@ -103,6 +104,7 @@ DOUBLE_dot(char *ip1, int is1, char *ip2, int is2, char *op, int n)
103104
*((double *)op) = (double)sum;
104105
}
105106
else {
107+
#endif
106108
double sum = (double)0;
107109
int i;
108110
for (i = 0; i < n; i++, ip1 += is1, ip2 += is2) {
@@ -111,7 +113,9 @@ DOUBLE_dot(char *ip1, int is1, char *ip2, int is2, char *op, int n)
111113
sum += ip1r * ip2r;
112114
}
113115
*((double *)op) = sum;
116+
#ifdef HAVE_CBLAS
114117
}
118+
#endif
115119
}
116120

117121
void
@@ -155,9 +159,11 @@ CArray_Matmul(CArray * ap1, CArray * ap2, CArray * out, MemoryPointer * ptr)
155159
nd1 = CArray_NDIM(ap1);
156160
nd2 = CArray_NDIM(ap2);
157161

162+
#ifdef HAVE_BLAS
158163
if (nd1 <= 2 && nd2 <= 2 && (TYPE_DOUBLE_INT == typenum || TYPE_FLOAT_INT == typenum)) {
159164
return cblas_matrixproduct(typenum, ap1, ap2, out, ptr);
160165
}
166+
#endif
161167

162168
if(typenum == TYPE_INTEGER_INT) {
163169
dot = &INT_dot;

0 commit comments

Comments
 (0)