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. This project provides Python bindings for the ArrayFire library.
Documentation for this project can be found over here.
# Monte Carlo estimation of pidefcalc_pi_device(samples): # Simple, array based API# Generate uniformly distributed random numersx=af.randu(samples) y=af.randu(samples) # Supports Just In Time Compilation# The following line generates a single kernelwithin_unit_circle= (x*x+y*y) <1# Intuitive function namesreturn4*af.count(within_unit_circle) /samplesChoosing a particular backend can be done using af.set_backend(name) where name is either "cuda", "opencl", or "cpu". The default device is chosen in the same order of preference.
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.
Please check the following links for dependencies.
Install the last stable version:
pip install arrayfireInstall the development version:
pip install git+git://github.com/arrayfire/arrayfire-python.git@develInstalling offline:
cd path/to/arrayfire-python python setup.py installPost Installation:
Please follow these instructions to ensure the arrayfire-python can find the arrayfire libraries.
To run arrayfire smoke tests, you can run the following command from command line.
python setup.py testThe ArrayFire library is written by developers at ArrayFire LLC with contributions from several individuals.
The developers at ArrayFire LLC have received partial financial support from several grants and institutions. Those that wish to receive public acknowledgement are listed below:
This material is based upon work supported by the DARPA SBIR Program Office under Contract Numbers W31P4Q-14-C-0012 and W31P4Q-15-C-0008. Any opinions, findings and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the DARPA SBIR Program Office.