Skip to content
Merged
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

## [Unreleased]

### Changed

- `locate_points` (Pyccel) is about twice as fast (35.7 to 15.9 ns per point on a two-level
hierarchy of picnic's extraction case), with the same results: the cell on each level is the
finest cell divided by the level's span in double precision instead of Pyccel's integer floor
division, which takes tens of cycles per division.

### Added

- Quadtree regridding: `AMRHierarchy.regrid(method="quadtree", block_size=16)` places the
Expand Down
10 changes: 7 additions & 3 deletions src/patchwork/kernels/locate_points/locate_points_pyccel.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,13 @@ def locate_points(
if fine_z > finest_cells[2] - 1:
fine_z = finest_cells[2] - 1
for level in range(num_levels - 1, -1, -1):
index_x = fine_x // span[level]
index_y = fine_y // span[level]
index_z = fine_z // span[level]
# fine_x // span[level], in double precision: the indices are not negative
# and far below 2**26, so the quotient truncates to the same integer, and a
# floating-point division costs a few cycles where Pyccel's integer floor
# division (py_floor_div_int64_t) takes tens; half the time of this kernel
index_x = int(fine_x / span[level])
index_y = int(fine_y / span[level])
index_z = int(fine_z / span[level])
offset_x = index_x - table_corner[level, 0]
offset_y = index_y - table_corner[level, 1]
offset_z = index_z - table_corner[level, 2]
Expand Down