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

Fix: Avoid _like function in Chunking #340

Merged
merged 1 commit into from
Apr 14, 2022
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,21 @@ def get_data(series, record_component, i_slice=None, pos_slice=None,
if i_slice is not None and not isinstance(i_slice, list):
i_slice = [i_slice]

# ADIOS2: Actual chunks, all other: one chunk
chunks = record_component.available_chunks()

# read whole data set
if pos_slice is None:
# mask invalid regions with NaN
data = np.full_like(record_component, np.nan)
# note: full_like triggers a full read, thus we avoid it #340
data = np.full(record_component.shape, np.nan, record_component.dtype)
for chunk in chunks:
chunk_slice = chunk_to_slice(chunk)
# read only valid region
x = record_component[chunk_slice]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this is related to openPMD/openPMD-api#1225
Prior to #332 we did not copy an extra time.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, @AlexanderSinn found that x = record_component[()] is fast, but it becomes slow the moment we have the data = np.full_like(record_component, np.nan) above.

We could try to make the above line a np.full with shape and dtype.

ax3l marked this conversation as resolved.
Show resolved Hide resolved
series.flush()
data[chunk_slice] = x
# slice: read only part of the data set
else:
full_shape = record_component.shape

Expand Down