Skip to content

Commit 1b23381

Browse files
committed
Updating README with examples and sample output
1 parent 9883450 commit 1b23381

File tree

1 file changed

+137
-2
lines changed

1 file changed

+137
-2
lines changed

README.md

Lines changed: 137 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,137 @@
1-
# arrayfire_python
2-
Python bindings for ArrayFire
1+
# ArrayFire Python Bindings
2+
3+
[ArrayFire](https://github.com/arrayfire/arrayfire) is a high performance library for parallel computing wih an easy-to-use API. This project provides Python bindings for the ArrayFire library. It enables the users to write scientific computing code that is portable across CUDA, OpenCL and CPU devices.
4+
5+
## Example
6+
7+
```
8+
import arrayfire as af
9+
10+
# Display backend information
11+
af.info()
12+
13+
# Generate a uniform random array with a size of 5 elements
14+
a = af.randu(5, 1)
15+
16+
# Get the minimum value of a
17+
a_min = af.min(a)
18+
19+
# Print a and its minimum value
20+
af.print_array(a)
21+
af.print_array(a_min)
22+
```
23+
24+
## Sample outputs
25+
26+
On an AMD GPU:
27+
28+
```
29+
Using opencl backend
30+
ArrayFire v3.0.1 (OpenCL, 64-bit Linux, build 17db1c9)
31+
[0] AMD : Spectre
32+
-1- AMD : AMD A10-7850K Radeon R7, 12 Compute Cores 4C+8G
33+
34+
[5 1 1 1]
35+
0.4107
36+
0.8224
37+
0.9518
38+
0.1794
39+
0.4198
40+
41+
42+
Min value of a
43+
[1 1 1 1]
44+
0.1794
45+
```
46+
47+
On an NVIDIA GPU:
48+
49+
```
50+
Using cuda backend
51+
ArrayFire v3.0.0 (CUDA, 64-bit Linux, build 86426db)
52+
Platform: CUDA Toolkit 7, Driver: 346.46
53+
[0] Tesla K40c, 12288 MB, CUDA Compute 3.5
54+
-1- GeForce GTX 750, 1024 MB, CUDA Compute 5.0
55+
56+
Generate a random matrix a:
57+
[5 1 1 1]
58+
0.7402
59+
0.9210
60+
0.0390
61+
0.9690
62+
0.9251
63+
64+
65+
Min value of a
66+
[1 1 1 1]
67+
0.0390
68+
69+
Max value of a
70+
[1 1 1 1]
71+
0.9690
72+
```
73+
74+
Fallback to CPU when CUDA and OpenCL are not availabe:
75+
76+
```
77+
Using cpu backend
78+
ArrayFire v3.0.0 (CPU, 64-bit Linux, build 86426db)
79+
80+
Generate a random matrix a:
81+
[5 1 1 1]
82+
0.0000
83+
0.1315
84+
0.7556
85+
0.4587
86+
0.5328
87+
88+
89+
Min value of a
90+
[1 1 1 1]
91+
0.0000
92+
93+
Max value of a
94+
[1 1 1 1]
95+
```
96+
97+
The backend selection is automated currently. Choosing a particular backend will be made available in the future.
98+
99+
## Requirements
100+
101+
Currently, this project is tested only on Linux and OSX. You also need to have the ArrayFire C/C++ library installed on your machine. You can get it from the following sources.
102+
103+
- [Download and install binaries](https://arrayfire.com/download)
104+
- [Build and install from source](https://github.com/arrayfire/arrayfire)
105+
106+
Please check the following links for dependencies.
107+
108+
- [Linux dependencies](http://www.arrayfire.com/docs/using_on_linux.htm)
109+
- [OSX dependencies](http://www.arrayfire.com/docs/using_on_osx.htm)
110+
111+
## Getting started
112+
113+
If you have not installed the ArrayFire library in your system paths, please make sure the following environment variables are exported.
114+
115+
**On Linux**
116+
117+
```
118+
export LD_LIBRARY_PATH=/path/to/arrayfire/lib:$LD_LIBRARY_PATH
119+
```
120+
121+
**On OSX**
122+
123+
```
124+
export DYLD_LIBRARY_PATH=/path/to/arrayfire/lib:$DYLD_LIBRARY_PATH
125+
```
126+
127+
On both systems, to run the example, you will need to add the python bindings to your `PYTHONPATH`
128+
129+
```
130+
export PYTHONPATH=/path/to/arrayfire_python/:$PYTHONPATH
131+
```
132+
133+
You are now good to go!
134+
135+
## Note
136+
137+
This is a work in progress and is not intended for production use.

0 commit comments

Comments
 (0)