{"id":18509163,"url":"https://github.com/rindow/rindow-math-matrix-matlibffi","last_synced_at":"2025-05-14T10:16:50.857Z","repository":{"id":228715614,"uuid":"774737159","full_name":"rindow/rindow-math-matrix-matlibffi","owner":"rindow","description":"Rindow Math Matrix's Drivers for Matlib with PHP FFI","archived":false,"fork":false,"pushed_at":"2024-04-29T06:49:58.000Z","size":16,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-26T00:18:46.706Z","etag":null,"topics":["acceleration","array","gpu","hpc","machine-learning","mathematics","n-dimensional","openblas","opencl","php","php8","scientific-computing"],"latest_commit_sha":null,"homepage":"https://rindow.github.io/mathematics/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rindow.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-20T04:51:29.000Z","updated_at":"2024-10-01T18:15:03.000Z","dependencies_parsed_at":"2024-04-29T07:57:06.292Z","dependency_job_id":null,"html_url":"https://github.com/rindow/rindow-math-matrix-matlibffi","commit_stats":null,"previous_names":["rindow/rindow-math-matrix-matlibffi"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rindow%2Frindow-math-matrix-matlibffi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rindow%2Frindow-math-matrix-matlibffi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rindow%2Frindow-math-matrix-matlibffi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rindow%2Frindow-math-matrix-matlibffi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rindow","download_url":"https://codeload.github.com/rindow/rindow-math-matrix-matlibffi/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239222022,"owners_count":19602544,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["acceleration","array","gpu","hpc","machine-learning","mathematics","n-dimensional","openblas","opencl","php","php8","scientific-computing"],"created_at":"2024-11-06T15:16:39.342Z","updated_at":"2025-05-14T10:16:50.844Z","avatar_url":"https://github.com/rindow.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Rindow Math Matrix's Drivers for Matlib with PHP FFI\n====================================================\n\nStatus:\n[![Build Status](https://github.com/rindow/rindow-math-matrix-matlibffi/workflows/tests/badge.svg)](https://github.com/rindow/rindow-math-matrix-matlibffi/actions)\n[![Downloads](https://img.shields.io/packagist/dt/rindow/rindow-math-matrix-matlibffi)](https://packagist.org/packages/rindow/rindow-math-matrix-matlibffi)\n[![Latest Stable Version](https://img.shields.io/packagist/v/rindow/rindow-math-matrix-matlibffi)](https://packagist.org/packages/rindow/rindow-math-matrix-matlibffi)\n[![License](https://img.shields.io/packagist/l/rindow/rindow-math-matrix-matlibffi)](https://packagist.org/packages/rindow/rindow-math-matrix-matlibffi)\n\nThis package is matlib drivers for Rindow-math-matrix. These drivers act as adapters to drive PHP FFI. Each PHP C Libraries requires a separate download and installation of a binary file appropriate for your environment's PHP version and OS version.\n\nRindow Math Matrix is the fundamental package for scientific matrix operation\n\n- A powerful N-dimensional array object\n- Sophisticated (broadcasting) functions\n- Tools for integrating C/C++ through the FFI\n- Useful linear algebra and random number capabilities\n\nPlease see the documents on [Rindow mathematics projects](https://rindow.github.io/mathematics/) web pages.\n\nRindow Math Matrix's repository is [here](https://github.com/rindow/rindow-math-matrix/).\n\nRequirements\n============\n\n- PHP 8.1 or PHP8.2 or PHP8.3 or PHP8.4\n- Rindow Math Matrix v2.0 or later\n- Rindow Matlib 1.0.0 or later\n- OpenBLAS 0.3.20 or later(Linux/Windows), vecLib(macOS)\n- OpenCL 1.1 or later\n- CLBlast 1.5.2 or later\n\n### Download pre-build binaries from each projects\n\nYou can perform very fast N-dimensional array operations in conjunction.\nDownload the pre-build binary files from each project's release page.\n\n- Pre-build binaries\n  - [Rindow Matlib](https://github.com/rindow/rindow-matlib/releases)\n  - [OpenBLAS](https://github.com/OpenMathLib/OpenBLAS/releases)\n  - [CLBlast](https://github.com/CNugteren/CLBlast/releases)\n\nSetup for Windows\n=================\n\nDownload the binary file, unzip it, and copy it to the execution directory.\n\n- rindow-matlib-X.X.X-win64.zip\n- OpenBLAS-X.X.X-x64.zip\n- CLBlast-X.X.X-windows-x64.zip\n\n\nAdd FFI extension to php.ini\n\n```shell\nC:\\TMP\u003e cd \\path\\to\\php\\directory\nC:\\PHP\u003e notepad php.ini\n\nextension=ffi\n```\n\n```shell\nC:\\TMP\u003e PATH %PATH%;\\path\\to\\binary\\directories\\bin\nC:\\TMP\u003e cd \\your\\progject\\directory\nC:\\PRJ\u003e composer require rindow/rindow-math-matrix\nC:\\PRJ\u003e composer require rindow/rindow-math-matrix-matlibffi\nC:\\PRJ\u003e vendor/bin/rindow-math-matrix\nService Level   : Accelerated\nBuffer Factory  : Rindow\\Math\\Buffer\\FFI\\BufferFactory\nBLAS Driver     : Rindow\\OpenBLAS\\FFI\\Blas(THREAD)\nLAPACK Driver   : Rindow\\OpenBLAS\\FFI\\Lapack\nMath Driver     : Rindow\\Matlib\\FFI\\Matlib(THREAD)\nOpenCL Factory  : Rindow\\OpenCL\\FFI\\OpenCLFactory\nCLBlast Factory : Rindow\\CLBlast\\FFI\\CLBlastFactory\n```\n\nThe OpenCL 1.2 environment is already set up if you are using the Windows standard driver.\n\nIf you add the -v option as shown below, the driver loading status at boot time will be displayed.\nIt will help with troubleshooting.\n\n```shell\nC:\\PRJ\u003e vendor/bin/rindow-math-matrix -v\n```\n\n\nSetup for Linux\n===============\n\nInstall each library using the apt command.\n\nMake sure FFI extension is enabled.\n```shell\n$ php -m | grep FFI\nFFI\n```\n\nDownload the pre-build binary file.\n\n- https://github.com/rindow/rindow-matlib/releases\n\nPlease install using the apt command. \n```shell\n$ sudo apt install ./rindow-matlib_X.X.X_amd64.deb\n```\n\nSince rindow-matlib currently uses ptheads, so you should choose the pthread version for OpenBLAS as well.\nIn version 1.0 of Rindow-matlib we recommended the OpenMP version, but now we have changed our policy and are recommending the pthread version.\nThis issue does not occur on Windows.\n\n```shell\n$ sudo apt install libopenblas0 liblapacke\n```\n\nIf you want to use GPU, install the OpenCL environment.\nIn addition, there are the following drivers.\n\n- mesa-opencl-icd\n- beignet-opencl-icd\n- intel-opencl-icd\n- nvidia-opencl-icd-xxx\n- pocl-opencl-icd\n\n```shell\n$ sudo apt install clinfo\n$ sudo apt install mesa-opencl-icd\n$ sudo mkdir -p /usr/local/usr/lib\n$ sudo ln -s /usr/lib/clc /usr/local/usr/lib/clc\n```\n\nAnd then, Install the fast matrix calculation library for OpenCL.\nIf you use Ubuntu22.04 or Debian 12 or later, You can install it from distribution packages.\n```shell\n$ sudo apt install libclblast1\n```\n\nIf You use Ubuntu20.04 or Debian 11, You need to download clblast from Github and make deb file. \nPlease download the CLBlast installation script from the rindow-clblast-ffi release page.\n```shell\n$ wget https://github.com/rindow/rindow-clblast-ffi/releases/download/X.X.X/clblast-packdeb.zip\n$ unzip clblast-packdeb.zip\n$ sh clblast-packdeb.sh\n$ sudo apt install ./clblast_X.X.X_amd64.deb\n```\n\u003e *CAUTION*: However, The rindow-matlib v1.1 do not support Ubuntu 20.04/Debian 11. If you want to use Ubuntu 20.04, please build it from source code or use rindow-matlib v1.0.\n\n\nAnd then, Install the rindow-math-matrix on your project directory.\n```shell\n$ composer require rindow/rindow-math-matrix\n$ composer require rindow/rindow-math-matrix-matlibffi\n$ vendor/bin/rindow-math-matrix\nService Level   : Accelerated\nBuffer Factory  : Rindow\\Math\\Buffer\\FFI\\BufferFactory\nBLAS Driver     : Rindow\\OpenBLAS\\FFI\\Blas(THREAD)\nLAPACK Driver   : Rindow\\OpenBLAS\\FFI\\Lapack\nMath Driver     : Rindow\\Matlib\\FFI\\Matlib(THREAD)\nOpenCL Factory  : Rindow\\OpenCL\\FFI\\OpenCLFactory\nCLBlast Factory : Rindow\\CLBlast\\FFI\\CLBlastFactory\n```\n\nIf you add the -v option as shown below, the driver loading status at boot time will be displayed.\nIt will help with troubleshooting.\n\n```shell\n$ vendor/bin/rindow-math-matrix -v\n```\n\nSetup for macOS\n===============\n\nInstall each library using the apt command.\n\nMake sure FFI extension is enabled.\n```shell\n$ php -m | grep FFI\nFFI\n```\n\nDownload the pre-build binary file.\n\n- https://github.com/rindow/rindow-matlib/releases\n\nPlease install using the apt command. \n```shell\n$ curl https://github.com/rindow/rindow-matlib/releases/download/X.X.X/rindow-matlib-X.X.X-Darwin-XXXX.tar.gz -O -L\n$ tar -xzf rindow-matlib-XXX-Darwin-XXX.tar.gz\n$ sudo cp -r usr/include /usr/local/\n$ sudo cp -r usr/lib /usr/local/\n```\n\nIf you want to use OpenMP mode instead of native thread mode, instantiate OpenMP. In most cases OpenMP mode is not needed.\n```shell\n$ brew install libomp\n```\n\n\nAnd then, Install the rindow-math-matrix on your project directory.\n```shell\n$ composer require rindow/rindow-math-matrix\n$ composer require rindow/rindow-math-matrix-matlibffi\n$ vendor/bin/rindow-math-matrix\nService Level   : Advanced\nBuffer Factory  : Rindow\\Math\\Buffer\\FFI\\BufferFactory\nBLAS Driver     : Rindow\\OpenBLAS\\FFI\\Blas(THREAD)\nLAPACK Driver   : Rindow\\OpenBLAS\\FFI\\Lapack\nMath Driver     : Rindow\\Matlib\\FFI\\Matlib(THREAD)\n```\n\nOpenCL is not supported on macOS.\n\n\n### Check driver status\n\nYou can check the driver settings by running the sample below.\n```php\n\u003c?php\n// status.php\ninclude_once __DIR__.'/vendor/autoload.php';\nuse Rindow\\Math\\Matrix\\MatrixOperator;\n\n$mo = new MatrixOperator();\n\necho $mo-\u003eservice()-\u003einfo();\n```\n\n```shell\n$ php status.php\nService Level   : Accelerated\nBuffer Factory  : Rindow\\Math\\Buffer\\FFI\\BufferFactory\nBLAS Driver     : Rindow\\OpenBLAS\\FFI\\Blas(THREAD)\nLAPACK Driver   : Rindow\\OpenBLAS\\FFI\\Lapack\nMath Driver     : Rindow\\Matlib\\FFI\\Matlib(THREAD)\nOpenCL Factory  : Rindow\\OpenCL\\FFI\\OpenCLFactory\nCLBlast Factory : Rindow\\CLBlast\\FFI\\CLBlastFactory\n```\n\n### Troubleshooting for Linux\nSince rindow-matlib currently uses ptheads, so you should choose the pthread version for OpenBLAS as well.\nIn version 1.0 of Rindow-matlib we recommended the OpenMP version, but now we have changed our policy and are recommending the pthread version.\n\nUsing the OpenMP version of OpenBLAS can cause conflicts and become unstable and slow.\nThis issue does not occur on Windows.\n\nIf you have already installed the OpenMP version of OpenBLAS, you can delete it and install pthread version.\n```shell\n$ sudo apt install libopenblas0-pthread liblapacke\n$ sudo apt remove libopenblas0-openmp\n```\n\nBut if you can't remove it, you can switch to it using the update-alternatives command.\n\n```shell\n$ sudo update-alternatives --config libopenblas.so.0-x86_64-linux-gnu\n$ sudo update-alternatives --config liblapack.so.3-x86_64-linux-gnu\n```\n\nIf you really want to use the OpenMP version of OpenBLAS, please switch to the OpenMP version of rindow-matlib.\n\n```shell\n$ sudo update-alternatives --config librindowmatlib.so\nThere are 1 choices for the alternative librindowmatlib.so (providing /usr/lib/librindowmatlib.so).\n\n  Selection    Path                                             Priority   Status\n------------------------------------------------------------\n* 0            /usr/lib/rindowmatlib-thread/librindowmatlib.so   95        auto mode\n  1            /usr/lib/rindowmatlib-openmp/librindowmatlib.so   95        manual mode\n  2            /usr/lib/rindowmatlib-serial/librindowmatlib.so   90        manual mode\n  3            /usr/lib/rindowmatlib-thread/librindowmatlib.so   100       manual mode\n\nPress \u003center\u003e to keep the current choice[*], or type selection number: 1\n```\nChoose the \"rindowmatlib-openmp\".\n\n\nAcceleration with GPU\n=====================\n\nYou can use GPU acceleration on OpenCL.\n\n*Note:*\n\nThis OpenCL support extension works better in your environment and helps speed up your laptop environment without n-NVIDIA.\n\nTested on Coffee Lake iGPU.\n\nIn the Windows environment, Integrated GPU usage was more effective than CPU, and it worked comfortably.\n\nHowever, OLD AMD APU on Linux, libclc used in linux standard mesa-opencl-icd is very buggy and slow.\nIf you have testable hardware, please test using the proprietary driver.\n\nIt now works comfortably with various adjustments on Windows Standard OpenCL Driver. However, the old Intel Integrated GPU is not very high compared to its CPU performance, so please use the right person in the right place.\n\nAnd it worked fine and fast in Ubuntu 24.04 + intel-opencl-icd environment.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frindow%2Frindow-math-matrix-matlibffi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frindow%2Frindow-math-matrix-matlibffi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frindow%2Frindow-math-matrix-matlibffi/lists"}