From 8a7a08f0109344d602d36301df161b76b5994a68 Mon Sep 17 00:00:00 2001 From: Yuichi Ishikawa Date: Tue, 26 Mar 2024 13:55:09 +0900 Subject: [PATCH] math matrix 2.0 descriptions --- _config.yml | 2 +- _data/widgets/nav/mathematics.yml | 4 +- _data/widgets/navv/mathematics.yml | 12 +- _mathematics/acceleration/opencl.md | 202 +++++++++++++++------ _mathematics/api/apitoc.md | 2 +- _mathematics/api/blas.md | 2 +- _mathematics/api/buffer.md | 2 +- _mathematics/api/linearalgebra.md | 10 +- _mathematics/api/math.md | 68 +------ _mathematics/api/matrixoperator.md | 2 +- _mathematics/index.md | 35 ++-- _mathematics/matrix/arrayobjects.md | 5 +- _mathematics/matrix/dimensionoperations.md | 19 +- _mathematics/matrix/matrix.md | 58 ++---- _mathematics/openblas/arraybuffer.md | 133 +++++++------- _mathematics/openblas/blaslibrary.md | 34 +++- _mathematics/openblas/mathlibrary.md | 50 +++-- _mathematics/openblas/overviewopenblas.md | 195 ++++++++------------ _neuralnetworks/api/neuralnetworks.md | 8 +- _neuralnetworks/index.md | 3 +- _neuralnetworks/install.md | 2 +- about.md | 4 +- index.html | 2 +- 23 files changed, 415 insertions(+), 439 deletions(-) diff --git a/_config.yml b/_config.yml index bd39450..d867f87 100644 --- a/_config.yml +++ b/_config.yml @@ -95,7 +95,7 @@ collections: mathematics: title: "Rindow Mathematics" description: "Mathematics libraries for PHP" - #meta_description: "An environment for vector operations suitable for scientific calculation and machine learning is provided on PHP. It also provides a PHP array extension that is optimal for vector operations." + #meta_description: "An environment for vector operations suitable for scientific calculation and machine learning is provided on PHP. It also provides a C library that is optimal for vector operations." output: true theme: document #comment: true diff --git a/_data/widgets/nav/mathematics.yml b/_data/widgets/nav/mathematics.yml index 2cf6444..a4c2f82 100644 --- a/_data/widgets/nav/mathematics.yml +++ b/_data/widgets/nav/mathematics.yml @@ -44,8 +44,8 @@ menu: | - [Scatter plot](/mathematics/plot/gettingstartplot.html#scatter-plot) - [Pie chart](/mathematics/plot/gettingstartplot.html#pie-chart) - [Heat map](/mathematics/plot/gettingstartplot.html#heat-map) - - **Rindow OpenBLAS extension** - - [Rindow OpenBLAS extension](/mathematics/openblas/overviewopenblas.html) + - **Rindow OpenBLAS FFI** + - [Rindow OpenBLAS FFI](/mathematics/openblas/overviewopenblas.html) - [Overview](/mathematics/openblas/overviewopenblas.html#overview) - [Requirements](/mathematics/openblas/overviewopenblas.html#requirements) - [Download binaries](/mathematics/openblas/overviewopenblas.html#download-binaries) diff --git a/_data/widgets/navv/mathematics.yml b/_data/widgets/navv/mathematics.yml index 392b838..6feb8ca 100644 --- a/_data/widgets/navv/mathematics.yml +++ b/_data/widgets/navv/mathematics.yml @@ -95,9 +95,9 @@ menu: link: /mathematics/plot/gettingstartplot.html#pie-chart - caption: Heat map link: /mathematics/plot/gettingstartplot.html#heat-map -- caption: Rindow OpenBLAS extension +- caption: Rindow OpenBLAS FFI menu: - - caption: Rindow OpenBLAS extension + - caption: Rindow OpenBLAS FFI link: /mathematics/openblas/overviewopenblas.html menu: - caption: Overview @@ -149,10 +149,10 @@ menu: menu: - caption: Overview link: /mathematics/acceleration/opencl.html - - caption: Rindow OpenCL extension - link: /mathematics/acceleration/opencl.html#rindow-opencl-extension - - caption: Rindow CLBlast extension - link: /mathematics/acceleration/opencl.html#rindow-clblast-extension + - caption: Rindow OpenCL FFI + link: /mathematics/acceleration/opencl.html#rindow-opencl-ffi + - caption: Rindow CLBlast FFI + link: /mathematics/acceleration/opencl.html#rindow-clblast-ffi - caption: OpenCLMath liblary link: /mathematics/acceleration/opencl.html#openclmath-liblary-in-rindow-math-matrix - caption: Requirements diff --git a/_mathematics/acceleration/opencl.md b/_mathematics/acceleration/opencl.md index 3ba11a4..291fe1c 100644 --- a/_mathematics/acceleration/opencl.md +++ b/_mathematics/acceleration/opencl.md @@ -5,85 +5,179 @@ upper_section: index --- Overview -------- -We chose OpenCL first because it supports various arithmetic accelerations including GPU. -This allows you to expect GPU acceleration even in an inexpensive laptop environment. +We initially chose OpenCL because it supports a variety of arithmetic accelerations, including GPUs. +As a result, you can expect faster GPU speeds even in an inexpensive notebook PC environment. -Not only OpenCL support but also an operation library using OpenCL is required to speed up numerical operations. CLBlast is an OpenCL-compatible library that is currently under active development. -In addition to this, various necessary operations provide OpenCL programs on PHP in Rindow Math Matrix. +To speed up numerical operations, you need not only support for OpenCL, but also a calculation library that uses OpenCL. CLBlast is a BLAS compatible library currently under development. +In addition to this, Rindow Math Matrix allows you to perform other MATH functions and various necessary operations on OpenCL. -Rindow OpenCL extension +Rindow OpenCL FFI ----------------------- -OpenCL can be used from PHP through [Rindow OpenCL extension](https://github.com/rindow/rindow-opencl). -The version of OpenCL is limited to version 1.2, and we are considering porting to a wide range of environments. +OpenCL is available from PHP through [Rindow OpenCL FFI](https://github.com/rindow/rindow-opencl-ffi). +OpenCL version is limited to 1.2 and is compatible with a wide range of environments. -Since our goal is to use it with the Rindow Neural Network Library, we currently only have the minimum required functionality. It will be expanded in the future. +Our goal is to use it with the Rindow neural network library, so it currently only has the bare minimum of functionality. It will be expanded in the future. -Rindow CLBlast extension +Rindow CLBlast FFI ----------------------- -CLBlast is BLAS library on OpenCL. [Click here for details](https://github.com/CNugteren/CLBlast). +CLBlast is a BLAS library on top of OpenCL. [Click here for details](https://github.com/CNugteren/CLBlast). -[Rindow CLBlast extension](https://github.com/rindow/rindow-clblast) is a PHP binding for the above library. +[Rindow CLBlast FFI](https://github.com/rindow/rindow-clblast) is a PHP binding for the above library. -OpenCLMath liblary in Rindow Math Matrix ----------------------------------------- -It provides useful functions on OpenCL that are not included in the BLAS library. - +OpenCLMath library for Rindow Math Matrix +-------------------------------------- +Provides useful functions on OpenCL that are not included in the BLAS library. Requirements ------------ -- PHP7.2 or PHP7.3 or PHP7.4 or PHP8.0 or PHP8.1 or PHP8.2 -- interop-phpobjects/polite-math 1.0.4 or later -- LinearBuffer implements for interop-phpobjects (Rindow OpenBLAS extension etc.) -- OpenCL 1.2 drivers/libraries. -- Windows 10,11 or Linux(Ubuntu) +- PHP8.1 or PHP8.2 or PHP8.3 +- interop-phpobjects/polite-math 1.0.6 or later +- OpenCL 1.1 or later drivers/libraries. +- Windows 10, 11 or Linux (Ubuntu 20.04 or later) - Rindow Math Matrix -- Rindow OpenCL extension -- Rindow CLBlast extension +- Rindow OpenCL FFI +- Rindow CLBlast FFI + +GPU/OpenCL support for Windows +------------------------------ +OpenCL can be used by default on Windows. + +Please download the pre-build binaries and set the execution path. -Currently it does not support Linux environment. +- [OpenBLAS](https://github.com/OpenMathLib/OpenBLAS/releases) +- [Rindow Matlib](https://github.com/rindow/matlib/releases) +- [CLBlast](https://github.com/CNugteren/CLBlast/releases) + +```shell +C:TEMP>PATH %PATH%;C:\CLBlast\bin;C:\OpenBLAS\bin;C:\Matlib\bin +``` + +Configure the PHP. Edit php.ini to use FFI extension + +```shell +extension = ffi +``` +Set up rindow-math-matrix to use OpenCL using composer. And make sure you are in Advanced mode. -How to setup pre-build binaries -------------------------------- -You can download and use pre-built Windows binaries. -Download the binary for your version of PHP. +```shell +C:yourproject> composer require rindow/rindow-math-matrix +C:yourproject> composer require rindow/rindow-math-matrix-matlibffi +C:yourproject> vendor\bin\rindow-math-matrix +Service Level : Accelerated +Buffer Factory : Rindow\Math\Buffer\FFI\BufferFactory +BLAS Driver : Rindow\OpenBLAS\FFI\Blas +LAPACK Driver : Rindow\OpenBLAS\FFI\Lapack +Math Driver : Rindow\Matlib\FFI\Matlib +OpenCL Factory : Rindow\OpenCL\FFI\OpenCLFactory +CLBlast Factory : Rindow\CLBlast\FFI\CLBlastFactory -- https://github.com/rindow/rindow-openblas/releases -- https://github.com/xianyi/OpenBLAS/releases -- https://github.com/rindow/rindow-opencl/releases -- https://github.com/rindow/rindow-clblast/releases -- https://github.com/CNugteren/CLBlast/releases +``` +If you are unable to successfully set the target GPU, please check the OpenCL device status using the clinfo command. -Please download the following two binaries and extract. +```shell +C:tutorials>vendor\bin\clinfo +Number of platforms(1) +Platform(0) + CL_PLATFORM_NAME=Intel(R) OpenCL + CL_PLATFORM_PROFILE=FULL_PROFILE +.... +... +.. +``` -- The PHP extension of rindow-opencl that matches the php version. -- The PHP extension of rindow-openblas that matches the php version. -- The PHP extension of rindow-clblast that matches the php version. -- DLL of OpenBLAS library. -- DLL of CLBlast library. -> If you are using Windows, you must Download the version of OpenBLAS binaries that correspond to the -> rindow_openblas binaries. The compatible OpenBLAS Library release number is included in the filename -> of the rindow-openblas pre-built archive file. If you use the wrong OpenBLAS release number DLL, -> it will not work properly. -> All so rindow_clblast and Clblast Library release number. +GPU/OpenCL support for Ubuntu +------------------------------ +Install the libraries required. -Copy the shared library to the PHP extension directory and set it in php.ini. -And OpenBLAS DLL's path to Windows PATH environment variable. ++ Install OpenBLAS with apt command ++ Download the latest version of Rindow-Matlib's pre-built binary files from https://github.com/rindow/rindow-matlib/releases. ++ Install the downloaded deb file using the apt command. ++ Set Rindow-Matlib to serial mode for use with PHP. ```shell -C:\tmp>copy rindow_openblas.dll /path/to/php-installation-path/ext -C:\tmp>copy rindow_opencl.dll /path/to/php-installation-path/ext -C:\tmp>copy rindow_clblast.dll /path/to/php-installation-path/ext -C:\tmp>echo extension=rindow_openblas.dll >> /path/to/php-installation-path/php.ini -C:\tmp>echo extension=rindow_opencl.dll >> /path/to/php-installation-path/php.ini -C:\tmp>echo extension=rindow_clblast.dll >> /path/to/php-installation-path/php.ini -C:\tmp>PATH %PATH%;/path/to/OpenBLAS/bin;/path/to/CLBlast-Library/lib -C:\tmp>cd /some/app/directory -C:\app\dir>composer require rindow/rindow-math-matrix +$ sudo apt install libopenblas-base liblapacke +$ wget https://github.com/rindow/rindow-matlib/releases/download/X.X.X/rindow-matlib_X.X.X_amd64.deb +$ sudo apt install ./rindow-matlib_X.X.X_amd64.deb +$ sudo update-alternatives --config librindowmatlib.so +There are 2 choices for the alternative librindowmatlib.so (providing /usr/lib/librindowmatlib.so). + + Selection Path Priority Status +------------------------------------------------------------ +* 0 /usr/lib/rindowmatlib-openmp/librindowmatlib.so 95 auto mode + 1 /usr/lib/rindowmatlib-openmp/librindowmatlib.so 95 manual mode + 2 /usr/lib/rindowmatlib-serial/librindowmatlib.so 90 manual mode + +Press to keep the current choice[*], or type selection number: 2 +``` + +It is essential that OpenCL works properly in the Linux environment. +(That's quite difficult) + +Install the OpenCL environment. + +```shell +$ sudo apt install clinfo +$ sudo apt install intel-opencl-icd +``` +Ubuntu standard OpenCL drivers include: +- mesa-opencl-icd +- beignet-opencl-icd +- intel-opencl-icd +- nvidia-opencl-icd-xxx +- pocl-opencl-icd + +The standard Linux OpenCL driver does not work properly, so we deal with it on a case-by-case basis to make it work somehow for each driver and version. + +Check that OpenCL is running using the clinfo command. + +```shell +$ clinfo +Number of platforms 1 + Platform Name Intel Gen OCL Driver + Platform Vendor Intel +.... +... +.. +``` + +Download and install the CLBlast library. +Scripts are available for easy download and installation. + ++ Check the latest version: [CLBlast library](https://github.com/CNugteren/CLBlast/releases) ++ Copy script ++ Change the version at the beginning of the script ++ Run script and create deb file ++ Install deb file + +```shell +$ cp vendor/rindow/rindow-clblast-ffi/clblast-packdeb.sh . +$ vi clblast-packdeb.sh +CLBLASTVERSION=1.6.2 <===== change +$ sh clblast-packdeb.sh +$ sudo apt install ./clblast_X.X.X-1+ubuntuXX.XX_amd64.deb +``` + +Configure the rindow-math-matrix. + ++ Verify that rindow-math-matrix is Accelerated and the OpenCL driver is recognized. + +```shell +$ composer rindow/rindow-math-matrix +$ composer rindow/rindow-math-matrix-ffi +$ vendor\bin\rindow-math-matrix +Service Level : Accelerated +Buffer Factory : Rindow\Math\Buffer\FFI\BufferFactory +BLAS Driver : Rindow\OpenBLAS\FFI\Blas +LAPACK Driver : Rindow\OpenBLAS\FFI\Lapack +Math Driver : Rindow\Matlib\FFI\Matlib +OpenCL Factory : Rindow\OpenCL\FFI\OpenCLFactory +CLBlast Factory : Rindow\CLBlast\FFI\CLBlastFactory + ``` diff --git a/_mathematics/api/apitoc.md b/_mathematics/api/apitoc.md index c4f9466..58dd86f 100644 --- a/_mathematics/api/apitoc.md +++ b/_mathematics/api/apitoc.md @@ -13,7 +13,7 @@ upper_section: index - [Figure](figure.html) - [Axes](axes.html) - [misc.](miscplot.html) -- Rindow\\OpenBLAS +- Low-layer Matrix Libraries - [Buffer](buffer.html) - [Blas](blas.html) - [Math](math.html) diff --git a/_mathematics/api/blas.md b/_mathematics/api/blas.md index 2aeddd4..e066ac9 100644 --- a/_mathematics/api/blas.md +++ b/_mathematics/api/blas.md @@ -6,7 +6,7 @@ upper_section: api/apitoc previous_section: api/buffer next_section: api/math --- -- **namespace**: Rindow\\OpenBLAS +- **namespace**: Rindow\\OpenBLAS\\FFI - **classname**: Blas Call OpenBLAS functions. diff --git a/_mathematics/api/buffer.md b/_mathematics/api/buffer.md index 0fa9545..bcd28e1 100644 --- a/_mathematics/api/buffer.md +++ b/_mathematics/api/buffer.md @@ -5,7 +5,7 @@ grand_upper_section: index upper_section: api/apitoc next_section: api/blas --- -- **namespace**: Rindow\\OpenBLAS +- **namespace**: Rindow\\Math\\Buffer\\FFI - **classname**: Buffer Buffer object for array. Allocate contiguous memory area. diff --git a/_mathematics/api/linearalgebra.md b/_mathematics/api/linearalgebra.md index 25f14d7..f4c3f06 100644 --- a/_mathematics/api/linearalgebra.md +++ b/_mathematics/api/linearalgebra.md @@ -16,7 +16,7 @@ The input data area and output data area are shared by many functions. So note that the contents of the input array will be destroyed. The BLAS library and the MATH library specified by "MatrixOperator" are used internally. -When the rindow_openblas extension is specified, high-speed operations are possible. +When the OpenBLAS FFI is specified, high-speed operations are possible. Methods ------- @@ -408,8 +408,6 @@ public function rotg( ``` Get the Givens rotation. -You need the openblas extension to use this function. - Arguments - **X**: the value of axis X. - **Y**: the value of axis Y. @@ -459,8 +457,6 @@ public function rot( ``` Get Coordinate rotation -You need the openblas extension to use this function. - Arguments - **X**: the value of axis X. - **Y**: the value of axis Y. @@ -772,8 +768,6 @@ public function trmm( ``` Cross product of a triangular matrix -You need the openblas or clblast extension to use this function. - Arguments - **A**: A matrix. - **B**: B matrix. @@ -828,8 +822,6 @@ public function trsm( ``` Cross product of a triangular matrix -You need the openblas or clblast extension to use this function. - Arguments - **A**: A matrix. - **B**: B matrix. diff --git a/_mathematics/api/math.md b/_mathematics/api/math.md index d0cc2fd..aaf9fc0 100644 --- a/_mathematics/api/math.md +++ b/_mathematics/api/math.md @@ -6,7 +6,7 @@ grand_upper_section: index upper_section: api/apitoc previous_section: api/blas --- -- **namespace**: Rindow\\OpenBLAS +- **namespace**: Rindow\\Matlib\\FFI - **classname**: Math Mathematics functions library. @@ -501,72 +501,6 @@ Arguments - **offsetX**: Offset buffer. - **incX**: Incremental X -### selectAxis0 -$$ -\begin{align*} -y_{ij} := a_{xj} -\end{align*} -$$ -```php -public function selectAxis0( - int $m, - int $n, - int $k, - Buffer $A, int $offsetA, int $ldA, - Buffer $X, int $offsetX, int $incX, - Buffer $Y, int $offsetY, int $ldY ) : void -``` -Select the element indexed by axis 0. - -Supported deta types -- float32, float64, bool, int8, int16, int32, int64, uint8, uint16, uint32, uint64 - -Arguments -- **m**: Number of array elements. -- **n**: Number of array elements. -- **k**: Number of array elements. -- **A**: Buffer A. -- **offsetA**: Offset buffer. -- **ldA**: leading dimension -- **X**: Buffer X. -- **offsetX**: Offset buffer. -- **incX**: Incremental X -- **Y**: Buffer Y. -- **offsetY**: Offset buffer. -- **ldY**: leading dimension - -### selectAxis1 -$$ -\begin{align*} -y_{ij} := a_{ix} -\end{align*} -$$ -```php -public function selectAxis1( - int $m, - int $n, - Buffer $A, int $offsetA, int $ldA, - Buffer $X, int $offsetX, int $incX, - Buffer $Y, int $offsetY, int $incY ) : void -``` -Select the element indexed by axis 1. - -Supported deta types -- float32, float64, bool, int8, int16, int32, int64, uint8, uint16, uint32, uint64 - -Arguments -- **m**: Number of array elements. -- **n**: Number of array elements. -- **A**: Buffer A. -- **offsetA**: Offset buffer. -- **ldA**: leading dimension -- **X**: Buffer X. -- **offsetX**: Offset buffer. -- **incX**: Incremental X -- **Y**: Buffer Y. -- **offsetY**: Offset buffer. -- **incY**: Incremental X - ### updateAddOnehot $$ \begin{align*} diff --git a/_mathematics/api/matrixoperator.md b/_mathematics/api/matrixoperator.md index b57df2f..7aff030 100644 --- a/_mathematics/api/matrixoperator.md +++ b/_mathematics/api/matrixoperator.md @@ -10,7 +10,7 @@ next_section: api/random - **classname**: MatrixOperator General operations on N-dimensional arrays. -If you have loaded the “rindow_openblas” extension, enable it. +If you have loaded the “OpenBLAS”, enable it. Methods ------- diff --git a/_mathematics/index.md b/_mathematics/index.md index 68e24b2..2f844b0 100644 --- a/_mathematics/index.md +++ b/_mathematics/index.md @@ -1,35 +1,36 @@ --- layout: document title: "Rindow mathematics libraries" -meta_description: "An environment for vector operations suitable for scientific calculation and machine learning is provided on PHP. It also provides a PHP array extension that is optimal for vector operations." +meta_description: "An environment for vector operations suitable for scientific calculation and machine learning is provided on PHP. It also provides a C library that is optimal for vector operations." next_section: matrix/matrix --- Overview -------- -A project to provide a mathematical libraries for PHP. +A project that provides a math library for PHP. -Most scientific calculations and machine learning use vector operations, -but PHP functions are only scalar operations. -Also, PHP Array is not suitable for vector operation. +Most scientific computing and machine learning use vector operations. +However, PHP functions are just scalar operations. +Also, PHP Arrays are not suitable for vector operations. -Therefore, the basic policy is to define an Array object suitable -for vector operation and build everything on it. +Therefore, the basic idea is to define a suitable Array object. +Build everything on top of that for vector operations. -It has the following features. +It has the following characteristics. -- Define a common Array object interface "NDArray". -- Provides a flexible matrix operation library. -- Provide C language interface of Array object by PHP extension -- High-speed matrix operation provided by PHP extension -- Provides a visualization library for mathematical data +- Defines a common Array object interface "NDArray". +- Provides a flexible matrix calculation library. +- Link external math libraries to speed up matrix operations. +- Utilize GPU to speed up matrix operations. +- Provides a mathematical data visualization library Libraries --------- -Divided into five libraries +Divided into 6 libraries - [**Rindow Math Matrix**](matrix/matrix.html): NDArray and array operations - [**Rindow Math Plot**](plot/overviewplot.html): Visualization mathematical data -- [**Rindow OpenBLAS extension**](openblas/overviewopenblas.html): C language interface and High-speed operation -- [**Rindow OpenCL extension**](acceleration/opencl.html#rindow-opencl-extension): Supports GPU acceleration -- [**Rindow CLBlast extension**](acceleration/opencl.html#rindow-clblast-extension): Supports GPU acceleration +- [**Rindow OpenBLAS FFI**](openblas/overviewopenblas.html): C language interface and High-speed operation +- [**Rindow Matlib FFI**](openblas/overviewopenblas.html): C language interface and High-speed operation +- [**Rindow OpenCL FFI**](acceleration/opencl.html#rindow-opencl-ffi): Supports GPU acceleration +- [**Rindow CLBlast FFI**](acceleration/opencl.html#rindow-clblast-ffi): Supports GPU acceleration diff --git a/_mathematics/matrix/arrayobjects.md b/_mathematics/matrix/arrayobjects.md index ae8e432..779bfdf 100644 --- a/_mathematics/matrix/arrayobjects.md +++ b/_mathematics/matrix/arrayobjects.md @@ -151,9 +151,10 @@ Buffer object ### Overview The buffer object is the area that stores the actual data of the NDArray. Implements a one-dimensional array. It must implement the standard ArrayAccess interface of PHP and the Countable interface. -(Because it is assumed to be implemented with php extension, Buffer specific interface is not defined) +Since it is assumed that various implementations will be used, a basic Buffer interface is defined. + +One-dimensional arrays can be implemented in any way, but contiguous areas of memory generally make it easier for the CPU to perform fast operations. It is easy to refer to memory areas at the C language level, and it is also easy to exchange data between high-speed calculation libraries. -One-dimensional arrays can be implemented in any way, but contiguous areas of memory generally make it easier for the CPU to perform high-speed operations. It is easy to refer to the memory area at the C language level, and it is easy to exchange data between extensions. For these reasons, NDArray uses a one-dimensional array buffer object rather than a PHP array. diff --git a/_mathematics/matrix/dimensionoperations.md b/_mathematics/matrix/dimensionoperations.md index 017acca..fc22274 100644 --- a/_mathematics/matrix/dimensionoperations.md +++ b/_mathematics/matrix/dimensionoperations.md @@ -4,16 +4,17 @@ title: "Dimension Operations" upper_section: index previous_section: matrix/arrayobjects --- -Overview +overview -------- -MatrixOperator performs general operations on N-dimensional arrays. Broadcasting can also give the same change to all elements. -Also provides random number arithmetic. -These are designed to resemble Python's Numpy. +MatrixOperator performs common operations on N-dimensional arrays. Broadcasting also allows you to apply the same changes to all elements. +It also provides random number operations. +These are designed to be similar to Python's Numpy. -We also provide functions that prioritize faster operations than flexibility. -These are implemented by excerpts from Basic Linear Algebra Subprograms (BLAS). Other scientific calculations are implemented as needed. +It also offers features that prioritize speed over flexibility. +These are implemented by excerpts from Basic Linear Algebra Subprograms (BLAS). Other scientific calculations will also be implemented as needed. + +It also works with pure PHP. You can also call OpenBLAS or Rindow-Matlib to make it work. -Automatically recognizes that the Rindow OpenBLAS extension is loaded and performs high-speed calculations. Create MatrixOperator --------------------- @@ -21,7 +22,7 @@ First, create an instance of MatrixOperator. (Currently, it does not support the ```php use Rindow\Math\Matrix\MatrixOperator; -$mo = new MatrixOperator; +$mo = new MatrixOperator(); ``` Create NDArray @@ -310,7 +311,7 @@ Most functions are algorithms that assume two-dimensional or one-dimensional arr The input data is destroyed and used as the output data area. This minimizes data copying in the process of performing continuous operations. -If you have the Rindow OpenBLAS extension loaded, it will call the extension and run faster. +If you have the OpenBLAS loaded, it will call it and run faster. - BLAS library - Mathematics library diff --git a/_mathematics/matrix/matrix.md b/_mathematics/matrix/matrix.md index e8ed403..d581773 100644 --- a/_mathematics/matrix/matrix.md +++ b/_mathematics/matrix/matrix.md @@ -15,60 +15,32 @@ It has the following features. - Implement a common Array object interface "NDArray". - Provides a flexible N-dimensional array operation library. -- Compatible with Rindow OpenBLAS extension +- Compatible with OpenBLAS -Requirements +requirements ------------ -- PHP 8.0, 8.1, 8.2 - - (If you want to use it on PHP 7.(2,3,4) environment, please use Release 1.1.x.) -- Window 10,11 or Linux when using Rindow OpenBLAS extension +- PHP 8.1, 8.2, 8.3 + - (If using in PHP 7.2 to 8.0 environment, please use release 1.1.) +- Window 10, 11, or Linux (if using OpenBLAS) + Recommends ---------- - [**Rindow Math Plot**](/mathematics/plot/overviewplot.html): Visualization mathematical data -- [**Rindow OpenBLAS extension**](/mathematics/openblas/overviewopenblas.html): C language interface and High-speed operation -- [**Rindow OpenCL extension**](https://github.com/rindow/rindow-opencl/releases): Supports GPU acceleration -- [**Rindow CLBlast extension**](https://github.com/rindow/rindow-clblast/releases): Supports GPU acceleration +- [**Rindow Matlib and OpenBLAS**](/mathematics/openblas/overviewopenblas.html): C language interface and High-speed operation +- [**OpenCL and CLBlast**](/mathematics/acceleration/openblas.html): Supports GPU acceleration Installation ------------ - ### Install the Rindow Math Matrix - -If you want to use extensions, download and setup pre-build binaries. -See the README for each extension. - -- https://github.com/rindow/rindow-openblas -- https://github.com/rindow/rindow-opencl -- https://github.com/rindow/rindow-clblast - -> If you are using Windows, you must Download the version of OpenBLAS binaries that correspond to the -> rindow_openblas binaries. The compatible OpenBLAS Library release number is included in the filename -> of the rindow-openblas pre-built archive file. If you use the wrong OpenBLAS release number DLL, -> it will not work properly. -> All so rindow_clblast and Clblast Library release number. - -Make sure the php extension is loaded. - -```shell -$ php -m -[PHP Modules] -... -rindow_openblas -rindow_opencl -rindow_clblast -... -``` - Please set up with composer. ```shell $ composer require rindow/rindow-math-matrix ``` - If you want a graphical display, set up rindow-math-plot. ```shell @@ -83,9 +55,16 @@ $ export RINDOW_MATH_PLOT_VIEWER ``` Note: Specify "viewnior" etc. for RINDOW_MATH_PLOT_VIEWER +### Install accelarators + +To use OpenBLAS and Rindow-Matlib, read and install them [here](/mathematics/openblas/overviewopenblas.html). + + +To use GPU, please read [here](/mathematics/acceleration/openblas.html) and install it. + + ### How to use the Rindow Math Matrix ```php -array([3.0, 4.0]); $c = $mo->add($a,$b); echo $mo->toString($c)."\n"; -print_r($c->toArray()); ### If you want to create a graph like this: @@ -108,7 +86,6 @@ $plt->show(); If you want to use the linear algebra library: ```php -array([[3.0, 4.0],[5.0, 6.0]]); $c = $la->gemm($a,$b); echo $mo->toString($c)."\n"; -print_r($c->toArray()); ### If you want to create a graph like this: @@ -132,7 +108,6 @@ $plt->show(); If you want to use the GPU version of the linear algebra library: ```php -gemm($a,$b); $c = $la->toNDArray($c); echo $mo->toString($c)."\n"; -print_r($c->toArray()); ### If you want to create a graph like this: diff --git a/_mathematics/openblas/arraybuffer.md b/_mathematics/openblas/arraybuffer.md index 1f59e5c..49e831d 100644 --- a/_mathematics/openblas/arraybuffer.md +++ b/_mathematics/openblas/arraybuffer.md @@ -24,32 +24,79 @@ PHP interface Buffer is created by specifying data type and size. Since it has an ArrayAccess interface and a Count interface, it can be used like an array. -Buffer has the following interface for convenience. +The universal Buffer has the following interface for convenience: ```php -namespace Rindow\OpenBLAS; -use ArrayAccess; +use Interop\Polite\Math\Matrix\Buffer as BufferInterface; + +class Buffer implements BufferInterface { + public function __construct(int $size, int $dtype); + public function dtype() : int; + public function value_size() : int; + public function count() : int; + public function offsetExists(mixed $offset) : bool; + public function offsetGet(mixed $offset): mixed; + public function offsetSet(mixed $offset, mixed $value): void; + public function offsetUnset(mixed $offset): void; + public function dump() : string; + public function load(string $string) : void; +} +``` +The definition of the Buffer interface is as follows. +```php +namespace Interop\Polite\Math\Matrix; + use Countable; -class Buffer implement ArrayAccess,Countable +use ArrayAccess; + +interface BufferInterface extends Countable,ArrayAccess { - public function __construct(int $size,int $dtype); - public function offsetExists(int $offset); - public function offsetGet(int $offset); - public function offsetSet(int $offset,$value); - public function offsetUnset(int $offset); - public function count() : int; +} +``` + +To enable a C language interface, rindow-math-buffer-ffi via FFI adds a LinearBuffer interface that inherits from Buffer and an addr method. + +LinearBuffer represents a continuous memory space buffer such as in C language. + +```php +namespace Rindow\Math\Buffer\FFI; +use Interop\Polite\Math\Matrix\LinearBuffer; +use FFI; + +class Buffer implements LinearBuffer { + public function __construct(int $size, int $dtype); public function dtype() : int; + public function value_size() : int; + public function count() : int; + public function addr(int $offset) : FFI\CData + public function offsetExists(mixed $offset) : bool; + public function offsetGet(mixed $offset): mixed; + public function offsetSet(mixed $offset, mixed $value): void; + public function offsetUnset(mixed $offset): void; public function dump() : string; - public function load(string $data) : void; + public function load(string $string) : void; } ``` +To standardize the interface, be sure to use a factory to generate objects. +```php +namespace Rindow\Math\Buffer\FFI; + +class BufferFactory +{ + public function isAvailable() : bool; + public function Buffer(int $size, int $dtype) : Buffer; +} +``` + + Usage on PHP ------------ Here is the sample code. ```php use Interop\Polite\Math\Matrix\NDArray; -$buffer = new Rindow\OpenBLAS\Buffer(10,NDArray::float32); +$factory = new Rindow\Math\Buffer\FFI\BufferFactory() +$buffer = $factory->Buffer(10,NDArray::float32); $buffer[0] = 1.0; $buffer[1] = 1.5; $x = $buffer[0]+$buffer[1]; @@ -58,68 +105,10 @@ $count = count($buffer); You can quickly dump the data in the buffer. ```php -use Interop\Polite\Math\Matrix\NDArray; -$x = new Rindow\OpenBLAS\Buffer(10,NDArray::float32); -$y = new Rindow\OpenBLAS\Buffer(10,NDArray::float32); +$x = $factory->Buffer(10,NDArray::float32); +$y = $factory->Buffer(10,NDArray::float32); $x[0] = 1.0; $x[1] = 1.5; $data = $x->dump(); $y->load($data); ``` - -C language interface --------------------- -See include/Rindow/OpenBLAS/Buffer.h in the source code. - -Include this header file and use Buffer in C language. - -The php object structure is as follows. -```c -typedef struct { - zend_long size; - zend_long dtype; - zend_long value_size; - void* data; - zend_object std; -} php_rindow_openblas_buffer_t; -``` - -Usage on C language -------------------- -The object passed in the PHP extension already has a memory area allocated for data. - -Determine the data type with dtype and cast the data pointer. - -The buffer size can be found in the size member - -Object type checking must be defined. -You cannot use the Buffer structure unless you check whether it is a Buffer type object. - -Use it as follows. -```c -#include -#include - -static PHP_METHOD(Sample, foo) -{ - php_rindow_openblas_buffer_t* buffer; - zend_long size; - zval* x=NULL; - float* data; - - ZEND_PARSE_PARAMETERS_START_EX(ZEND_PARSE_PARAMS_THROW, 1, 1) - Z_PARAM_OBJECT(x) - ZEND_PARSE_PARAMETERS_END(); - buffer = Z_RINDOW_OPENBLAS_BUFFER_OBJ_P(x); - - if(buffer->dtype!=php_rindow_openblas_dtype_float32) { - zend_throw_exception(spl_ce_RuntimeException, "Unsupported data type.", 0); - return; - } - size = buffer->size; - data = (float*)buffer->data; -} -ZEND_BEGIN_ARG_INFO_EX(ai_Sample_foo, 0, 0, 1) - ZEND_ARG_OBJ_INFO(0, x, Rindow\\OpenBLAS\\Buffer, 0) -ZEND_END_ARG_INFO() -``` diff --git a/_mathematics/openblas/blaslibrary.md b/_mathematics/openblas/blaslibrary.md index 8a5b1e8..c80bcf3 100644 --- a/_mathematics/openblas/blaslibrary.md +++ b/_mathematics/openblas/blaslibrary.md @@ -5,20 +5,20 @@ upper_section: index previous_section: openblas/arrayobjects next_section: openblas/mathlibrary --- -The Rindow\\OpenBLAS\\Blas class makes OpenBLAS available in php. +The Rindow\\OpenBLAS\\FFI\\Blas class makes OpenBLAS available in php. What is BLAS ------------ "BLAS" is the Basic Linear Algebra Subprograms library. -It is routines that provide standard building blocks for performing basic vector and matrix operations. -Because the BLAS are efficient, portable, and widely available, they are commonly used in the development of high quality linear algebra software. +This is a routine that provides standard building blocks for performing basic vector and matrix operations. +BLAS is often used to develop high-quality linear algebra software because it is efficient, portable, and widely available. -OpenBLAS is a representative library with a c language interface that implements BLAS. -See the [OpenBLAS website](https://www.openblas.net/) for details. +OpenBLAS is a typical library with a C language interface that implements BLAS. +For details, please see the [OpenBLAS website](https://www.openblas.net/). How it is implemented --------------------- -The BLAS library provides a very large number of functions, but this Linden OpenBLAS extension only provides very commonly used functions. +The BLAS library provides a very large number of functions, but this Rindow OpenBLAS FFI only provides very commonly used functions. The memory area is received via the Buffer object and passed to the OpenBLAS library. The distinction from the c-language interface of OpenBLAS is that it uses a buffer object and an offset to represent the start address of the memory area. This is to minimize the number of copies of the memory area when dealing with multidimensional arrays. @@ -28,9 +28,23 @@ Integers cannot be calculated. Currently the following functions are supported: +Implemented Methods +------------------- +Although the BLAS library provides a large number of functions, this Rindow OpenBLAS FFI leaves a few unimplemented functions. Starting from version 2.0, complex numbers are now supported. + +Memory space is received via a Buffer object and passed to the OpenBLAS library. +OpenBLAS differs from the C language interface in that it uses a buffer object and an offset to represent the starting address of memory space. This is to minimize the number of memory copies when working with multidimensional arrays. + +Most importantly, the OpenBLAS library only supports 32-bit and 64-bit floating point. +Integers cannot be calculated. + +Currently the following features are supported: + - scal - axpy - dot +- dotu +- dotc - asum - iamax - iamin @@ -46,6 +60,8 @@ Currently the following functions are supported: - syr2k - trmm - trsm +- omatcopy + Usage on PHP @@ -54,8 +70,10 @@ Here is the sample code. ```php use Interop\Polite\Math\Matrix\NDArray; -$x = new Rindow\OpenBLAS\Buffer(3,NDArray::float32); -$blas = new Rindow\OpenBLAS\Blas(); +$bufferFactory = new Rindow\Math\Buffer\FFI\BufferFactory() +$openblasFactory = new Rindow\OpenBLAS\FFI\OpenBLASFactory() +$x = $bufferFactory->Buffer(3,NDArray::float32); +$blas = $openblasFactory->Blas(); $x[0] = 1.0; $x[1] = 1.5; $x[2] = 2.0; diff --git a/_mathematics/openblas/mathlibrary.md b/_mathematics/openblas/mathlibrary.md index 98f27b1..edc3d4c 100644 --- a/_mathematics/openblas/mathlibrary.md +++ b/_mathematics/openblas/mathlibrary.md @@ -7,16 +7,15 @@ previous_section: openblas/blaslibrary Overview -------- -The "Math" library is a library of frequently used matrix operations. -When used in combination with BLAS, matrix operations can be completed in Buffer. -It is very important to minimize the number of data exchanges between PHP numeric variables and Buffers in order to process matrix operations at high speed. +The "Math" library is a library of frequently used matrix operations useful for machine learning. +When used in conjunction with BLAS, matrix operations can complete all operations within a buffer object. +To process matrix operations quickly, it is very important to minimize the number of data exchanges between PHP's numeric variables and buffers. +Implemented Methods +------------------- +Memory space is received via a Buffer object and passed to the Math library. -How it is implemented ---------------------- -The memory area is received via the Buffer object and passed to the Math library. - -Currently the following functions are supported: +Currently the following features are supported: - sum - imax @@ -26,7 +25,9 @@ Currently the following functions are supported: - maximum - minimum - greater +- greaterEqual - less +- lessEqual - multiply - add - duplicate @@ -37,27 +38,38 @@ Currently the following functions are supported: - exp - log - tanh +- sin +- con +- tan - zeros -- selectAxis0 -- selectAxis1 -- scatterAxis0 -- scatterAxis1 -- slice - updateAddOnehot - softmax - equal +- notEqual +- not - astype - matrixcopy +- imagecopy - fill +- nan2num +- isnan +- searchsorted +- cumsum +- transpose +- bandpart +- gather +- reduceGather +- slice +- repeat - reduceSum - reduceMax - reduceArgMax -- im2col1d -- im2col2d -- im2col3d - randomUniform - randomNormal - randomSequence +- im2col1d +- im2col2d +- im2col3d Usage on PHP @@ -66,8 +78,10 @@ Here is the sample code. ```php use Interop\Polite\Math\Matrix\NDArray; -$x = new Rindow\OpenBLAS\Buffer(3,NDArray::float32); -$math = new Rindow\OpenBLAS\Math(); +$bufferFactory = new Rindow\Math\Buffer\FFI\BufferFactory() +$matlibFactory = new Rindow\Matlib\FFI\MatlibFactory() +$x = $bufferFactory->Buffer(3,NDArray::float32); +$math = $matlibFactory->Math(); $x[0] = 1.0; $x[1] = 1.5; $x[2] = 2.0; diff --git a/_mathematics/openblas/overviewopenblas.md b/_mathematics/openblas/overviewopenblas.md index e3c14c3..e04ea6b 100644 --- a/_mathematics/openblas/overviewopenblas.md +++ b/_mathematics/openblas/overviewopenblas.md @@ -1,154 +1,113 @@ --- layout: document -title: "Rindow OpenBLAS extension" +title: "Rindow Matlib and OpenBLAS" upper_section: index next_section: openblas/arraybuffer --- Overview -------- -The Rindow OpenBLAS PHP extension is universal Buffer for N-dimension and OpenBLAS and Mathematical library. +Rindow-math-matrix can call external libraries written in C language etc. to speed up matrix operations. +You can call OpenBLAS, the most famous linear algebra library, and Rindow-Matlib, which is useful for machine learning. -- Provides Universal Buffer for 1-dimension for data exchange between C,C+ language and PHP. -- The OpenBLAS library available to PHP. Only the commonly used functions in OpenBLAS are provided. -- Provides commonly used Mathematical libraries not included in OpenBLAS. +From the latest version 2, we use PHP's FFI function to call the C language interface library. (Version 1 used PHP extensions) -You can do very fast N-dimensional array operations in conjunction with the [Rindow Math Matrix](/mathematics/matrix/matrix.html). +The following low-layer interfaces are mainly provided. -Very useful when you want to do deep learning with PHP! - -Requirements ------------- - -- PHP7.2 or PHP7.3 or PHP7.4 or PHP8.0 or PHP8.1 or PHP8.2 -- Linux or Windows 10,11 -- OpenBLAS library - -How to download and setup pre-build binaries --------------------------------------------- -You can download and use pre-built binaries for Windows and Ubuntu from each releases. -Download the binary for your version of PHP in "Asset" link. - -- https://github.com/rindow/rindow-openblas/releases - -For Windows, copy rindow_openblas.dll to your PHP extension directory and set extension=rindow_openblas in php.ini. - -If you are using Windows, you must download and setup OpenBLAS binary from OpenBLAS releases. -Please Download the version of OpenBLAS binaries that correspond to the rindow_openblas binaries. +- Provides a one-dimensional universal buffer for data exchange between C and PHP. +- You can use almost the same low-layer interface as the OpenBLAS library in PHP. This allows for flexible usage that does not depend on the array shape. +- Rindow-matlib can also be used in PHP with almost the same low-layer interface as C language. +- Can be combined with [Rindow Math Matrix](/mathematics/matrix/matrix.html) to perform very fast and advanced N-dimensional array operations. -- https://github.com/xianyi/OpenBLAS/releases - -> If you are using Windows, you must Download the version of OpenBLAS binaries that correspond to the -> rindow_openblas binaries. The compatible OpenBLAS Library release number is included in the filename -> of the rindow-openblas pre-built archive file. If you use the wrong OpenBLAS release number DLL, -> it will not work properly. - -Unzip it to a suitable location and set the execution path in the bin directory. - -```shell -TMP>copy rindow-openblas-phpX.X-X.X.X-openblasX.X.XX-win-ts-vXXX-x64\rindow_openblas.dll \path\to\php\ext -TMP>set PATH=%PATH%;\path\to\OpenBLAS\bin -``` - -For Ubuntu, use the apt command to install the deb file. - -```shell -$ sudo apt install ./rindow-openblas-phpX.X_X.X.X-X+ubuntuXX.XX_amd64.deb -``` +Very useful when you want to do deep learning with PHP! -How to build from source code on Windows ----------------------------------------------- -You can also build and use from source code. +requirements +------------ +- PHP8.1 or PHP8.2 or PHP8.3 +- Linux or Windows 10, 11 +- OpenBLAS library 0.3.20 or later +- Rindow-Math Library 1.0 or later -Download or Build OpenBLAS for MSVC on Windows ----------------------------------------------- -### Download binaries for the OpenBLAS libray -You need to build OpenBLAS libray for MSVC or download built binaries of libray for MSVC. -If you want to use the pre-built OpenBLAS libray, you need OpenBLAS release 0.3.10 or later. +Installation instructions from pre-build binaries +------------------------------------------------- -- https://github.com/xianyi/OpenBLAS/releases +### Download pre-build binaries from each projects -### Install VC15 or VC16 -Developing PHP extensions for php7.2,php7.3 and php7.4 requires VC15 instead of the latest VC. +You can perform very fast N-dimensional array operations in conjunction. +Download the pre-build binary files from each project's release page. -- Install Microsoft Visual Studio 2019 or later installer -- Run Installer with vs2017 build tools option. +- Pre-build binaries + - [Rindow Matlib](https://github.com/rindow/rindow-matlib/releases) + - [OpenBLAS](https://github.com/OpenMathLib/OpenBLAS/releases) -Developing PHP extensions from php8.0 requires VS16. You can use Visual Studio 2019. +### Setup for Windows -### Build OpenBLAS for pure MSVC from sources -If you want to build the OpenBLAS on MSVC with static library instead you use pre-build binary on our site, you can build it yourself. +Download the binary file, unzip it, and copy it to the execution directory. -https://github.com/xianyi/OpenBLAS/wiki/How-to-use-OpenBLAS-in-Microsoft-Visual-Studio -> 1. Native (MSVC) ABI -> Install Miniconda3 for 64 bits. And then follow the procedure described on the above page. +- rindow-matlib-X.X.X-win64.zip +- OpenBLAS-X.X.X-x64.zip -You want to build a DLL of OpenBLAS, you can run cmake with shared libray option -DBUILD_SHARED_LIBS=ON +Add FFI extension to php.ini ```shell -Anaconda3>vcvars64 -vcvars_ver=14.16 - -...... omission - -Anaconda3>cmake .. -G "Ninja" -DCMAKE_CXX_COMPILER=clang-cl -DCMAKE_C_COMPILER=clang-cl -DCMAKE_Fortran_COMPILER=flang -DBUILD_WITHOUT_LAPACK=no -DNOFORTRAN=0 -DDYNAMIC_ARCH=ON -DCMAKE_BUILD_TYPE=Release -Anaconda3>cmake --build . --config Release +C:\TMP> cd \path\to\php\directory +C:\PHP> notepad php.ini + +extension=ffi +C:\PHP> php -m + +C:\TMP> PATH %PATH%;\path\to\binary\directories\bin +C:\TMP> cd \your\progject\directory +C:\PRJ> composer require rindow/rindow-math-matrix +C:\PRJ> composer require rindow/rindow-math-matrix-matlibffi +C:\PRJ> vendor/bin/rindow-math-matrix +Service Level : Advanced +Buffer Factory : Rindow\Math\Buffer\FFI\BufferFactory +BLAS Driver : Rindow\OpenBLAS\FFI\Blas +LAPACK Driver : Rindow\OpenBLAS\FFI\Lapack +Math Driver : Rindow\Matlib\FFI\Matlib ``` -Build the extension for Windows -------------------------------- - -Please refer to the following URL for details. - -https://wiki.php.net/internals/windows/stepbystepbuild_sdk_2 - -### php sdk and devel-pack binaries for windows +### Setup for Ubuntu -- You must know that PHP 7.2,7.3 and 7.4 needs environment for the MSVC version vc15 (that means Visual Studio 2017). php-sdk releases 2.1.9 supports vc15. -- For PHP 7.x, Download the php-sdk from https://github.com/microsoft/php-sdk-binary-tools/releases/tag/php-sdk-2.1.9 -- If you want to build extensions for PHP 8.0, You have to use php-sdk release 2.2.0. It supports vs16. -- For PHP 8.0, Download the php-sdk from https://github.com/microsoft/php-sdk-binary-tools/releases/tag/php-sdk-2.2.0 -- Extract to c:\php-sdk -- Download target dev-pack from https://windows.php.net/downloads/releases/ -- Extract to /path/to/php-devel-pack-x.x.x-Win32-Vxxx-x64/ - -### start php-sdk for target PHP version - -Open Visual Studio Command Prompt for VS for the target PHP version(see stepbystepbuild.) -Note that you must explicitly specify the version of vc15 for which php.exe was built. -The -vcvars_ver=14.16 means vc15. - -If you want to build for PHP 8.0, No options required. +Install each library using the apt command. +Make sure FFI extension is enabled. ```shell -C:\visual\studio\path>vcvars64 -vcvars_ver=14.16 -or -C:\visual\studio\path>vcvars64 - -C:\tmp>cd c:\php-sdk-x.x.x - -C:\php-sdk-2.1.9>phpsdk-vc15-x64.bat -or -C:\php-sdk-2.2.0>phpsdk-vs16-x64.bat - +$ php -m | grep FFI +FFI ``` -### Build - +Install the fast matrix calculation library. +And then set the rindow-matlib to serial mode for use with PHP. ```shell -$ PATH %PATH%;/path/to/OpenBLAS/bin -$ cd /path/to/here -$ composer update -$ /path/to/php-devel-pack-x.x.x-Win32-VXXX-x64/phpize.bat -$ configure --enable-rindow_openblas --with-prefix=/path/to/php-installation-path --with-openblas=/path/to/OpenBLAS-libray-built-directory -$ nmake clean -$ nmake -$ nmake test +$ mkdir -p /your/project/directory +$ cd /your/project/directory +$ sudo apt install libopenblas-base libpapacke +$ wget https://github.com/rindow/rindow-matlib/releases/download/X.X.X/rindow-matlib_X.X.X_amd64.deb +$ sudo apt install ./rindow-matlib_X.X.X_amd64.deb +$ sudo update-alternatives --config librindowmatlib.so +There are 2 choices for the alternative librindowmatlib.so (providing /usr/lib/librindowmatlib.so). + + Selection Path Priority Status +------------------------------------------------------------ +* 0 /usr/lib/rindowmatlib-openmp/librindowmatlib.so 95 auto mode + 1 /usr/lib/rindowmatlib-openmp/librindowmatlib.so 95 manual mode + 2 /usr/lib/rindowmatlib-serial/librindowmatlib.so 90 manual mode + +Press to keep the current choice[*], or type selection number: 2 + +$ cd \your\progject\directory +$ composer require rindow/rindow-math-matrix +$ composer require rindow/rindow-math-matrix-matlibffi +$ vendor/bin/rindow-math-matrix +Service Level : Advanced +Buffer Factory : Rindow\Math\Buffer\FFI\BufferFactory +BLAS Driver : Rindow\OpenBLAS\FFI\Blas +LAPACK Driver : Rindow\OpenBLAS\FFI\Lapack +Math Driver : Rindow\Matlib\FFI\Matlib ``` -### Install from built directory - -- Copy the php extension binary(.dll) to the php/ext directory from here/arch/Releases_TS/php_rindow_openblas.dll -- Add the "extension=php_rindow_openblas" entry to php.ini diff --git a/_neuralnetworks/api/neuralnetworks.md b/_neuralnetworks/api/neuralnetworks.md index d144003..ff0e08b 100644 --- a/_neuralnetworks/api/neuralnetworks.md +++ b/_neuralnetworks/api/neuralnetworks.md @@ -126,7 +126,7 @@ If you want to use the original backend engine created by the developer, please ### OpenBLAS backend engine Calculation engine based on OpenBLAS and Rindow-OpenBLAS original functions. -If the rindow-openblas PHP extension is not installed, a compatible PHP implementation will automatically be used. A compatible PHP implementation is very slow but works without PHP extensions. +If the OpenBLAS is not installed, a compatible PHP implementation will automatically be used. A compatible PHP implementation is very slow but works without OpenBLAS. ### CLBlast backend engine @@ -135,11 +135,11 @@ CLBlast is an OpenCL BLAS compatible calculation engine. To run this engine you need: - OpenBLAS library -- Rindow-OpenBLAS PHP extension +- Rindow-OpenBLAS FFI - CLBlast library -- Rindow-clblast PHP extension +- Rindow-clblast FFI - OpenCL device driver -- Rindow - OpenCL PHP extension +- Rindow - OpenCL FFI You can specify options to identify OpenCL devices in environment variables. diff --git a/_neuralnetworks/index.md b/_neuralnetworks/index.md index 3d684b5..f9b49f6 100644 --- a/_neuralnetworks/index.md +++ b/_neuralnetworks/index.md @@ -23,7 +23,7 @@ next_section: gettingstarted Easy Acceleration

Easy Acceleration

-

PHP extensions that can be as fast as the CPU version of Tensorflow and GPU extensions that work on laptops without NVidia are available.

+

PHP FFI that can be as fast as the CPU version of Tensorflow and GPU acceleration that work on laptops without NVidia are available.

@@ -140,6 +140,7 @@ Recommends - Rindow Math Plot ( Display the result on a graph ) - GD / GD2 extension ( Used for graph display ) - pdo_sqlite extension ( Used to save the trained model ) +- FFI extension ( Used for high-speed calculation ) - OpenBLAS/Rindow-Matlib ( Used for high-speed calculation ) - OpenCL/CLBlast ( GPU Acceleration ) diff --git a/_neuralnetworks/install.md b/_neuralnetworks/install.md index 8368eec..7b28277 100644 --- a/_neuralnetworks/install.md +++ b/_neuralnetworks/install.md @@ -66,7 +66,7 @@ C:bin>echo @php "%~dp0composer.phar" %*>composer.bat Install the PHP extensions required by Rindow Neural Networks. -+ Download and unzip the corresponding pre-built binary file from https://github.com/xianyi/OpenBLAS/releases. ++ Download and unzip the corresponding pre-built binary file from https://github.com/OpenMathLib/OpenBLAS/releases. + Download and unzip the corresponding pre-built binary file from https://github.com/rindow/rindow-matlib/releases. + Set the OpenBLAS and Rindow-Matlib DLL paths to the execution path. + Make the necessary settings in php.ini. diff --git a/about.md b/about.md index 9ae483a..2f71f3b 100644 --- a/about.md +++ b/about.md @@ -23,8 +23,6 @@ Our Goal 2020 ©rindow™ -竜 - -胆 +竜胆 ( りんどう ) ![rindow flowers](/assets/img/rindow-flowers.jpg) diff --git a/index.html b/index.html index 768b5c1..3a68d0e 100644 --- a/index.html +++ b/index.html @@ -72,7 +72,7 @@

Neural Networks

Placeholder

Mathematics

-

Rindow math libraries efficiently supports matrix operations in PHP. Get even faster the processing speed with dedicated PHP extensions. The results can also be displayed in graphs in an easy-to-view format. Realistic data analysis can be performed without using Python or R.

+

Rindow math libraries efficiently supports matrix operations in PHP. Get even faster the processing speed with dedicated C libraries. The results can also be displayed in graphs in an easy-to-view format. Realistic data analysis can be performed without using Python or R.

View details »