Skip to content

Commit f9cdef3

Browse files
committed
First commit
1 parent 4104132 commit f9cdef3

27 files changed

+14113
-1
lines changed

.gitattributes

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
* text=auto
2+
/tests export-ignore
3+
/vendor export-ignore
4+
.gitattributes export-ignore
5+
.gitignore export-ignore
6+
.travis.yml export-ignore

.github/workflows/tests.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: tests
2+
3+
on: [push]
4+
5+
jobs:
6+
no_ext_tests:
7+
runs-on: ubuntu-22.04
8+
9+
strategy:
10+
fail-fast: true
11+
matrix:
12+
php: ['8.1','8.2','8.3']
13+
14+
steps:
15+
- name: Checkout codes
16+
uses: "actions/checkout@v4"
17+
18+
- name: Composer
19+
uses: php-actions/composer@v6
20+
with:
21+
php_version: ${{ matrix.php }}
22+
php_extensions: ffi
23+
24+
- name: PHPUnit Tests
25+
uses: php-actions/phpunit@v3
26+
with:
27+
configuration: tests/phpunit.xml
28+
version: 10.5
29+
php_version: ${{ matrix.php }}
30+
args: --filter ReleaseTest
31+

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
vendor/
2+
*.log
3+
composer.lock
4+
composer.phar
5+
tests/.phpunit.*
6+
build/

.vscode/settings.json

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"files.associations": {
3+
"array": "cpp",
4+
"atomic": "cpp",
5+
"bit": "cpp",
6+
"*.tcc": "cpp",
7+
"cctype": "cpp",
8+
"clocale": "cpp",
9+
"cmath": "cpp",
10+
"compare": "cpp",
11+
"complex": "cpp",
12+
"concepts": "cpp",
13+
"cstdarg": "cpp",
14+
"cstddef": "cpp",
15+
"cstdint": "cpp",
16+
"cstdio": "cpp",
17+
"cstdlib": "cpp",
18+
"cwchar": "cpp",
19+
"cwctype": "cpp",
20+
"deque": "cpp",
21+
"string": "cpp",
22+
"unordered_map": "cpp",
23+
"vector": "cpp",
24+
"exception": "cpp",
25+
"algorithm": "cpp",
26+
"functional": "cpp",
27+
"iterator": "cpp",
28+
"memory": "cpp",
29+
"memory_resource": "cpp",
30+
"numeric": "cpp",
31+
"random": "cpp",
32+
"string_view": "cpp",
33+
"system_error": "cpp",
34+
"tuple": "cpp",
35+
"type_traits": "cpp",
36+
"utility": "cpp",
37+
"initializer_list": "cpp",
38+
"iosfwd": "cpp",
39+
"istream": "cpp",
40+
"limits": "cpp",
41+
"new": "cpp",
42+
"numbers": "cpp",
43+
"ostream": "cpp",
44+
"sstream": "cpp",
45+
"stdexcept": "cpp",
46+
"streambuf": "cpp",
47+
"typeinfo": "cpp"
48+
}
49+
}

LICENSE

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2018, rindow
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted provided that the following conditions are met:
8+
9+
* Redistributions of source code must retain the above copyright notice, this
10+
list of conditions and the following disclaimer.
11+
12+
* Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
16+
* Neither the name of the copyright holder nor the names of its
17+
contributors may be used to endorse or promote products derived from
18+
this software without specific prior written permission.
19+
20+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,64 @@
1-
# rindow-clblast-ffi
1+
The CLBlast interface for FFI on PHP
2+
====================================
3+
Status:
4+
[![Build Status](https://github.com/rindow/rindow-clblast-ffi/workflows/tests/badge.svg)](https://github.com/rindow/rindow-clblast-ffi/actions)
5+
[![Downloads](https://img.shields.io/packagist/dt/rindow/rindow-clblast-ffi)](https://packagist.org/packages/rindow/rindow-clblast-ffi)
6+
[![Latest Stable Version](https://img.shields.io/packagist/v/rindow/rindow-clblast-ffi)](https://packagist.org/packages/rindow/rindow-clblast-ffi)
7+
[![License](https://img.shields.io/packagist/l/rindow/rindow-clblast-ffi)](https://packagist.org/packages/rindow/rindow-clblast-ffi)
8+
9+
"The CLBlast ffi" is a interface for the CLBlast library. Available in libraries with FFI interface.
10+
11+
Please see the documents about Buffer objects on [Rindow Mathematics](https://rindow.github.io/mathematics/acceleration/opencl.html#rindow-clblast-ffi) web pages.
12+
13+
Requirements
14+
============
15+
16+
- PHP 8.1 or PHP8.2 or PHP8.3
17+
- CLBlast 1.5.1 or later
18+
19+
How to setup OpenCL & CLBlast
20+
=============================
21+
You can download and setup pre-built CLBlast binaries.
22+
Please download the binaries for your platform.
23+
24+
- https://github.com/CNugteren/CLBlast/releases
25+
26+
27+
### Windows
28+
CLBlast and OpenBLAS DLL's path to Windows PATH environment variable.
29+
30+
```shell
31+
C:\tmp>PATH %PATH%;/path/to/OpenBLAS/bin;/path/to/CLBlast-Library/lib
32+
C:\tmp>cd /some/app/directory
33+
C:\app\dir>composer require rindow/rindow-clblast-ffi
34+
```
35+
36+
### Ubuntu
37+
On Linux, you first need to set up OpenCL.
38+
39+
For example, in the case of Ubuntu standard AMD driver, install as follows
40+
```shell
41+
$ sudo apt install clinfo
42+
$ sudo apt install mesa-opencl-icd
43+
$ sudo mkdir -p /usr/local/usr/lib
44+
$ sudo ln -s /usr/lib/clc /usr/local/usr/lib/clc
45+
```
46+
Ubuntu standard OpenCL drivers include:
47+
- mesa-opencl-icd
48+
- beignet-opencl-icd
49+
- intel-opencl-icd
50+
- nvidia-opencl-icd-xxx
51+
- pocl-opencl-icd
52+
53+
54+
Next, download and set up clbast.
55+
56+
Download and Extract Archive file and Pack to deb
57+
```shell
58+
$ cd /some/app/directory
59+
$ composer require rindow/rindow-clblast-ffi
60+
$ cp vendor/rindow/rindow-clblast-ffi/clblast-packdeb.sh .
61+
$ sh ./clblast-packdeb.sh
62+
$ sudo apt install ./clblast_X.X.X-X+ubuntuXX.XX_amd64.deb
63+
```
64+

clblast-packdeb.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/bash
2+
3+
CLBLASTVERSION=1.6.2
4+
5+
. /etc/os-release
6+
7+
FILENAME=CLBlast-${CLBLASTVERSION}-linux-x86_64
8+
PLATFORM=ubuntu${VERSION_ID}
9+
TARGET=./pkgwork
10+
11+
12+
wget https://github.com/CNugteren/CLBlast/releases/download/${CLBLASTVERSION}/${FILENAME}.zip
13+
14+
unzip ${FILENAME}.zip
15+
tar xvf ${FILENAME}.tar.gz
16+
#xz -dc ${FILENAME}.tar.xz | tar xvf -
17+
rm -rf ${TARGET}
18+
mkdir ${TARGET}
19+
mkdir ${TARGET}/DEBIAN
20+
mkdir ${TARGET}/usr
21+
mv ${FILENAME}/* ${TARGET}/usr
22+
23+
cat << EOS > ${TARGET}/DEBIAN/control
24+
Package: clblast
25+
Maintainer: CLBlast Developers <CNugteren@users.noreply.github.com>
26+
Architecture: amd64
27+
Depends: libc6 (>= 2.14), ocl-icd-libopencl1 | libopencl1, ocl-icd-libopencl1 (>= 1.0) | libopencl-1.1-1
28+
Version: ${CLBLASTVERSION}-1+${PLATFORM}
29+
Homepage: https://github.com/CNugteren/CLBlast/
30+
Description: The tuned OpenCL BLAS library
31+
CLBlast is a modern, lightweight, performant and tunable OpenCL BLAS library
32+
written in C++11. It is designed to leverage the full performance potential
33+
of a wide variety of OpenCL devices from different vendors, including desktop
34+
and laptop GPUs, embedded GPUs, and other accelerators.
35+
EOS
36+
mv ${TARGET}/usr/lib/pkgconfig/clblast.pc ./clblast.pc.orig
37+
cat ./clblast.pc.orig | sed -e s/^prefix=.*$/prefix=\\/usr/ > ${TARGET}/usr/lib/pkgconfig/clblast.pc
38+
rm ./clblast.pc.orig
39+
rm clblast_${CLBLASTVERSION}-1+${PLATFORM}_amd64.deb
40+
fakeroot dpkg-deb --build pkgwork .
41+
rm ${FILENAME}.zip
42+
rm ${FILENAME}.tar.gz
43+
rm -rf ${FILENAME}
44+
rm -rf ${TARGET}

composer.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "rindow/rindow-clblast-ffi",
3+
"type": "library",
4+
"description": "The CLBlast interface for FFI on PHP",
5+
"keywords": ["rindow","math","opencl","clblast","FFI"],
6+
"license": "BSD-3-Clause",
7+
"require": {
8+
"php": "^8.1",
9+
"interop-phpobjects/polite-math": "~1.0.6",
10+
"rindow/rindow-opencl-ffi": "~1.0.0"
11+
},
12+
"require-dev": {
13+
"ext-ffi": "*",
14+
"rindow/rindow-math-buffer-ffi": ">=1.0.0",
15+
"rindow/rindow-openblas-ffi": ">=1.0.0",
16+
"rindow/rindow-matlib-ffi": ">=1.0.0"
17+
},
18+
"autoload": {
19+
"psr-4": {
20+
"Rindow\\CLBlast\\FFI\\": "src/"
21+
}
22+
}
23+
}

platforms/ubuntu/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
cmake_minimum_required(VERSION 3.14)
2+
3+
#enable_testing()
4+
5+
project(rindow-clblast-ubuntu VERSION 1.0.0 LANGUAGES CXX C)
6+
#set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib)
7+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib)
8+
9+
file(GLOB_RECURSE srcfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ./*.cpp)
10+
add_library(rindowclblast SHARED ${srcfiles})
41.3 KB
Binary file not shown.

0 commit comments

Comments
 (0)