A Pytnon library containing basic algorithm with GPU-accelerated computing.
Project description
CuAlgo
CuAlgo is a Python library benefiting from GPU-accelerated computing, featuring a collection of fundamental algorithms implemented with CUDA. Currently, it includes the Floyd-Warshall algorithm for graph analysis, showcasing the potential of GPU acceleration.
Key Features
Graph Algorithms:
- Floyd-Warshall algorithm
Why CuAlgo?
- Significant Speedup: Experience substantial performance gains with CuAlgo's GPU-accelerated algorithms compared to their CPU approaches.
- User-Friendly Python Interface: CuAlgo provides convenient interface for Python users. It is compatible with NumPy, allowing for easy data interchange with existing scientific computing workflows. Ensuring that python developers can leverage GPU acceleration without delving into CUDA programming details.
- Cross-Platform Compatibility: Developed with CMake, CuAlgo supports cross-platform development, enabling seamless compilation on various operating systems.
Performance Evaluation
Explore different implementations of the Floyd-Warshall algorithm using datasets of sizes N=40, N=1000, and N=2000. This section presents a comprehensive analysis of the efficiency improvements achieved through GPU acceleration.
Methodology
- CPU Version: The algorithm is executed on the CPU without GPU acceleration.
- CPU (12 threads) Version: Runs on the CPU with 12 threads using OpenMP.
- GPU (Unoptimized) Version: Initial GPU implementation with similar parallelism as the next GPU (Optimized) Version.
- GPU (Optimized) Version: GPU implementation with optimizations, including loop/block unrolling, dynamic parallelism, and coalesced memory access, fully leveraging GPU resources efficiently.
The charts illustrate the speedup achieved by CuAlgo's GPU-accelerated algorithms over CPU-based implementations. Notably, the optimized GPU version outperforms both the unoptimized GPU and CPU versions when N grows large, emphasizing the impact of optimization on algorithm efficiency.
Hardware and Software Information:
CPU | AMD Ryzen 9 5900X 12-Core Processor |
GPU | NVIDIA GeForce RTX 3060 Ti - 8GB |
RAM | 32GB DDR4 3600 Mhz |
CUDA Toolkit Version | 12.2 |
GPU Driver Version | 537.13 |
Prerequisites
(For linux, need GCC compiler with C++ support (gcc works better with CUDA's compiler), and GNU make)
- Latest NVIDIA GPU driver
- Python 3.7+ with pip available
- Latest CUDA toolkit installed with nvcc compiler. (download here)
NOTE: [Recommended] You can skip 2 and 3. by using conda, see Installation below
Installation
Linux / Windows [Recommended]:
conda install cuda -c nvidia
python -m pip install --upgrade pip
pip install cualgo
Windows (without conda):
- Install NVIDIA latest GPU driver by yourself
python -m pip install --upgrade pip && pip install cualgo
Sample Code
Support data type of Numpy
.
from cualgo import graph as cg
import numpy as np
graph = np.array([
[0 , 7 , np.inf, 8],
[np.inf, 0 , 5 , np.inf],
[np.inf, np.inf, 0 , 2],
[np.inf, np.inf, np.inf, 0]
], dtype=np.float64)
print(cg.floydwarshall(graph))
# [[0.0, 7.0, 12.0, 8.0], [inf, 0.0, 5.0, 7.0], [inf, inf, 0.0, 2.0], [inf, inf, inf, 0.0]]
Or just simply pass 2D list
in python
from cualgo import graph as cg
INF = 9999
graph = [
[0 , 7 , INF, 8],
[INF, 0 , 5 , INF],
[INF, INF, 0 , 2],
[INF, INF, INF, 0]
]
print(cg.floydwarshall(graph))
# [[0, 7, 12, 8], [9999, 0, 5, 7], [9999, 9999, 0, 2], [9999, 9999, 9999, 0]]
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
Built Distributions
File details
Details for the file cualgo-0.2.0.tar.gz
.
File metadata
- Download URL: cualgo-0.2.0.tar.gz
- Upload date:
- Size: 2.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dc00f6742907433f0d6b97cbb891a68141422fbe2c64ff6c874ce444a196fb32 |
|
MD5 | 284599056840f1c86cd4f6437a61cda1 |
|
BLAKE2b-256 | dce8d977970fa1ebc7a0e3b1e592edb45ec5554aae791ff4fe88ec9f814de8fb |
File details
Details for the file cualgo-0.2.0-cp312-cp312-win_amd64.whl
.
File metadata
- Download URL: cualgo-0.2.0-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 1.4 MB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9214e95a73b777157c7ecbb271703b62172dda61e07f5f6c170da869fe7d52f1 |
|
MD5 | 93f2336acbf954529dd613cfb30fced6 |
|
BLAKE2b-256 | 457229e0fa5ca4f8c78a5127c3d4bda26c773e3ef7a5e87b5d68395bed9722a2 |
File details
Details for the file cualgo-0.2.0-cp311-cp311-win_amd64.whl
.
File metadata
- Download URL: cualgo-0.2.0-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 1.4 MB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2ed89f1e58bf1a0b83dc27e86eec3c8f6ac584bbcfd226a49cdc8fcbc6957e0 |
|
MD5 | 71b21568fe236e6077d3547f33213061 |
|
BLAKE2b-256 | 60021c390c567b2e98d379dfeabce9de1ecb3a0e3bc4fb3ec94df387c9754a66 |
File details
Details for the file cualgo-0.2.0-cp310-cp310-win_amd64.whl
.
File metadata
- Download URL: cualgo-0.2.0-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 1.4 MB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa53e41aa19fd3bef0defcd6413ad1b28ce4984541ad7e20353eabceb51c7c2c |
|
MD5 | b57446bb2ce5eb9ab99e4b80557d3150 |
|
BLAKE2b-256 | c42fd3b25ae9b8d0a14c149224b5b06af5399b5940d6eac0ebc8605b15efa635 |
File details
Details for the file cualgo-0.2.0-cp39-cp39-win_amd64.whl
.
File metadata
- Download URL: cualgo-0.2.0-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 1.4 MB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f9274cbb798d41912b4cd7277bd4ef8cef17a72ccc202910b07df6b4934db573 |
|
MD5 | 693aa95f7c4d8f35503c4b62b023469d |
|
BLAKE2b-256 | c3ed578a02f424bdd0c8c6bfb239f385bb99276d70021b79a4ba795aadd9db12 |
File details
Details for the file cualgo-0.2.0-cp38-cp38-win_amd64.whl
.
File metadata
- Download URL: cualgo-0.2.0-cp38-cp38-win_amd64.whl
- Upload date:
- Size: 1.4 MB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc2827c79099af0627d455bc5017f5969994aba9448ffdb1a3d4ee335a5aaa84 |
|
MD5 | d22049a1a332b8736381b4a5acf2b4e2 |
|
BLAKE2b-256 | a7cbbfdf18d268906492b4e926e01b3704375b62e5b1c7f227673141c68f8b73 |
File details
Details for the file cualgo-0.2.0-cp37-cp37m-win_amd64.whl
.
File metadata
- Download URL: cualgo-0.2.0-cp37-cp37m-win_amd64.whl
- Upload date:
- Size: 1.4 MB
- Tags: CPython 3.7m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a21e51013b34d2900c47b716295cf71d040fef255c501adfbfbaac521842f2c |
|
MD5 | 9c979fc8d68c0bf145f860ac5a56d705 |
|
BLAKE2b-256 | 0e4f7b46a385e8eee40c7944cdd56c671c20b12bc205b313caccf693b29bdacd |