Skip to main content

A CPU/GPU library for finding the minimum of a quartic function

Project description

CUDA-quartic-solver

GitHub Build Status PyPI

A general cubic equation solver and quartic equation minimisation solver written for CPU and Nvidia GPUs, for more details and results, see: https://arxiv.org/abs/1903.10041. The library is available for C++/CUDA as well as Python using Pybind11.

Running the solver

Requirements

  1. CUDA 9.0+ capable GPU and nvcc required to run the GPU solvers
  2. CMake 3.8+
  3. Python 3.6, numpy (if using Python)
  4. Pybind11 v2.5.0+ (installation instructions)

CMake

CMake can be used to build the project, for example:

git clone --recursive https://github.com/qureshizawar/CUDA-quartic-solver
mkdir build && cd build
cmake -D CMAKE_BUILD_TYPE=Release ../ -D CPP_exe=true -D GPU_build=false
make

When the CPP_exe flag is set to true, CMake will build a c++ executable, then quartic_solver_main can be executed to run the example code. When the GPU_build flag is set to true, CMake will build the CUDA capable version of the library.

Python

The Python package can be installed by building its .whl file, for example:

git clone --recursive https://github.com/qureshizawar/CUDA-quartic-solver
python setup.py bdist_wheel --GPU_build True

When the GPU_build flag is set to True, the CUDA capable version of the library will be built. The built .whl can then be used to install the package, for example:

pip install ./dist/QuarticSolver-0.1.1-cp36-cp36m-linux_x86_64.whl

Usage

Please see src/main.cu, src/cpu_main.cpp, and the examples in the /tests folder for detailed usage examples

C++

Given quartic functions of the form Ax^4 + Bx^3 + Cx^2 + Dx + E the minimiser for the quartic functions can calculated on the CPU by calling the following function from cpu_solver.cpp:

QuarticMinimumCPU(N, A, B, C, D, E, min);

Where:

  • N is the number of functions
  • A is an array containing the coefficient A for each of the quartic functions
  • B is an array containing the coefficient B for each of the quartic functions
  • C is an array containing the coefficient C for each of the quartic functions
  • D is an array containing the coefficient D for each of the quartic functions
  • E is an array containing the coefficient E for each of the quartic functions
  • min is an array which will contain the corresponding minimums for each of the quartic functions

The calculations can be carried out on a GPU by using QuarticMinimumGPU or QuarticMinimumGPUStreams. Please note signifcant performance improvement is observed when N>10000 for QuarticMinimumGPU vs QuarticMinimumGPUStreams

Python

The Python version of the library can be used as follows:

import numpy as np
import QuarticSolver

minimum = QuarticSolver.QuarticMinimum(A,B,C,D,E,True)

Where A,B,C,D,E are numpy arrays containing the quartic function coefficients and the final arg is a boolean flag which if set to True will use the GPU if possible. minimum is the returned numpy array containing the corresponding minimisers.

TODO

  1. Add multi-gpu support

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

QuarticSolver-0.1.5.tar.gz (616.8 kB view hashes)

Uploaded Source

Built Distributions

QuarticSolver-0.1.5-cp38-cp38-manylinux2010_x86_64.whl (115.7 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

QuarticSolver-0.1.5-cp38-cp38-manylinux2010_i686.whl (85.0 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.12+ i686

QuarticSolver-0.1.5-cp38-cp38-macosx_10_9_x86_64.whl (52.6 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

QuarticSolver-0.1.5-cp37-cp37m-manylinux2010_x86_64.whl (116.1 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.12+ x86-64

QuarticSolver-0.1.5-cp37-cp37m-manylinux2010_i686.whl (85.0 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.12+ i686

QuarticSolver-0.1.5-cp37-cp37m-macosx_10_9_x86_64.whl (51.9 kB view hashes)

Uploaded CPython 3.7m macOS 10.9+ x86-64

QuarticSolver-0.1.5-cp36-cp36m-win_amd64.whl (62.1 kB view hashes)

Uploaded CPython 3.6m Windows x86-64

QuarticSolver-0.1.5-cp36-cp36m-win32.whl (56.9 kB view hashes)

Uploaded CPython 3.6m Windows x86

QuarticSolver-0.1.5-cp36-cp36m-manylinux2010_x86_64.whl (115.9 kB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.12+ x86-64

QuarticSolver-0.1.5-cp36-cp36m-manylinux2010_i686.whl (85.2 kB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.12+ i686

QuarticSolver-0.1.5-cp36-cp36m-macosx_10_9_x86_64.whl (51.7 kB view hashes)

Uploaded CPython 3.6m macOS 10.9+ x86-64

QuarticSolver-0.1.5-cp35-cp35m-manylinux2010_x86_64.whl (115.9 kB view hashes)

Uploaded CPython 3.5m manylinux: glibc 2.12+ x86-64

QuarticSolver-0.1.5-cp35-cp35m-manylinux2010_i686.whl (85.3 kB view hashes)

Uploaded CPython 3.5m manylinux: glibc 2.12+ i686

QuarticSolver-0.1.5-cp35-cp35m-macosx_10_9_x86_64.whl (51.7 kB view hashes)

Uploaded CPython 3.5m macOS 10.9+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page