Skip to content

PooledBuffer and one other minor fix #32

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions gpyfft/fft.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def __init__(self, context, queue, in_array, out_array=None, axes = None,
t_inplace = False
t_strides_out, t_distance_out, t_batchsize_out, t_shape_out, foo = self.calculate_transform_strides(
axes, out_array)
if in_array.base_data is out_array.base_data:
if in_array.base_data is out_array.base_data and in_array.offset == out_array.offset:
t_inplace = True

#assert t_batchsize_out == t_batchsize_in and t_shape == t_shape_out, 'input and output size does not match' #TODO: fails for real-to-complex
Expand Down Expand Up @@ -196,13 +196,23 @@ def enqueue_arrays(self, data = None, result = None, forward = True, wait_for_ev

# get buffer for data
if data.offset != 0:
data = data._new_with_changes(data=data.base_data[data.offset:], offset=0)
buf = data.base_data
if hasattr(buf, 'buf'):
# PooledBuffer (probably)
buf = buf.buf
data = data._new_with_changes(data=buf[data.offset:], offset=0)
del buf
data_buffer = data.base_data

if result is not None:
# get buffer for result
if result.offset != 0:
result = result._new_with_changes(data=result.base_data[result.offset:], offset=0)
buf = result.base_data
if hasattr(buf, 'buf'):
# PooledBuffer (probably)
buf = buf.buf
result = result._new_with_changes(data=buf[result.offset:], offset=0)
del buf
result_buffer = result.base_data

events = self.plan.enqueue_transform((self.queue,), (data_buffer,), (result_buffer),
Expand Down