ComputationalRadiationPhysics / student_project_python_bindings

The student project investigates the performance and memory handling of Python bindings for CUDA C++ code created with pybind11.
GNU General Public License v3.0
1 stars 0 forks source link

Writing a cupy array caster for pybind11 bindings #17

Closed SimeonEhrig closed 3 years ago

SimeonEhrig commented 3 years ago

During the development of PR #15 we recognized, that we cannot use the numpy array support of pybind11 for cupy arrays. The reason is, that both arrays uses different apis.

Therefore we need to implement a custom pybind11 caster to support a nice interface for the C++ and Python side.

Please implement the custom caster. The C++ interfaces should look like this:

void compute(mycupy::arrray_t<float> x, mycupy::arrray_t<float> y){
  kernel<<<1,1>>>(x.ptr, x.size, y.ptr, y.size);
}

This documentation contains useful information about, how a Python class is organized internal: https://docs.python.org/3/reference/datamodel.html

SimeonEhrig commented 3 years ago

Update: During the development of the cupy caster, we got new experience using pybind11, which changes some of the design decisions.

SimeonEhrig commented 3 years ago

Done in #22