rindow/rindow-matlib-ffi 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

rindow/rindow-matlib-ffi

Composer 安装命令:

composer require rindow/rindow-matlib-ffi

包简介

The math matrix library for FFI on PHP

README 文档

README

Status: Build Status Downloads Latest Stable Version License

"The interface of rindow matlib on ffi".

Please see the documents about rindow mathematics on Rindow Mathematics web pages.

You can call a high-speed calculation library written in C language to speed up matrix calculation processing. Rindow Matlib includes many matrix operations functions used in machine learning.

Requirements

  • PHP 8.1 or PHP8.2 or PHP8.3 or PHP8.4
  • Rindow Matlib C Library 1.1 or later
  • Windows 10/11, Linux, macOS

How to setup

How to setup for Windows

Download the pre-build binary file.

Unzip the file for Windows and copy rindowmatlib.dll to the directory set in PATH.

The standard DLLs in the Bin directory is the thread version. Subdirectories contain OpenMP and Serial versions.

C> copy rindowmatlib.dll C:\php
C> PATH %PATH%;C:\php

Set it up using composer.

C> mkdir \your\app\dir
C> cd \your\app\dir
C> composer require rindow/rindow-matlib-ffi

How to setup for Linux

Download the pre-build binary file.

Please install using the apt command.

$ sudo apt install ./rindow-matlib_X.X.X_amd64.deb

Set it up using composer.

$ mkdir \your\app\dir
$ cd \your\app\dir
$ composer require rindow/rindow-matlib-ffi

How to setup for macOS

Download the pre-build binary file.

Extract the tar.gz file to the tmp directory and navigate to the directory.

$ tar -xzf rindow-matlib-X.X.X-Darwin-XXX.tar.gz -C /tmp
$ cd /tmp/rindow-matlib-X.X.X-Darwin-XXX

The standard dylib in the Lib directory is the thread version. Subdirectories contain OpenMP and Serial versions.

Next, copy the include and lib directories to /usr/local.

$ sudo cp -r usr/include /usr/local/
$ sudo cp -r usr/lib /usr/local/

If you want to use OpenMP mode please type brew install libomp

Set it up using composer.

$ mkdir \your\app\dir
$ cd \your\app\dir
$ composer require rindow/rindow-matlib-ffi

Troubleshooting for Linux

Since rindow-matlib currently uses ptheads, so you should choose the pthread version for OpenBLAS as well. In version 1.0 of Rindow-matlib we recommended the OpenMP version, but now we have changed our policy and are recommending the pthread version.

Using the OpenMP version of OpenBLAS can cause conflicts and become unstable and slow. This issue does not occur on Windows.

If you have already installed the OpenMP version of OpenBLAS, you can delete it and install pthread version.

$ sudo apt install libopenblas0-pthread liblapacke
$ sudo apt remove libopenblas0-openmp

But if you can't remove it, you can switch to it using the update-alternatives command.

$ sudo update-alternatives --config libopenblas.so.0-x86_64-linux-gnu
$ sudo update-alternatives --config liblapack.so.3-x86_64-linux-gnu

If you really want to use the OpenMP version of OpenBLAS, please switch to the OpenMP version of rindow-matlib.

$ sudo update-alternatives --config librindowmatlib.so
There are 1 choices for the alternative librindowmatlib.so (providing /usr/lib/librindowmatlib.so).

  Selection    Path                                             Priority   Status
------------------------------------------------------------
* 0            /usr/lib/rindowmatlib-thread/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
  3            /usr/lib/rindowmatlib-thread/librindowmatlib.so   100       manual mode

Press <enter> to keep the current choice[*], or type selection number: 1

Choose the "rindowmatlib-openmp".

How to use

$ composer require rindow/rindow-matlib-ffi
$ composer require rindow/rindow-math-buffer-ffi
<?php
include __DIR__.'/vendor/autoload.php';

use Interop\Polite\Math\Matrix\NDArray;
use Rindow\Matlib\FFI\MatlibFactory;
use Rindow\Math\Buffer\FFI\BufferFactory;

$factory = new MatlibFactory();
$math = $factory->Math();
$hostBufferFactory = new BufferFactory();
$NWITEMS = 64;

$x = $hostBufferFactory->Buffer(
    $NWITEMS,NDArray::float32
);

for($i=0;$i<$NWITEMS;$i++) {
    $x[$i] = $i;
}
$n = count($x);
$offsetX = 0;
$incX = 1;

$sum = $math->sum($n,$x,$offsetX,$incX);

var_dump($sum);

rindow/rindow-matlib-ffi 适用场景与选型建议

rindow/rindow-matlib-ffi 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 260.08k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 03 月 18 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「math」 「matrix」 「ffi」 「rindow」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 rindow/rindow-matlib-ffi 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 rindow/rindow-matlib-ffi 我们能提供哪些服务?
定制开发 / 二次开发

基于 rindow/rindow-matlib-ffi 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 260.08k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 29
  • 依赖项目数: 4
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2024-03-18