Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/amypad/cuvec
Unifying Python/C++/CUDA memory: Python buffered array ↔️ `std::vector` ↔️ CUDA managed memory
https://github.com/amypad/cuvec
array buffer c cpp cpu cpython cpython-api cpython-extensions cuda cxx gpu hacktoberfest pybind11 python swig vector
Last synced: 1 day ago
JSON representation
Unifying Python/C++/CUDA memory: Python buffered array ↔️ `std::vector` ↔️ CUDA managed memory
- Host: GitHub
- URL: https://github.com/amypad/cuvec
- Owner: AMYPAD
- License: other
- Created: 2021-01-16T21:16:49.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-11-18T16:25:44.000Z (about 1 month ago)
- Last Synced: 2024-12-21T07:07:31.951Z (1 day ago)
- Topics: array, buffer, c, cpp, cpu, cpython, cpython-api, cpython-extensions, cuda, cxx, gpu, hacktoberfest, pybind11, python, swig, vector
- Language: Python
- Homepage: https://amypad.github.io/CuVec/
- Size: 716 KB
- Stars: 81
- Watchers: 4
- Forks: 3
- Open Issues: 7
-
Metadata Files:
- Readme: README.rst
- Contributing: CONTRIBUTING.md
- Citation: CITATION.cff
Awesome Lists containing this project
README
CuVec
=====Unifying Python/C++/CUDA memory: Python buffered array ↔ C++11 ``std::vector`` ↔ CUDA managed memory.
|Version| |Downloads| |Py-Versions| |DOI| |Licence| |Tests| |Coverage|
.. contents:: Table of contents
:backlinks: top
:local:Why
~~~Data should be manipulated using the existing functionality and design paradigms of each programming language. Python code should be Pythonic. CUDA code should be... CUDActic? C code should be... er, Clean.
However, in practice converting between data formats across languages can be a pain.
Other libraries which expose functionality to convert/pass data formats between these different language spaces tend to be bloated, unnecessarily complex, and relatively unmaintainable. By comparison, ``cuvec`` uses the latest functionality of Python, C/C++11, and CUDA to keep its code (and yours) as succinct as possible. "Native" containers are exposed so your code follows the conventions of your language. Want something which works like a ``numpy.ndarray``? Not a problem. Want to convert it to a ``std::vector``? Or perhaps a raw ``float *`` to use in a CUDA kernel? Trivial.
- Less boilerplate code (fewer bugs, easier debugging, and faster prototyping)
- Fewer memory copies (faster execution)
- Lower memory usage (do more with less hardware)Non objectives
--------------Anything to do with mathematical functionality. The aim is to expose functionality, not (re)create it.
Even something as simple as setting element values is left to the user and/or pre-existing features - for example:
- Python: ``arr[:] = value``
- NumPy: ``arr.fill(value)``
- CuPy: ``cupy.asarray(arr).fill(value)``
- C++: ``std::fill(vec.begin(), vec.end(), value)``
- C & CUDA: ``memset(vec.data(), value, sizeof(T) * vec.size())``Install
~~~~~~~Requirements:
- Python 3.7 or greater (e.g. via `Anaconda or Miniconda `_, or via ``python3-dev``)
- (optional) `CUDA SDK/Toolkit `_ (including drivers for an NVIDIA GPU)* note that if the CUDA SDK/Toolkit is installed *after* CuVec, then CuVec must be re-installed to enable CUDA support
.. code:: sh
pip install cuvec
Usage
~~~~~See `the usage documentation `_ and `quick examples `_ of how to upgrade a Python ↔ C++ ↔ CUDA interface.
See also `NumCu `_, a minimal stand-alone Python package built using CuVec.
External Projects
~~~~~~~~~~~~~~~~~For integration into Python, C++, CUDA, CMake, pybind11, and general SWIG projects, see `the external project documentation `_.
Full and explicit example modules using the `CPython API `_, `pybind11 API `_, and `SWIG `_ are also provided.Contributing
~~~~~~~~~~~~See `CONTRIBUTING.md `_.
Licence
~~~~~~~|Licence| |DOI|
Copyright:
- `Casper O. da Costa-Luis `_
- `Contributors `_.. |DOI| image:: https://zenodo.org/badge/DOI/10.5281/zenodo.4446211.svg
:target: https://doi.org/10.5281/zenodo.4446211
.. |Licence| image:: https://img.shields.io/pypi/l/cuvec.svg?label=licence
:target: https://github.com/AMYPAD/CuVec/blob/main/LICENCE
.. |Tests| image:: https://img.shields.io/github/actions/workflow/status/AMYPAD/CuVec/test.yml?branch=main&logo=GitHub
:target: https://github.com/AMYPAD/CuVec/actions
.. |Downloads| image:: https://img.shields.io/pypi/dm/cuvec?logo=pypi&logoColor=white
:target: https://pypi.org/project/cuvec
.. |Coverage| image:: https://codecov.io/gh/AMYPAD/CuVec/branch/main/graph/badge.svg
:target: https://codecov.io/gh/AMYPAD/CuVec
.. |Version| image:: https://img.shields.io/pypi/v/cuvec.svg?logo=python&logoColor=white
:target: https://github.com/AMYPAD/CuVec/releases
.. |Py-Versions| image:: https://img.shields.io/pypi/pyversions/cuvec.svg?logo=python&logoColor=white
:target: https://pypi.org/project/cuvec