1- // Comments in this file start with '//'.
2- // Remove where necessary.
1+ ARG_ENABLE("ndarray",
2+ "whether to enable ndarray support",
3+ "Enable ndarray support",
4+ "no")
35
4- ARG_ENABLE('ndarray', 'whether to enable ndarray support', 'no')
6+ ARG_WITH("cuda", "for CUDA support",
7+ "Include CUDA support", "no", "no")
58
6- if PHP_NDARRAY != "no"; then
7- // Check for CUBLAS library
8- PHP_CHECK_LIBRARY('cublas', 'cublasDgemm', '
9- ARG_ENABLE("cublas", "Enable CUBLAS support", "no")
10- AC_MSG_RESULT(["CUBLAS detected"])
11- CFLAGS = CFLAGS + " -lcublas -lcudart "
12- ', '
13- AC_MSG_RESULT(["Wrong CUBLAS version or library not found."])
14- ')
9+ if test x%PHP_CUDA% != xno; then
10+ CHECK_LIB("cublas", "cublasDgemm", ,
11+ [
12+ AC_DEFINE("HAVE_CUBLAS", 1)
13+ PHP_ADD_LIBRARY("cublas", , "NDARRAY_SHARED_LIBADD")
14+ AC_MSG_RESULT("CUBLAS detected")
15+ PHP_ADD_MAKEFILE_FRAGMENT("$abs_srcdir/Makefile.frag", "$abs_builddir")
16+ CFLAGS+=" -lcublas -lcudart"
17+ AC_CHECK_HEADER("immintrin.h",
18+ [
19+ AC_DEFINE("HAVE_AVX2", 1)
20+ AC_MSG_RESULT("AVX2/SSE detected")
21+ CXX+=" -mavx2 -march=native"
22+ ],
23+ [
24+ AC_DEFINE("HAVE_AVX2", 0)
25+ AC_MSG_RESULT("AVX2/SSE not found")
26+ ],
27+ []
28+ )
29+ ],
30+ [
31+ AC_MSG_RESULT("wrong cublas version or library not found.")
32+ AC_CHECK_HEADER("immintrin.h",
33+ [
34+ AC_DEFINE("HAVE_AVX2", 1)
35+ AC_MSG_RESULT("AVX2/SSE detected")
36+ CFLAGS+=" -mavx2 -march=native"
37+ ],
38+ [
39+ AC_DEFINE("HAVE_AVX2", 0)
40+ AC_MSG_RESULT("AVX2/SSE not found")
41+ ],
42+ []
43+ )
44+ ]
45+ )
46+ else
47+ AC_CHECK_HEADER("immintrin.h",
48+ [
49+ AC_DEFINE("HAVE_AVX2", 1)
50+ AC_MSG_RESULT("AVX2/SSE detected")
51+ CFLAGS+=" -mavx2 -march=native"
52+ ],
53+ [
54+ AC_DEFINE("HAVE_AVX2", 0)
55+ AC_MSG_RESULT("AVX2/SSE not found")
56+ ],
57+ []
58+ )
59+ fi
1560
16- // Check for AVX2 support
17- PHP_CHECK_HEADER('immintrin.h', '
18- AC_DEFINE("HAVE_AVX2", 1, ["Have AVX2/SSE support"])
19- AC_MSG_RESULT(["AVX2/SSE detected"])
20- CFLAGS = CFLAGS + " -mavx2 "
21- ', '
22- AC_DEFINE("HAVE_AVX2", 0, ["Have AVX2/SSE support"])
23- AC_MSG_RESULT(["AVX2/SSE not found"])
24- ')
61+ if test x%PHP_GD% != xno; then
62+ AC_DEFINE("HAVE_GD", 1)
63+ AC_MSG_RESULT("GD detected")
64+ PHP_ADD_EXTENSION_DEP("ndarray", "gd", true)
65+ endif
2566
26- // Check for CBLAS library
27- PHP_CHECK_LIBRARY('cblas', 'cblas_sdot', '
28- ARG_ENABLE("cblas", "Enable CBLAS support", "no")
29- AC_MSG_RESULT(["CBLAS detected"])
30- CFLAGS = CFLAGS + " -lcblas "
31- ', '
32- PHP_CHECK_LIBRARY('openblas', 'cblas_sdot', '
33- ARG_ENABLE("openblas", "Enable OpenBLAS support", "no")
34- AC_MSG_RESULT(["OpenBLAS detected"])
35- AC_DEFINE("HAVE_CBLAS", 1, [""])
36- CFLAGS = CFLAGS + " -lopenblas -lpthread "
37- ', '
38- AC_MSG_ERROR(["Wrong OpenBLAS/BLAS version or library not found."])
39- ', '
40- -lopenblas
41- ')
42- ', '
43- -lcblas
44- ')
67+ CHECK_LIB("cblas", "cblas_sdot",
68+ [
69+ AC_DEFINE("HAVE_CBLAS", 1)
70+ PHP_ADD_LIBRARY("cblas", , "NDARRAY_SHARED_LIBADD")
71+ AC_MSG_RESULT("CBlas detected")
72+ CFLAGS+=" -lcblas"
73+ ],
74+ [
75+ CHECK_LIB("openblas", "cblas_sdot",
76+ [
77+ PHP_ADD_LIBRARY("openblas", , "NDARRAY_SHARED_LIBADD")
78+ AC_MSG_RESULT("OpenBLAS detected")
79+ AC_DEFINE("HAVE_CBLAS", 1)
80+ CFLAGS+=" -lopenblas -lpthread"
81+ ],
82+ [
83+ AC_MSG_ERROR("wrong openblas/blas version or library not found.")
84+ ],
85+ [
86+ "-lopenblas"
87+ ]
88+ )
89+ ],
90+ [
91+ "-lcblas"
92+ ]
93+ )
4594
46- // Check for LAPACKE library
47- PHP_CHECK_LIBRARY('lapack', 'dgesvd_', '
48- ARG_ENABLE("lapacke", "Enable LAPACKE support", "no")
49- AC_MSG_RESULT(["LAPACKE detected"])
50- CFLAGS = CFLAGS + " -llapack -llapacke "
51- ', '
52- AC_MSG_ERROR(["Wrong LAPACKE version or library not found."])
53- ')
95+ CHECK_LIB("lapacke", "LAPACKE_sgesdd",
96+ [
97+ AC_DEFINE("HAVE_LAPACKE", 1)
98+ PHP_ADD_LIBRARY("lapack", , "NDARRAY_SHARED_LIBADD")
99+ AC_MSG_RESULT("LAPACKE detected")
100+ CFLAGS+=" -llapack -llapacke"
101+ ],
102+ [
103+ AC_MSG_ERROR("wrong LAPACKE version or library not found. Try `apt install liblapacke-dev`")
104+ ]
105+ )
54106
55- // Add your extension's source files
56- PHP_ADD_EXTENSION('ndarray', '
57- numpower.c \
58- src/initializers.c \
59- src/ndmath/double_math.c \
60- src/ndarray.c \
61- src/debug.c \
62- src/buffer.c \
63- src/logic.c \
64- src/gpu_alloc.c \
65- src/ndmath/linalg.c \
66- src/manipulation.c \
67- src/iterators.c \
68- src/indexing.c \
69- src/ndmath/arithmetics.c \
70- src/ndmath/statistics.c \
71- src/types.c
72- ')
107+ if test x%PHP_NDARRAY% != xno; then
108+ AC_DEFINE("HAVE_NDARRAY", 1, "Have ndarray support")
109+ PHP_NEW_EXTENSION("ndarray",
110+ "numpower.c src/initializers.c src/ndmath/double_math.c src/ndarray.c src/debug.c src/buffer.c src/logic.c src/gpu_alloc.c src/ndmath/linalg.c src/manipulation.c src/iterators.c src/indexing.c src/ndmath/arithmetics.c src/ndmath/statistics.c src/types.c",
111+ %ext_shared%
112+ )
73113endif
0 commit comments