CUDA-quartic-solver
所属分类:GPU/显卡
开发工具:Cuda
文件大小:25KB
下载次数:0
上传日期:2020-06-15 10:11:21
上 传 者:
sh-1993
说明: 为CPU和Nvidia GPU编写的通用三次方程求解器和四次方程最小化求解器,用于了解更多细节...
(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.)
文件列表:
.travis.yml (3013, 2020-06-15)
CMakeLists.txt (4171, 2020-06-15)
LICENSE (1070, 2020-06-15)
MANIFEST.in (47, 2020-06-15)
pybind11 (0, 2020-06-15)
pyproject.toml (239, 2020-06-15)
setup.cfg (40, 2020-06-15)
setup.py (4151, 2020-06-15)
src (0, 2020-06-15)
src\cpu_main.cpp (2451, 2020-06-15)
src\cpu_main_py.cpp (5054, 2020-06-15)
src\cpu_solver.cpp (9277, 2020-06-15)
src\cpu_solver.h (924, 2020-06-15)
src\gpu_solver.cu (21945, 2020-06-15)
src\gpu_solver.cuh (1225, 2020-06-15)
src\main.cu (4857, 2020-06-15)
src\main_py.cu (8238, 2020-06-15)
src\utils.cpp (609, 2020-06-15)
src\utils.h (267, 2020-06-15)
tests (0, 2020-06-15)
tests\tests.py (2598, 2020-06-15)
tests\testsCPU.cpp (1147, 2020-06-15)
tests\testsGPU.cu (0, 2020-06-15)
# CUDA-quartic-solver
![GitHub](https://img.shields.io/github/license/qureshizawar/CUDA-quartic-solver)
[![Build Status](https://travis-ci.org/qureshizawar/CUDA-quartic-solver.svg?branch=master)](https://travis-ci.org/qureshizawar/CUDA-quartic-solver)
[![PyPI](https://img.shields.io/pypi/v/QuarticSolver)](https://pypi.org/project/QuarticSolver/)
[![Downloads](https://pepy.tech/badge/quarticsolver)](https://pepy.tech/project/quarticsolver)
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](https://stackoverflow.com/a/56552686))
### 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 via PyPI:
```
pip install QuarticSolver
```
Or 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_***.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
近期下载者:
相关文件:
收藏者: