Skip to content

Commit

Permalink
logging boot
Browse files Browse the repository at this point in the history
  • Loading branch information
yuichiis committed Apr 29, 2024
1 parent 58ab6cd commit 2f5ea66
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
- name: Checkout math-matrix tests
run: |
( cd .. && git clone https://github.com/rindow/rindow-math-matrix )
( cd ../rindow-math-matrix && git checkout 2.0.3 )
( cd ../rindow-math-matrix && git checkout 2.0.4 )
#- name: Composer
# uses: php-actions/composer@v6
Expand Down
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ CLBlast Factory : Rindow\CLBlast\FFI\CLBlastFactory

The OpenCL 1.2 environment is already set up if you are using the Windows standard driver.

If you add the -v option as shown below, the driver loading status at boot time will be displayed.
It will help with troubleshooting.

```shell
C:\PRJ> vendor/bin/rindow-math-matrix -v
```


Setup for Linux
===============
Expand Down Expand Up @@ -104,7 +111,7 @@ Using the pthread version of OpenBLAS can cause conflicts and become unstable an
This issue does not occur on Windows.

```shell
$ sudo apt install libopenblas0-openmp
$ sudo apt install libopenblas0-openmp liblapacke
```

If you want to use GPU, install the OpenCL environment.
Expand Down Expand Up @@ -152,6 +159,13 @@ OpenCL Factory : Rindow\OpenCL\FFI\OpenCLFactory
CLBlast Factory : Rindow\CLBlast\FFI\CLBlastFactory
```

If you add the -v option as shown below, the driver loading status at boot time will be displayed.
It will help with troubleshooting.

```shell
$ vendor/bin/rindow-math-matrix -v
```

### Check driver status

You can check the driver settings by running the sample below.
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"php": "^8.1",
"ext-ffi": "*",
"interop-phpobjects/polite-math": "~1.0.7",
"rindow/rindow-math-matrix": "~2.0.3",
"rindow/rindow-math-matrix": "~2.0.4",
"rindow/rindow-math-buffer-ffi": "~1.0.2",
"rindow/rindow-openblas-ffi": "~1.0.3",
"rindow/rindow-matlib-ffi": "~1.0.1",
Expand Down
74 changes: 39 additions & 35 deletions src/MatlibFFI.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,47 +13,51 @@ class MatlibFFI extends AbstractMatlibService
{
protected string $name = 'matlib_ffi';

public function __construct(
object $bufferFactory=null,
object $mathFactory=null,
object $openblasFactory=null,
object $openclFactory=null,
object $clblastFactory=null,
object $blasCLFactory=null,
object $mathCLFactory=null,
object $bufferCLFactory=null,
)
protected function injectDefaultFactories() : void
{
if($bufferFactory===null && class_exists(BufferFactory::class)) {
$bufferFactory = new BufferFactory();
if($this->bufferFactory===null) {
if(class_exists(BufferFactory::class)) {
$this->bufferFactory = new BufferFactory();
} else {
$this->logging(0,BufferFactory::class.' ** not found.');
}
}
if($openblasFactory===null && class_exists(OpenBLASFactory::class)) {
$openblasFactory = new OpenBLASFactory();
if($this->openblasFactory===null) {
if(class_exists(OpenBLASFactory::class)) {
$this->openblasFactory = new OpenBLASFactory();
} else {
$this->logging(0,OpenBLASFactory::class.' ** not found **.');
}
}
if($mathFactory===null && class_exists(MatlibFactory::class)) {
$mathFactory = new MatlibFactory();
if($this->mathFactory===null) {
if(class_exists(MatlibFactory::class)) {
$this->mathFactory = new MatlibFactory();
} else {
$this->logging(0,MatlibFactory::class.' ** not found **.');
}
}
if($openclFactory===null && class_exists(OpenCLFactory::class)) {
$openclFactory = new OpenCLFactory();
if($this->openclFactory===null) {
if(class_exists(OpenCLFactory::class)) {
$this->openclFactory = new OpenCLFactory();
} else {
$this->logging(0,OpenCLFactory::class.' ** not found **.');
}
}
$bufferCLFactory = $bufferCLFactory ?? $openclFactory;
if($clblastFactory===null && class_exists(CLBlastFactory::class)) {
$clblastFactory = new CLBlastFactory();
$this->bufferCLFactory ??= $this->openclFactory;
if($this->clblastFactory===null) {
if(class_exists(CLBlastFactory::class)) {
$this->clblastFactory = new CLBlastFactory();
} else {
$this->logging(0,CLBlastFactory::class.' ** not found **.');
}
}
$blasCLFactory = $blasCLFactory ?? $clblastFactory;
if($mathCLFactory===null && class_exists(MatlibCLFactory::class)) {
$mathCLFactory = new MatlibCLFactory();
$this->blasCLFactory ??= $this->clblastFactory;
if($this->mathCLFactory===null) {
if(class_exists(MatlibCLFactory::class)) {
$this->mathCLFactory = new MatlibCLFactory();
} else {
$this->logging(0,MatlibCLFactory::class.' ** not found **.');
}
}

parent::__construct(
bufferFactory:$bufferFactory,
openblasFactory:$openblasFactory,
mathFactory:$mathFactory,
openclFactory:$openclFactory,
clblastFactory:$clblastFactory,
blasCLFactory:$blasCLFactory,
mathCLFactory:$mathCLFactory,
bufferCLFactory:$bufferCLFactory,
);
}
}

0 comments on commit 2f5ea66

Please sign in to comment.