Skip to content

Commit 8292b65

Browse files
committed
Update README.md
1 parent a0d2dbb commit 8292b65

File tree

1 file changed

+41
-36
lines changed

1 file changed

+41
-36
lines changed

README.md

Lines changed: 41 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,74 @@
1-
# arrayfire-python (WIP)
1+
# arrayfire-py
22
<p align="center"><a href="http://arrayfire.com/"><img src="http://arrayfire.com/logos/arrayfire_logo_whitebkgnd.png" width="800"></a></p>
33

4-
[ArrayFire](https://github.com/arrayfire/arrayfire) is a high performance library for parallel computing with an easy-to-use API. It enables users to write scientific computing code that is portable across CUDA, OpenCL and CPU devices.
4+
[ArrayFire](https://github.com/arrayfire/arrayfire) is a high performance library for parallel computing with an easy-to-use API. It enables users to write scientific computing code that is portable across CUDA, OpenCL, oneAPI and CPU devices.
55

6-
This project is a **work in progress**. It is meant to provide a numpy-like Python interface for the ArrayFire C library, i.e, it provides array functionality, math operations, printing, etc. This is the front-end python library for using ArrayFire. It is currently supported on Python 3.10+.
6+
This project is meant is meant to provide an easy to use Python interface for the ArrayFire C library, i.e, it provides array functionality, math operations, printing, etc. This is the front-end python library for using ArrayFire. It is currently supported on Python 3.10+.
77

88
Here is an example of the library at work:
99
```py
10-
# Set backend and device (optional: 'cuda', 'opencl', 'oneapi', 'cpu')
10+
import arrayfire as af
11+
12+
# Set any backend and device (optional: 'cuda', 'opencl', 'oneapi', 'cpu')
1113
af.setBackend(af.BackendType.cuda)
1214
af.setDevice(0)
1315

14-
# Create two 5x5 arrays on the GPU
15-
a = af.randu((5, 5))
16-
b = af.randu((5, 5))
17-
18-
# Perform element-wise addition and matrix multiplication
19-
c = a + b
20-
d = af.matmul(a, b)
21-
22-
# Print the result
23-
print(c, "Element-wise Sum")
24-
print(d, "Matrix Product")
16+
# Monte Carlo estimation of pi
17+
def calc_pi_device(samples):
18+
# Simple, array based API
19+
# Generate uniformly distributed random numers
20+
x = af.randu(samples)
21+
y = af.randu(samples)
22+
# Supports Just In Time Compilation
23+
# The following line generates a single kernel
24+
within_unit_circle = (x * x + y * y) < 1
25+
# Intuitive function names
26+
return 4 * af.count(within_unit_circle) / samples
2527
```
28+
Find out more in our [examples](https://github.com/arrayfire/arrayfire-py/tree/master/examples) directory or just read the [documentation](https://arrayfire.org/arrayfire-python).
2629

27-
# Installing
30+
# Prequisites and Installing
2831

29-
**Requirement Details**
30-
This project is separated into 3 different parts:
32+
This project provides the python interface to ArrayFire, however it requires access to the ArrayFire binaries as a prequisite. The dependency chain can be separated into 3 different parts as follows:
3133
```
3234
arrayfire-py -> arrayfire-binary-python-wrapper -> ArrayFire C Libraries
3335
```
34-
This means that arrayfire with python each of these parts is needed:
35-
- [`arrayfire-py`](https://github.com/arrayfire/arrayfire-python) is the intended User Interface that provides a numpy-like layer to execute math and array operations with ArrayFire. *** This is the preferred Interface ***
36-
- [`arrayfire-binary-python-wrapper`](https://github.com/arrayfire/arrayfire-binary-python-wrapper) is the wrapper that provides Python direct access to the ArrayFire functions in the C library. This package must have access to ArrayFire binaries.
37-
- [`ArrayFire C Libraries`](https://github.com/arrayfire/arrayfire) are the binaries obtained from compiling the [ArrayFire C/C++ Project](https://github.com/arrayfire/arrayfire). You obtain these easily through [installers in the ArrayFire download page](https://arrayfire.com/download/).
36+
To run arrayfire with python each of these parts is needed:
37+
- [`arrayfire-py`](https://github.com/arrayfire/arrayfire-python) is the ***intended User Interface*** that provides a numpy-like layer to execute math and array operations with ArrayFire.
38+
- [`arrayfire-binary-python-wrapper`](https://github.com/arrayfire/arrayfire-binary-python-wrapper) is a thin wrapper that provides Python direct access to the ArrayFire functions in the C library. This package must have access to ArrayFire binaries, either through a system-wide install, or through a pre-bundled wheel that includes binaries.
39+
- [`ArrayFire C Libraries`](https://github.com/arrayfire/arrayfire) are the binaries obtained from compiling the [ArrayFire C/C++ Project](https://github.com/arrayfire/arrayfire) or more simply by downloading [installers in the ArrayFire download page](https://arrayfire.com/download/). Binaries can also be obtained as part of a pre-packaged arrayfire-binary-python-wrapper wheel.
3840

39-
**Install the last stable version of python wrapper:**
41+
**Install the python wrapper with existing ArrayFire install:**
4042
```sh
41-
pip install arrayfire_binary_python_wrapper-0.8.0+af3.10.0-py3-none-linux_x86_64.whl # install required binary wrapper with the 3.10 ArrayFire binaries included
43+
# install required binary wrapper, assumes ArrayFire binaries will be installed on the system
44+
pip install arrayfire_binary_python_wrapper
4245
pip install arrayfire-py # install arrayfire python interface library
4346
```
4447

45-
**Install a pre-built wheel:**
48+
**Install wrapper with a pre-built wheel:**
49+
```sh
50+
# will grab a binary wrapper with included pre-built binaries
51+
pip install arrayfire-binary-python-wrapper -f https://repo.arrayfire.com/python/wheels/3.10.0/
52+
pip install arrayfire-py
4653
```
47-
pip install arrayfire-py -f https://repo.arrayfire.com/python/wheels/arrayfire-python/0.1.0
54+
# Running Tests
55+
56+
Tests are located in folder [tests](tests).
57+
58+
To run the tests, use:
59+
```bash
60+
python -m pytest tests/
4861
```
4962

5063
# Building
51-
Building this interface is straight forward using [scikit-build-core](https://github.com/scikit-build/scikit-build-core):
5264
```
5365
python -m pip install -r dev-requirements.txt
5466
python -m build --wheel
5567
```
56-
5768
**Note: Building this project does not require the arrayfire-binary-python-wrapper package; however, the binary wrapper is needed to run any projects with it**
5869

59-
# Running Tests
60-
61-
Tests are located in folder [tests](tests).
62-
63-
To run the tests, use:
64-
```bash
65-
python -m pytest tests/
66-
```
70+
## Experimental Array API support
71+
This wrapper is exploring an experimental implementation of the [DataAPIs](https://data-apis.org) [array API](https://data-apis.org/array-api/latest) standard [in this directory](https://github.com/arrayfire/arrayfire-py/tree/master/arrayfire/array_api) with the goal of allowing ArrayFire to seamlessly interoperate with the broader Python landscape. Some portions of the standard are still unimplemented however some simpler examples are working.
6772

6873
# Contributing
6974

0 commit comments

Comments
 (0)