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

On GPU: Multiplication of array * scalar != scalar * array #119

Open
aoeftiger opened this issue Mar 25, 2020 · 0 comments
Open

On GPU: Multiplication of array * scalar != scalar * array #119

aoeftiger opened this issue Mar 25, 2020 · 0 comments

Comments

@aoeftiger
Copy link
Collaborator

This "feature" of Python can lead to bugs in PyHEADTAIL on the GPU when developing new modules, need to keep this in mind for the future (all current modules in PyHEADTAIL work fine normally!):

Basis: e.g. a * b calls the operator __mul__ of a. Vice versa, b * a calls the operator __mul__ of b.

Take a to be a pycuda.GPUArray of some length (typically e.g. the beam.x array on the GPU) and b to be a scalar / single number stored in a pycuda.GPUArray of length 1.

In PyHEADTAIL on the GPU, a * b now provides an array of length a.shape while b * a leads to a length 1 output. I.e. all contents of a have been swallowed...

PyHEADTAIL monkeypatches PyCUDA to deal with a * b (kudos to @Stefannn ) but b * a will lead to mostly unwanted behaviour. (The monkey patching:

# patch the GPUArray to be able to cope with gpuarrays of size 1 as ops
)

==> we should cleanly fix this at some point! It's there since the very beginning...

@aoeftiger aoeftiger changed the title On GPU: Multiplication of array * scalar != scalar * array on GPU On GPU: Multiplication of array * scalar != scalar * array Apr 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant