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

Commit eb916c5

Browse files
Implemented clBLAS (OpenCL) for AMD GPU computing
1 parent 9bed151 commit eb916c5

File tree

5 files changed

+643
-6
lines changed

5 files changed

+643
-6
lines changed

config.m4

+35-1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,39 @@ AC_CHECK_HEADERS(
6464
[[#include "/usr/include/openblas/cblas.h"]]
6565
)
6666

67+
68+
AC_CHECK_HEADERS(
69+
[/usr/include/clBLAS.h],
70+
[
71+
PHP_ADD_INCLUDE(/usr/include/)
72+
],
73+
,
74+
[[#include "/usr/include/clBLAS.h"]]
75+
)
76+
77+
78+
79+
PHP_CHECK_LIBRARY(clBLAS,clblasSgemm,
80+
[
81+
PHP_ADD_LIBRARY(clBLAS)
82+
AC_DEFINE(HAVE_CLBLAS,1,[Have CLBLAS support])
83+
84+
PHP_CHECK_LIBRARY(OpenCL,clGetPlatformIDs,
85+
[
86+
PHP_ADD_LIBRARY(OpenCL)
87+
AC_DEFINE(HAVE_OPENCL,1,[Have OpenCL support])
88+
],[
89+
AC_MSG_RESULT([OpenCL not detected (OpenCL BLAS not available).])
90+
],[
91+
-lOpenCL
92+
])
93+
],[
94+
AC_MSG_RESULT([clBLAS not detected (OpenCL BLAS not available).])
95+
],[
96+
-lclBLAS
97+
])
98+
99+
67100
PHP_CHECK_LIBRARY(blas,cblas_sdot,
68101
[
69102
PHP_ADD_LIBRARY(blas)
@@ -91,7 +124,7 @@ PHP_CHECK_LIBRARY(lapacke,LAPACKE_sgetrf,
91124
-llapacke
92125
])
93126

94-
CFLAGS="$CFLAGS -lopenblas -llapacke -lblas -llapack"
127+
CFLAGS="$CFLAGS -lopenblas -llapacke -lblas -llapack -lclBLAS -lOpenCL"
95128

96129
PHP_NEW_EXTENSION(carray,
97130
phpsci.c \
@@ -107,6 +140,7 @@ PHP_NEW_EXTENSION(carray,
107140
kernel/shape.c \
108141
kernel/common/common.c \
109142
kernel/common/cblas_funcs.c \
143+
kernel/common/clblas_funcs.c \
110144
kernel/common/mem_overlap.c \
111145
kernel/number.c \
112146
kernel/convert_type.c \

kernel/common/cblas_funcs.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,17 @@
1010
* Henrique Borba
1111
1212
*/
13-
13+
#include "config.h"
1414
#include "../carray.h"
1515
#include "../convert.h"
1616
#include "cblas_funcs.h"
1717
#include "../buffer.h"
1818
#include "../alloc.h"
1919
#include "common.h"
20-
#include "cblas.h"
2120

2221
#ifdef HAVE_BLAS
22+
#include "cblas.h"
23+
2324
/*
2425
* Helper: dispatch to appropriate cblas_?gemm for typenum.
2526
*/

0 commit comments

Comments
 (0)