Skip to main content

Unifying Python/C++/CUDA memory: Python buffered array -> C++11 `std::vector` -> CUDA managed memory

Project description

Unifying Python/C++/CUDA memory: Python buffered array ↔ C++11 std::vector ↔ CUDA managed memory.

Version Downloads Py-Versions DOI Licence Tests Coverage

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 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.6 or greater (e.g. via Anaconda or Miniconda)

  • (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

pip install cuvec

Usage

See the usage documentation and quick examples of how to upgrade a Python ↔ C++ ↔ CUDA interface.

External Projects

For integration into Python, C++, CUDA, CMake, and general SWIG projects, see the external project documentation. Full and explicit example modules using the CPython API and SWIG are also provided.

Contributing

See CONTRIBUTING.md.

Licence

Licence DOI

Copyright 2021

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

cuvec-2.11.1.tar.gz (37.4 kB view details)

Uploaded Source

File details

Details for the file cuvec-2.11.1.tar.gz.

File metadata

  • Download URL: cuvec-2.11.1.tar.gz
  • Upload date:
  • Size: 37.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for cuvec-2.11.1.tar.gz
Algorithm Hash digest
SHA256 22154250e4cbc39d3fe5d5174ded7113a4a0482c49fb9536e096a429773ee11d
MD5 97a6d15e0e61aebfeb28514d2287a7f4
BLAKE2b-256 0f40bb0f9eddedb1267c8bd8af035c540b59b605b6b3ada78011acb858e6c735

See more details on using hashes here.

Supported by

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