Skip to content

Commit

Permalink
bump version, merge pull request #13 from AMYPAD/devel
Browse files Browse the repository at this point in the history
  • Loading branch information
casperdcl authored Jul 21, 2021
2 parents 1f5bc2d + be9c993 commit 429ebfa
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 43 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/comment-bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
post({
owner: context.repo.owner, repo: context.repo.repo,
comment_id: context.payload.comment.id, content: "eyes"})
github-token: ${{ secrets.GH_TOKEN }}
- name: Tag Commit
run: |
git clone https://${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY} repo
Expand All @@ -48,3 +49,4 @@ jobs:
post({
owner: context.repo.owner, repo: context.repo.repo,
comment_id: context.payload.comment.id, content: "rocket"})
github-token: ${{ secrets.GH_TOKEN }}
28 changes: 11 additions & 17 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,25 +89,19 @@ jobs:
requirements: twine setuptools wheel setuptools_scm[toml] scikit-build
build: sdist
password: ${{ secrets.PYPI_TOKEN }}
upload: ${{ github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') }}
- name: Changelog
run: git log --pretty='format:%d%n- %s%n%b---' $(git tag --sort=v:refname | tail -n2 | head -n1)..HEAD > _CHANGES.md
- if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
id: create_release
uses: actions/create-release@v1
upload: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }}
- id: meta
name: Changelog
run: |
echo ::set-output name=tag::${GITHUB_REF#refs/tags/}
git log --pretty='format:%d%n- %s%n%b---' $(git tag --sort=v:refname | tail -n2 | head -n1)..HEAD > _CHANGES.md
- if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: CuVec ${{ github.ref }} beta
name: CuVec ${{ steps.meta.outputs.tag }} stable
body_path: _CHANGES.md
draft: true
- if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: dist/${{ steps.dist.outputs.targz }}
asset_name: ${{ steps.dist.outputs.targz }}
asset_content_type: application/gzip
files: |
dist/${{ steps.dist.outputs.targz }}
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ MANIFEST
/_skbuild/
/_cmake_test_compile/
/*.egg*/
/.eggs/

/.coverage*
/coverage.xml
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ default_language_version:
python: python3
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
rev: v4.0.1
hooks:
- id: check-added-large-files
- id: check-case-conflict
Expand All @@ -26,7 +26,7 @@ repos:
exclude: ^(.pre-commit-config.yaml|.github/workflows/test.yml)$
args: [-i]
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.4
rev: 3.9.2
hooks:
- id: flake8
additional_dependencies:
Expand All @@ -35,16 +35,16 @@ repos:
- flake8-debugger
- flake8-string-format
- repo: https://github.com/google/yapf
rev: 6db9374
rev: v0.31.0
hooks:
- id: yapf
args: [-i]
- repo: https://github.com/PyCQA/isort
rev: 5.7.0
rev: 5.9.2
hooks:
- id: isort
- repo: https://github.com/doublify/pre-commit-clang-format
rev: master
rev: '6230247'
hooks:
- id: clang-format
files: \.(cc?|cuh?|cxx|cpp|h|hpp|hxx|java|js)$
Expand Down
17 changes: 8 additions & 9 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Even something as simple as setting element values is left to the user and/or pr
- 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())``
- C & CUDA: ``memset(vec.data(), value, sizeof(T) * vec.size())``

Install
~~~~~~~
Expand All @@ -54,7 +54,7 @@ Creating
.. code:: python
import cuvec
# from cuvec import swigcuvec as cuvec # SWIG alternative
# from cuvec import swigcuvec as cuvec # SWIG alternative
arr = cuvec.zeros((1337, 42), "float32") # like `numpy.ndarray`
# print(sum(arr))
# some_numpy_func(arr)
Expand Down Expand Up @@ -125,7 +125,7 @@ The following involve no memory copies.
CuVec<float> &vec = ((PyCuVec<float> *)obj)->vec; // like std::vector<float>
std::vector<Py_ssize_t> &shape = ((PyCuVec<float> *)obj)->shape;
**C++** to **C/CUDA**
**C++** to **C & CUDA**

.. code:: cpp
Expand All @@ -139,7 +139,7 @@ The following involve no memory copies.
# import cuvec, my_custom_lib
# arr = cuvec.swigcuvec.zeros((1337, 42), "float32")
my_custom_lib.some_swig_api_unc(arr.cuvec)
my_custom_lib.some_swig_api_func(arr.cuvec)
**SWIG API** to **Python**

Expand All @@ -153,7 +153,7 @@ The following involve no memory copies.
.. code:: cpp
/// input: `SwigCuVec<type> *swv`
/// output: `CuVec<type> vec`, `std::vector<size_> shape`
/// output: `CuVec<type> vec`, `std::vector<size_t> shape`
CuVec<float> &vec = swv->vec; // like std::vector<float>
std::vector<size_t> &shape = swv->shape;
Expand All @@ -164,13 +164,12 @@ Python Projects
---------------

Python objects (``arr``, returned by ``cuvec.zeros()``, ``cuvec.asarray()``, or ``cuvec.copy()``) contain all the attributes of a ``numpy.ndarray``.
Additionally, ``arr.cuvec`` implements the `buffer protocol <https://docs.python.org/3/c-api/buffer.html>`_, while
``arr.__cuda_array_interface__`` provides `compatibility with other libraries <https://numba.readthedocs.io/en/latest/cuda/cuda_array_interface.html>`_ such as Numba, CuPy, PyTorch, PyArrow, and RAPIDS.
Additionally, ``arr.cuvec`` implements the `buffer protocol <https://docs.python.org/3/c-api/buffer.html>`_, while ``arr.__cuda_array_interface__`` provides `compatibility with other libraries <https://numba.readthedocs.io/en/latest/cuda/cuda_array_interface.html>`_ such as Numba, CuPy, PyTorch, PyArrow, and RAPIDS.

When using the SWIG alternative module, ``arr.cuvec`` is a wrapper around ``SwigCuVec<type> *``.

C++/CUDA Projects
-----------------
C++ & CUDA Projects
-------------------

``cuvec`` is a header-only library so simply ``#include "pycuvec.cuh"``
(or ``#include "cuvec.cuh"``). You can find the location of the headers using:
Expand Down
21 changes: 11 additions & 10 deletions cuvec/include/cuvec.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,24 @@ template <class T> struct CuAlloc {
#if __cplusplus > 201703L
[[nodiscard]]
#endif
T *
T
*
allocate(std::size_t n) {
if (n > std::numeric_limits<std::size_t>::max() / sizeof(T)) throw std::bad_alloc();
if (n > std::numeric_limits<std::size_t>::max() / sizeof(T)) throw std::bad_alloc();

T *p;
T *p;
#ifndef CUVEC_DISABLE_CUDA
cuvec::HandleError(cudaMallocManaged((void **)&p, n * sizeof(T)), __FILE__, __LINE__);
cuvec::HandleError(cudaMallocManaged((void **)&p, n * sizeof(T)), __FILE__, __LINE__);
#else
p = (T *)std::malloc(n * sizeof(T));
#endif
if (p) {
report(p, n);
return p;
}
if (p) {
report(p, n);
return p;
}

throw std::bad_alloc();
}
throw std::bad_alloc();
}

void deallocate(T *p, std::size_t n) noexcept {
report(p, n, false);
Expand Down
2 changes: 1 addition & 1 deletion cuvec/include/pycuvec.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ template <class T> struct PyCuVec_tp {
template <class T> PyCuVec<T> *PyCuVec_new() {
static PyCuVec_tp<T> PyCuVec_T;
if (PyType_Ready(&PyCuVec_T.tp_obj) < 0) return NULL;
return (PyCuVec<T> *)PyCuVec_T.tp_obj.tp_alloc(&PyCuVec_T.tp_obj, 1);
return (PyCuVec<T> *)PyCuVec_T.tp_obj.tp_alloc(&PyCuVec_T.tp_obj, 0);
}
template <class T> PyCuVec<T> *PyCuVec_zeros(std::vector<Py_ssize_t> shape) {
PyCuVec<T> *self = PyCuVec_new<T>();
Expand Down

0 comments on commit 429ebfa

Please sign in to comment.