/Fast

A library that is meant to be faster than Numpy for Linear Algebra Calculations

Primary LanguageJupyter Notebook

Fast

A library for Linear Algebra Calculations (In Progress). Fast allows users to perform linear algebra calculations in python faster than native python language or even Numpy since Fast uses PyBind11 to wrap C++ code into a python object. Furthermore, Fast utilises Eigen3 Library which specialises in linear algebra calculations and OpenMP to allow parallel matrix calculations to boost performance.

Version: 1.1

System Requirements:

  1. Python 3.x
  2. C++ 11.0
  3. OpenCL and Grpahics Drivers depending on the User's Graphics Card
  4. PyBind11
  5. Eigen3 Library
  6. OpenMP 4.5 and above
  7. CMake

Quick Installation

If all of the aforementioned systems requirements have been met, you can do a quick installation and use the Fast Library, else it is highly recommended that you follow the full installation guide before this step.

Steps to Take:

  1. Clone Fast repository to your preferred location.

  2. Clone PyBind11 into the Fast Folder as shown below: alt text

  3. Open Terminal and go to the Fast directory

user@user:~$ cd Desktop/Fast
user@user:~/Desktop/Fast$
  1. Install the Library!
(base) user@user:~/Desktop/Fast$ python setup.py [option]
  • For the option parameter it is advised to use develop if users wish to customise the functions available in the library. However users can also use install as a parameter.
  • If no Error messages are shown during the build and installation process,you are now able to use Fast! See the next section on how to use Fast.
  • However, if there are errors, it is highly recommended that you follow full installation guide as you may have missing dependencies.

Using Fast

Congratulations! You have finished the hardest part of using this library (installation), Fast allows the use of multi-core CPUs and GPUs to run matrix calculations.

Using the CPU version

The cpu class uses Eigen3 and OpenMP to run matrix calculations. Users just have to make a cpu object in python and run the function they desire.

  • An example of an element-wise matrix multiplication:
# Import Fast Library
import fast.fast as ft

# Create the cpu python object
cpu = ft.cpu()

# Create a vector of size 20
A = range(0,20)

# Run the Multiplication!
C = cpu.mul(A,A)

Viola! You are done with the multiplication.

  • Available functions:
  1. getmaxCore() : returns an integer value showing the number of cores are available in the user's CPU.
  2. mul(A,B) : Element-wise vector multiplication where A and B are 1-D Arrays with the same size and data-type. Returns a 1-D Array.

Using the GPU version:

The gpu class utilises the PC's Graphics Processing Unit (GPU) to run the calculations that can be parallelized using OpenCL. Its working is similar to the cpu class, whereby a gpu object needs to created before it can used. However it is also advisable to check the available GPUs on your PC before running.

  • An example of an element-wise matrix multiplication:
# Import Fast Library
import fast.fast as ft

# Create the cpu python object
gpu = ft.gpu()

# Check available GPU 
print(gpu.findGPU())

# Create a vector of size 20
A = range(0,20)

# Run the Multiplication!
C = gpu.mul(A,A)

Again You are Done!

  • WARNING: If the gpu.findGPU() functions does not print out any string related to your PC's GPUs, it is safe to assume that you have not installed your drivers for your native GPUs yet, as such please go through full installation guide.

  • Available functions:

  1. findGPU() : Provides a List of GPUs available in your PC and uses the first GPU on the list to perform the operations on.

  2. mul(A,B) : Element-wise vector multiplication where A and B are 1-D Arrays with the same size and data-type. Returns a 1-D Array.

Problems and Help

If you encounter any problems with the Fast Library, send an issue on the repository page along with the details of the error/problem and our support team will get back to you as early as possible! Enjoy!