Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose WarpX data to Python, on GPU #1674

Open
RemiLehe opened this issue Feb 2, 2021 · 2 comments
Open

Expose WarpX data to Python, on GPU #1674

RemiLehe opened this issue Feb 2, 2021 · 2 comments
Assignees
Labels
backend: cuda Specific to CUDA execution (GPUs) component: PICMI Standardized input format

Comments

@RemiLehe
Copy link
Member

RemiLehe commented Feb 2, 2021

Right now, WarpX exposes its data to Python, by converting it to numpy arrays:

return np.frombuffer(buf, dtype=dtype, count=size)

However, this would not be a good solution when running on GPU. Instead we should expose the data as a GPU-aware object (e.g. cupy array)

@ax3l ax3l added backend: cuda Specific to CUDA execution (GPUs) component: PICMI Standardized input format labels Feb 8, 2021
@ax3l
Copy link
Member

ax3l commented Feb 8, 2021

cupy

Comparison table has no frombuffer equivalent: https://docs.cupy.dev/en/stable/reference/comparison.html

Chainer mentions a cupy.creation.from_data: https://docs.chainer.org/en/v1.3.1/_modules/cupy/creation/from_data.html
Code

cupy.ndarray constructors not obvious to pass device pointers atm either: https://docs.cupy.dev/en/stable/reference/generated/cupy.ndarray.html#cupy.ndarray

We could explore if creating a numpy array with the pointer being a device pointer and calling cupy.asarray(numpy_array_w_device_ptr) from it works [ref] [more details] or if this triggers a copy and/or if this triggers ownership issues. There also seems to be a , copy=False option in array which is equivalent to asarray [ref].

Maybe we need to write our own constructor (could also consider contributing this upstream). I opened an issue to ask about details: cupy/cupy#4644

@ax3l
Copy link
Member

ax3l commented Feb 13, 2021

Discussion moved to: AMReX-Codes/pyamrex#9

Looks like the community standardizes on the CUDA Array Interface (v3).

Ref.: cupy/cupy#4644 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend: cuda Specific to CUDA execution (GPUs) component: PICMI Standardized input format
Projects
None yet
Development

No branches or pull requests

3 participants