You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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...
The text was updated successfully, but these errors were encountered:
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
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__
ofa
. Vice versa,b * a
calls the operator__mul__
ofb
.Take
a
to be apycuda.GPUArray
of some length (typically e.g. thebeam.x
array on the GPU) andb
to be a scalar / single number stored in apycuda.GPUArray
of length 1.In PyHEADTAIL on the GPU,
a * b
now provides an array of lengtha.shape
whileb * a
leads to a length 1 output. I.e. all contents ofa
have been swallowed...PyHEADTAIL monkeypatches
PyCUDA
to deal witha * b
(kudos to @Stefannn ) butb * a
will lead to mostly unwanted behaviour. (The monkey patching:PyHEADTAIL/PyHEADTAIL/general/contextmanager.py
Line 99 in cbd0976
==> we should cleanly fix this at some point! It's there since the very beginning...
The text was updated successfully, but these errors were encountered: