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

PERF: Optimize GAMER IO #4651

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
28 changes: 12 additions & 16 deletions yt/frontends/gamer/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,24 +121,20 @@ def _read_fluid_selection(self, chunks, selector, fields, size):
start = (gs[0].id) * self.pgroup
end = (gs[-1].id + 1) * self.pgroup
buf = ds[start:end, :, :, :]
ngrid = len(gs)
data = np.empty((ngrid, ps2, ps2, ps2), dtype=self._field_dtype)

for g in range(ngrid):
pid0 = g * self.pgroup
data[g, 0:ps1, 0:ps1, 0:ps1] = buf[pid0 + 0, :, :, :]
data[g, 0:ps1, 0:ps1, ps1:ps2] = buf[pid0 + 1, :, :, :]
data[g, 0:ps1, ps1:ps2, 0:ps1] = buf[pid0 + 2, :, :, :]
data[g, ps1:ps2, 0:ps1, 0:ps1] = buf[pid0 + 3, :, :, :]
data[g, 0:ps1, ps1:ps2, ps1:ps2] = buf[pid0 + 4, :, :, :]
data[g, ps1:ps2, ps1:ps2, 0:ps1] = buf[pid0 + 5, :, :, :]
data[g, ps1:ps2, 0:ps1, ps1:ps2] = buf[pid0 + 6, :, :, :]
data[g, ps1:ps2, ps1:ps2, ps1:ps2] = buf[pid0 + 7, :, :, :]

data = data.transpose()
data = np.empty((ps2, ps2, ps2), dtype=self._field_dtype)

for i, g in enumerate(gs):
offset += g.select(selector, data[..., i], rv[field], offset)
pid0 = i * self.pgroup
data[0:ps1, 0:ps1, 0:ps1] = buf[pid0 + 0, :, :, :]
data[0:ps1, 0:ps1, ps1:ps2] = buf[pid0 + 1, :, :, :]
data[0:ps1, ps1:ps2, 0:ps1] = buf[pid0 + 2, :, :, :]
data[ps1:ps2, 0:ps1, 0:ps1] = buf[pid0 + 3, :, :, :]
data[0:ps1, ps1:ps2, ps1:ps2] = buf[pid0 + 4, :, :, :]
data[ps1:ps2, ps1:ps2, 0:ps1] = buf[pid0 + 5, :, :, :]
data[ps1:ps2, 0:ps1, ps1:ps2] = buf[pid0 + 6, :, :, :]
data[ps1:ps2, ps1:ps2, ps1:ps2] = buf[pid0 + 7, :, :, :]
offset += g.select(selector, data, rv[field], offset)
matthewturk marked this conversation as resolved.
Show resolved Hide resolved

return rv

def _read_chunk_data(self, chunk, fields):
Expand Down